Stream
查看 MarkdownThis page lists the Go SDK names for Streams. The doc comment of each API gives its parameters, defaults, and errors. Read them in the Go SDK API reference.
API names
| Task | Go API | Dex behavior |
|---|---|---|
| Define a Stream and its byte capacity | DefineStream, with its streamCapacityBytes argument | Capacity and trimming |
| Declare it in the Flow | Streams of PersistenceSchema, returned from GetPersistenceSchema | Flow definition |
| Write a message from a Step | Stream.Write | Write semantics |
| Write text chunks in batches from a Step | NewBufferedTextStream, which returns a BufferedTextStream | Buffer text chunks |
| Write a message from a Client | Client.WriteStream | Write semantics |
| Read the next message | Client.ReadStream, with the ResumeToken of the last StreamMessage | Resumable reads |
| List retained messages, newest first | Client.ListStreamMessages, into a StreamMessagesPage | List messages |
Stream.Write works in WaitFor, Execute, and the Flow timeout handler. An RPC handler cannot write a Stream. Stream.Write sends the message right away. Its error covers only local validation, encoding, and transport.