# README
tipubsub
A small library using TiDB providing Sub/Pub API at sacle.
Subscriber:
type MySubscriber struct {}
var _ pubsub.Subscriber = (*MySubscriber)(nil)
func (s *MySubscriber) OnMessages(streamName string, msgs []pubsub.Message) {
for _, msg := range msgs {
log.I("Got Message:", msg, msg.ID)
}
}
func (s *MySubscriber) Id() string {
return "my_subscriber"
}
func main() {
...
sub := &MySubscriber{}
hub, err := pubsub.NewHub(cfg)
if err != nil {
log.Fatal(err)
}
err = hub.Subscribe("test_stream", sub, offset)
if err != nil {
log.Fatal(err)
}
...
}
Publisher:
func main() {
...
hub, err := pubsub.NewHub(cfg)
if err != nil {
log.Fatal(err)
}
for i := 0; i < 10000; i++ {
hub.Publish("test_stream", &pubsub.Message{
Data: []byte(fmt.Sprintf("Message: %d", i)),
})
}
...
}
See example
for more details
# Functions
No description provided by the author
No description provided by the author
LoadConfig loads config from file.
LoadConfigFromEnv loads config from environment variables.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
PollWorker is a worker that polls messages from a stream.
NOT yet implemented, just a placeholder.
No description provided by the author
No description provided by the author
# Interfaces
Store is the interface for the storage of the messages.
# Type aliases
No description provided by the author