redisstream

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package redisstream provides a Redis Streams adapter for runtime/contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder func(json.RawMessage) (any, error)

Decoder converts one JSON event value into the typed value expected by runtime/contracts subscribers.

type Option

type Option func(*Store)

Option configures a Store.

func WithBatchSize

func WithBatchSize(size int64) Option

WithBatchSize sets the max stream messages returned per receive call.

func WithBlock

func WithBlock(block time.Duration) Option

WithBlock sets the Redis XREADGROUP block duration.

func WithDecoder

func WithDecoder(eventType string, decoder Decoder) Option

WithDecoder registers a decoder for one event type.

func WithJSONDecoder

func WithJSONDecoder[T any](eventType string) Option

WithJSONDecoder registers a JSON decoder for one event type.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store publishes events to a Redis stream and reads them through a consumer group. It implements contracts.Broker and contracts.EventSource.

func New

func New(client *redis.Client, stream, group, consumer string, options ...Option) *Store

New creates a Redis Streams store.

func (*Store) EnsureGroup

func (store *Store) EnsureGroup(ctx context.Context) error

EnsureGroup creates the consumer group if it does not already exist.

func (*Store) PublishEvents

func (store *Store) PublishEvents(ctx context.Context, events []contracts.EventEnvelope) error

PublishEvents appends event envelopes to the Redis stream.

func (*Store) ReceiveEventBatch

func (store *Store) ReceiveEventBatch(ctx context.Context) (contracts.EventBatch, error)

ReceiveEventBatch reads the next stream batch for this consumer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL