diff options
Diffstat (limited to 'transport/channel.go')
| -rw-r--r-- | transport/channel.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/transport/channel.go b/transport/channel.go new file mode 100644 index 0000000..56d5f2b --- /dev/null +++ b/transport/channel.go | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | package transport | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "context" | ||
| 5 | |||
| 6 | "flux/core" | ||
| 7 | ) | ||
| 8 | |||
| 9 | type Receiver[T any] interface { | ||
| 10 | // Receive returns the next record, or ok=false once the stream is done or | ||
| 11 | // ctx is cancelled. | ||
| 12 | Receive(ctx context.Context) (core.StreamRecord[T], bool) | ||
| 13 | Close() error | ||
| 14 | } | ||
| 15 | |||
| 16 | // Emitter mirrors core.Emitter plus Close. It is declared separately because | ||
| 17 | // core cannot import transport without an import cycle. | ||
| 18 | type Emitter[T any] interface { | ||
| 19 | // Emit blocks until the record is handed off, or returns ctx.Err() if ctx | ||
| 20 | // is cancelled first. | ||
| 21 | Emit(ctx context.Context, record core.StreamRecord[T]) error | ||
| 22 | Close() error | ||
| 23 | } | ||
