Hanzo PubSub
The bus everything else rides
PubSub moves messages between services on port 4222. Publish to a subject and everyone listening on it — or on a pattern that matches it — has the message. Add a stream and those same messages are written down too, so a consumer that was offline can start from the beginning, from a sequence number, or from a timestamp. Streams, key-value buckets, an object store and request-reply are one server, not four.
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.
Read https://hanzo.ai/skill.md and use Hanzo Pubsub in my project. Start with: hanzo pubsub publish
Publish and Subscribe
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()
}20% to the author of the code that runs
Verify that you own a repository, and every org that deploys a project built from it pays you 20% of its metered spend, accrued each period.