NATS 流媒体
NATS Streaming是一款性能极高、轻量级可靠的流媒体平台,由NATS提供支持。
NATS Streaming提供以下高级功能集:
- 基于日志的持久性
- 至少一次交付模型,提供可靠的消息交付
- 每个订阅的速率匹配
- 重播/重新启动
- 最后值语义
请注意
- 请通过问题跟踪器提出问题/问题。
安装
# Go client go get github.com/nats-io/stan.go/
基本使用
import stan "github.com/nats-io/stan.go" sc, _ := stan.Connect(clusterID, clientID) // Simple Synchronous Publisher sc.Publish("foo", []byte("Hello World")) // does not return until an ack has been received from NATS Streaming // Simple Async Subscriber sub, _ := sc.Subscribe("foo", func(m *stan.Msg) { fmt.Printf("Received a message: %s\n", string(m.Data)) }) // Unsubscribe sub.Unsubscribe() // Close connection sc.Close()