Documentation
¶
Overview ¶
Package ami - Go client to reliable queues based on Redis Cluster Streams https://redis.io/topics/streams-intro.
Producer example
pr, err := ami.NewProducer( ami.ProducerOptions{ Name: "ruthie", ShardsCount: 10, PendingBufferSize: 10000000, PipeBufferSize: 50000, PipePeriod: time.Microsecond * 1000, }, &redis.ClusterOptions{ Addrs: []string{"172.17.0.1:7001", "172.17.0.1:7002"}, }, ) if err != nil { panic(err) } for i := 0; i < 10000; i++ { pr.Send("{}") } pr.Close()
Consumer example
cn, err := ami.NewConsumer( ami.ConsumerOptions{ Name: "ruthie", Consumer: "alice", ShardsCount: 10, PrefetchCount: 100, Block: time.Second, PendingBufferSize: 10000000, PipeBufferSize: 50000, PipePeriod: time.Microsecond * 1000, }, &redis.ClusterOptions{ Addrs: []string{"172.17.0.1:7001", "172.17.0.1:7002"}, }, ) if err != nil { panic(err) } c := cn.Start() wg := sync.WaitGroup{} wg.Add(1) go func() { for { m, more := <-c if !more { break } println("Got", m.Body, "ID", m.ID) cn.Ack(m) } wg.Done() }() time.Sleep(time.Second) cn.Stop() wg.Wait() cn.Close()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consumer ¶ added in v0.1.6
type Consumer struct {
// contains filtered or unexported fields
}
Consumer client for Ami
func NewConsumer ¶ added in v0.1.6
func NewConsumer(opt ConsumerOptions, ropt *redis.ClusterOptions) (*Consumer, error)
NewConsumer creates new consumer client for Ami
type ConsumerOptions ¶ added in v0.1.6
type ConsumerOptions struct { Name string Consumer string ShardsCount int8 PrefetchCount int64 Block time.Duration PendingBufferSize int64 PipeBufferSize int64 PipePeriod time.Duration }
ConsumerOptions - options for consumer client for Ami
type Producer ¶ added in v0.1.6
type Producer struct {
// contains filtered or unexported fields
}
Producer client for Ami
func NewProducer ¶ added in v0.1.6
func NewProducer(opt ProducerOptions, ropt *redis.ClusterOptions) (*Producer, error)
NewProducer creates new producer client for Ami
Click to show internal directories.
Click to hide internal directories.