Streams ClientGo SDK
Accessed via client.Streams() on the Hatchet client.
StreamsClient
StreamsClient publishes to and reads from durable topics. Unlike ctx.PutStream streams, topics are stored, independent of any run, and readers can resume from a cursor.
Methods:
| Name | Description |
|---|---|
Events | Events streams topic's messages from the start or WithCursor. |
Publish | Publish returns once the message is stored. |
Functions
Events
Events streams topic's messages from the start or WithCursor. The channel closes when ctx ends, the connection drops or the server hangs up; to continue, call Events again with the last event's Cursor.
func (s *StreamsClient) Events(ctx context.Context, topic string, opts ...StreamCallOpt) <-chan StreamEventParameters:
| Name | Type |
|---|---|
ctx | context.Context |
topic | string |
opts | ...StreamCallOpt |
Returns:
| Type |
|---|
<-chan StreamEvent |
Publish
Publish returns once the message is stored. A topic is created on first publish. A client's messages to a topic are delivered in the order they were stored.
func (s *StreamsClient) Publish(ctx context.Context, topic string, message []byte, opts ...StreamCallOpt) errorParameters:
| Name | Type |
|---|---|
ctx | context.Context |
topic | string |
message | []byte |
opts | ...StreamCallOpt |
Returns:
| Type |
|---|
error |
Related types
StreamEvent
StreamEvent is a stored message. Its Cursor resumes Events right after it.
Fields:
| Name | Type | Description |
|---|---|---|
Payload | []byte | |
Cursor | string | |
CreatedAt | time.Time |
StreamCallOpt
StreamCallOpt configures a call to StreamsClient.Publish or StreamsClient.Events.
Functions
WithCursor
WithCursor resumes Events after the StreamEvent the cursor came from. Without it, Events starts at the oldest retained message. Ignored by Publish.
func WithCursor(cursor string) StreamCallOptParameters:
| Name | Type |
|---|---|
cursor | string |
Returns:
| Type |
|---|
StreamCallOpt |
WithNamespace
WithNamespace sets the namespace; the default is "".
func WithNamespace(namespace string) StreamCallOptParameters:
| Name | Type |
|---|---|
namespace | string |
Returns:
| Type |
|---|
StreamCallOpt |
Last updated on October 2, 2026