Retrieve a stream
Edit this pageStream · Related pages
Posted: 2026-09-16 · Report this thread
Get(ctx context.Context) (*Stream, error)Reads the named stream’s registration. It does not create a missing stream or change an existing stream’s settings or messages.
Example
Read the payments.requested stream using an initialized client.
RawPayload avoids declaring a payload type for this registration lookup.
payments := client.Stream[sqlstreams.RawPayload]("payments.requested")stream, err := payments.Get(ctx)if err != nil { return err}if stream == nil { return errors.New("payments.requested is not registered")}fmt.Println(stream.Id, stream.RetentionTTL)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context |
Yes | Cancelling this context or reaching its deadline interrupts the database read. |
Returns
| Condition | Return value |
|---|---|
| Stream is registered | (stream, nil), where stream is the stream object. |
| Stream or installation is absent | (nil, nil). |
| Read fails | (nil, err). |
CLI
sqlstreams stream get payments.requestedPrints the registration and exits with status 0 when found. An absent stream
prints an absence message and exits with status 1. See
stream commands for output formats and flags.
Errors
| Error | When |
|---|---|
| Validation error | The stream name is empty. |
| Read error | The database read fails or stored settings cannot be decoded. |
| Context cancellation or deadline error | The read is interrupted by its context. |
Related topics
- The stream object — Returned fields.
- Register a stream — Create or update a registration.