Stencil go client package provides a store to lookup protobuf descriptors and options to keep the protobuf descriptors upto date.
It has following features
- Deserialize protobuf messages directly by specifying protobuf message name
- Ability to refresh protobuf descriptors in specified intervals
- Support to download descriptors from multiple urls
- go 1.16
Use go get
go get github.com/odpf/stencil/clients/go
Then import the stencil package into your own code as mentioned below
import stencil "github.com/odpf/stencil/clients/go"
import stencil "github.com/odpf/stencil/clients/go"
url := "http://url/to/proto/descriptorset/file"
client, err := stencil.NewClient(url, stencil.Options{})
import stencil "github.com/odpf/stencil/clients/go"
urls := []string{"http://urlA", "http://urlB"}
client, err := stencil.NewMultiURLClient(urls, stencil.Options{})
import stencil "github.com/odpf/stencil/clients/go"
url := "http://url/to/proto/descriptorset/file"
client, err := stencil.NewClient(url, stencil.Options{})
if err != nil {
return
}
desc, err := client.GetDescriptor("google.protobuf.DescriptorProto")
import stencil "github.com/odpf/stencil/clients/go"
url := "http://url/to/proto/descriptorset/file"
client, err := stencil.NewClient(url, stencil.Options{})
if err != nil {
return
}
data := []byte("")
desc, err := client.Parse("google.protobuf.DescriptorProto", data)
Refer to go documentation for all available methods and options.