Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Support Value well known type #55

Closed
codebien opened this issue Oct 16, 2023 · 3 comments
Closed

Support Value well known type #55

codebien opened this issue Oct 16, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@codebien
Copy link
Contributor

Context

From the community we got a report regarding the missing support for Value Protobuf type: https://community.grafana.com/t/k6-is-sending-empty-text-for-datetime-string/105656.

An edited version of our internal test for Any confirms the issue. Sharing the patch below.

grpc-value-type-test.txt

@codebien codebien added the enhancement New feature or request label Oct 16, 2023
@olegbespalov
Copy link
Collaborator

olegbespalov commented Oct 20, 2023

@codebien we do support (well actually we do after #49 which means it's v0.47) this type, check this PR #56

I believe we're missing more examples (maybe here, but for sure in grafana/k6-docs#1378) of how to use these wrappers. It's not so transparent that in the case of the wrapper, there is no need to pack this into the structure, like:

let respString = client.invoke("grpc.wrappers.testing.Service/TestValue", "John")
if (respString.message !== "hey John") {
	throw new Error("expected to get 'hey John', but got a " + respString.message)
}

let respNumber = client.invoke("grpc.wrappers.testing.Service/TestValue", 12)
if (respNumber.message !== 42) {
	throw new Error("expected to get '42', but got a " + respNumber.message)
}

@codebien
Copy link
Contributor Author

codebien commented Oct 23, 2023

@olegbespalov I'm struggling to find some good references about it. Reading https://protobuf.dev/reference/protobuf/google.protobuf/#value I had the impression that what the user suggested is a correct form. Do you have other references with better documentation?

@olegbespalov
Copy link
Collaborator

@codebien, the link that you've suggested is the right one. But keep in mind that this is the definition of the specification of the protobuf language. It's lacking of language-specific.

For instance, there is no direct access to string_value. It's the responsibility of the serializer (in our case, it's https://pkg.go.dev/google.golang.org/protobuf/encoding/protojson) to put the correct value there, or at least it's what's happening for the most cases.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants