More than pub/sub
A stream captures the subjects you name and keeps them by age, by count or by bytes. A consumer starts at the beginning, at the newest message, at a sequence number or at a wall-clock time, and reads at the original pace or as fast as it can take them.
Paste and ship
Paste this into any agent. It reads the skill manifest and calls Pubsub from there.
Agent prompt
Read https://hanzo.ai/skill.md and use Hanzo Pubsub in my project. Start with: hanzo pubsub publish
4222Client port
ReplayFrom any point
DurableWritten to disk
ReplicasSet per stream
Publish and Subscribe
events.go
nc, _ := nats.Connect("nats://pubsub.hanzo.ai:4222")
js, _ := nc.JetStream()
// Create a durable stream
js.AddStream(&nats.StreamConfig{
Name: "EVENTS",
Subjects: []string{"events.>"},
Storage: nats.FileStorage,
Replicas: 3,
})
// Publish
js.Publish("events.user.signup", []byte(`{"id":"usr_123"}`))
// Durable consumer with ack
sub, _ := js.PullSubscribe("events.>", "my-service")
msgs, _ := sub.Fetch(10)
for _, msg := range msgs {
process(msg.Data)
msg.Ack()
}