Skip to content

goku321/pulsar-proto-x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to use proto schema with pulsar go client library

  • Define a .proto file

  • Generate Code using below command:

    protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --gogofast_out=. --gogofast_opt=paths=source_relative your_file.proto
  • Attach schema to the topic

    1. Generate a JSON string of your schema.

    2. Define schema definition in a json file. See example schema definition below:

      {
          "type": "PROTOBUF",
          "schema": "{\"fields\":[{\"default\":\"\",\"name\":\"name\",\"type\":\"string\"},{\"default\":0,\"name\":\"age\",\"type\":\"int\"}],\"name\":\"Person\",\"namespace\":\"person\",\"type\":\"record\"}",
          "properties": {}
      }
    3. Upload schema to the pulsar topic

      pulsar-admin schemas upload --filename < schemafile > < topicname >
  • Use Generated types while creating producer/consumer. See producer/producer_test.go for examples.

About

Experiments with pulsar go client and protobuf

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages