Stencil go client package provides a store to lookup protobuf descriptors and options to keep the protobuf descriptors upto date.
It has following features
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://localhost:8000/v1beta1/namespaces/{test-namespace}/schemas/{schema-name}"
client, err := stencil.NewClient([]string{url}, stencil.Options{})
import stencil "github.com/odpf/stencil/clients/go"
url := "http://localhost:8000/v1beta1/namespaces/{test-namespace}/schemas/{schema-name}"
client, err := stencil.NewClient([]string{url}, stencil.Options{})
if err != nil {
return
}
desc, err := client.GetDescriptor("google.protobuf.DescriptorProto")
import stencil "github.com/odpf/stencil/clients/go"
url := "http://localhost:8000/v1beta1/namespaces/{test-namespace}/schemas/{schema-name}"
client, err := stencil.NewClient([]string{url}, stencil.Options{})
if err != nil {
return
}
data := []byte("")
parsedMsg, err := client.Parse("google.protobuf.DescriptorProto", data)
import stencil "github.com/odpf/stencil/clients/go"
url := "http://url/to/proto/descriptorset/file"
client, err := stencil.NewClient([]string{url}, stencil.Options{})
if err != nil {
return
}
data := map[string]interface{}{}
serializedMsg, err := client.Serialize("google.protobuf.DescriptorProto", data)
import stencil "github.com/odpf/stencil/clients/go"
url := "http://localhost:8000/v1beta1/namespaces/{test-namespace}/schemas/{schema-name}"
// Configured to refresh schema every 12 hours
client, err := stencil.NewClient([]string{url}, stencil.Options{AutoRefresh: true, RefreshInterval: time.Hours * 12})
if err != nil {
return
}
desc, err := client.GetDescriptor("google.protobuf.DescriptorProto")
import stencil "github.com/odpf/stencil/clients/go"
url := "http://localhost:8000/v1beta1/namespaces/{test-namespace}/schemas/{schema-name}"
// Configured to refresh schema every 12 hours
client, err := stencil.NewClient([]string{url}, stencil.Options{AutoRefresh: true, RefreshInterval: time.Hours * 12, RefreshStrategy: stencil.VersionBasedRefresh})
if err != nil {
return
}
desc, err := client.GetDescriptor("google.protobuf.DescriptorProto")
Refer to go documentation for all available methods and options.
Can you improve this documentation? These fine people already did:
Hari krishna & Ravi SuhagEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close