-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RSDK-8312] Collect and send API and SDK version in metadata (#53)
- Loading branch information
Showing
13 changed files
with
89 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
.PHONY: buf | ||
buf: | ||
rm -rf core/sdk/src/main/gen | ||
rm -rf core/sdk/src/main/resources/protofds | ||
mkdir -p core/sdk/src/main/resources/protofds | ||
buf build --as-file-descriptor-set=true -o core/sdk/src/main/resources/protofds/viam.api buf.build/viamrobotics/api | ||
buf generate --template buf.gen.yaml buf.build/viamrobotics/api | ||
buf build --as-file-descriptor-set=true -o core/sdk/src/main/resources/protofds/viam.api buf.build/viamrobotics/api:$$(cat api_version.lock) | ||
buf generate --template buf.gen.yaml buf.build/viamrobotics/api:$$(cat api_version.lock) | ||
buf generate --template buf.gen.yaml buf.build/viamrobotics/goutils | ||
buf generate --template buf.gen.yaml buf.build/googleapis/googleapis | ||
|
||
.PHONY: run_client | ||
run_client: | ||
./gradlew runExample1Client --args="localhost:8080" | ||
|
||
.PHONY: run_client_webrtc_auth | ||
run_client_webrtc_auth: | ||
./gradlew runExample2Client | ||
|
||
.PHONY: run_client_grpc_auth | ||
run_client_grpc_auth: | ||
./gradlew runExample3Client | ||
|
||
.PHONY: run_server | ||
run_server: | ||
./gradlew runExample1Server --args="8080" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v0.1.327 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
version: v1 | ||
version: v2 | ||
plugins: | ||
- plugin: buf.build/protocolbuffers/java:v25.2 | ||
- remote: buf.build/protocolbuffers/java:v27.2 | ||
out: core/sdk/src/main/gen | ||
opt: lite | ||
- plugin: buf.build/grpc/java:v1.61.1 | ||
- remote: buf.build/grpc/java:v1.65.1 | ||
out: core/sdk/src/main/gen | ||
opt: lite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
core/sdk/src/main/java/com/viam/sdk/core/rpc/BasicManagedChannel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
core/sdk/src/main/kotlin/com/viam/sdk/core/util/Metadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@file:JvmName("Metadata") | ||
package com.viam.sdk.core.util | ||
|
||
import io.grpc.Metadata | ||
|
||
/** | ||
* Metadata containing client and API versions | ||
*/ | ||
val VERSION_METADATA: Metadata | ||
get() { | ||
val md = Metadata() | ||
md.put(Metadata.Key.of("viam_client", Metadata.ASCII_STRING_MARSHALLER), "java;$SDK_VERSION;$API_VERSION") | ||
return md; | ||
} |
4 changes: 4 additions & 0 deletions
4
core/sdk/src/main/kotlin/com/viam/sdk/core/util/VersionInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.viam.sdk.core.util | ||
|
||
const val SDK_VERSION = "v0.0.5" | ||
const val API_VERSION = "v0.1.327" |
19 changes: 19 additions & 0 deletions
19
core/sdk/src/test/kotlin/com/viam/sdk/core/util/MetadataTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.viam.sdk.core.util | ||
|
||
import io.grpc.Metadata | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.Assertions.* | ||
|
||
class MetadataTest { | ||
|
||
@Test | ||
fun getVersionMetadata() { | ||
val metadata = VERSION_METADATA | ||
val versionString = metadata.get(Metadata.Key.of("viam_client", Metadata.ASCII_STRING_MARSHALLER)) | ||
assertNotNull(versionString) | ||
val components = versionString!!.split(";") | ||
assertEquals(components[0], "java") | ||
assertTrue(components[1].matches("v[0-9]+\\.[0-9]+\\.[0-9]+".toRegex())) | ||
assertTrue(components[2].matches("(v[0-9]+\\.[0-9]+\\.[0-9]+)|unreleased".toRegex())) | ||
} | ||
} |