modulepackage
0.0.0-20240416085252-550848e1bdd4
Repository: https://github.com/tiantiandas/prototube-go.git
Documentation: pkg.go.dev
# README
Prototube
Package prototube implements an API to publish strongly-typed events into Kafka.
Applications can publish events into a specific topic. A topic is always associated with a schema which defines the schema of the event. Events that do not conform with the schemas are rejected.
Internally prototube encodes the events using the following format:
<Magic Number> <Header> <Event>
- Magic Number: 0x50, 0x42, 0x54, 0x42
- Header: Protobuf-encoded structure that contains the metadata of the event (e.g, timestamp / uuid)
- Event: Protobuf-encoded event
How to use
Prerequisite
Please follow this Kafka Quickstart link to install and start Kafka locally.
Quickstart
Build and run the example application to produce random messages to local Kafka.
$ cd examples
$ go run main.go
Compile a proto file
Below command generates the example example.pb.go
from example.proto
with module main
.
$ cd examples
$ protoc --go_out=. idl/example.proto
Use prototube producer
Please see this example for your reference.
Code snippet:
producer, err := prototube.NewWithConfig("testTopic", &prototube.ProducerConfig{
KafkaBootstrapBrokerList: []string{"localhost:9092"},
})
producer.Emit(&ExamplePrototubeMessage{
Int32Field: int32(rand.Intn(10000)),
Int64Field: rand.Int63n(int64(10000) + 10000),
DoubleField: rand.Float64(),
})
# Packages
No description provided by the author
# Functions
New create a new producer for the specified topic.
NewWithConfig create a new producer for the specified topic.
# Structs
Producer a event log producer that pushes events into Kinesis stream.
ProducerConfig configs to create a Sarama Kafka Producer.
Server side message decoration.