sbctransport

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyKey = fmt.Errorf("key is empty")

ErrEmptyKey is an error that is returned when the key is empty.

View Source
var ErrNoMessages = fmt.Errorf("topic has no messages")

ErrNoMessages is returned by Current when the topic has no messages yet.

Functions

This section is empty.

Types

type ChainTransport added in v1.1.0

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

ChainTransport aggregates multiple transports and merges their results. Transports later in the chain override values from earlier transports.

func NewChainTransport added in v1.1.0

func NewChainTransport(encoder sbc.Encoder, transports ...sbc.Transport) *ChainTransport

NewChainTransport creates a new ChainTransport.

func (*ChainTransport) Current added in v1.1.0

func (c *ChainTransport) Current(ctx context.Context, key string) ([]byte, error)

Current retrieves the merged value from all transports.

func (*ChainTransport) Updates added in v1.1.0

func (c *ChainTransport) Updates(ctx context.Context, key string) (<-chan []byte, error)

Updates returns a channel that streams merged updates.

type ConsulTransport

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

ConsulTransport represents a transport mechanism for accessing and manipulating data stored in Consul Key-Value store.

func NewConsulTransport

func NewConsulTransport(kv *capi.KV, opts ...ConsulTransportOpt) *ConsulTransport

NewConsulTransport creates a new ConsulTransport.

func (ConsulTransport) Current

func (c ConsulTransport) Current(ctx context.Context, key string) ([]byte, error)

Current retrieves the current value for the specified key from the Consul Key-Value store.

func (ConsulTransport) Updates

func (c ConsulTransport) Updates(ctx context.Context, key string) (<-chan []byte, error)

Updates creates a channel that streams updates for a given key in the Consul KV store, emitting updated values.

type ConsulTransportOpt

type ConsulTransportOpt func(*ConsulTransport)

ConsulTransportOpt is a function type that modifies the properties of a ConsulTransport. It accepts a pointer to a ConsulTransport instance and updates its properties. TODO: add Consul enterprise options, like Namespace, Partition, etc. usefully options.

func WithUpdateInterval

func WithUpdateInterval(interval time.Duration) ConsulTransportOpt

WithUpdateInterval is a ConsulTransportOpt function that sets the update interval for ConsulTransport. It ensures that the update interval is at least 100 milliseconds. It accepts a duration parameter and updates the ConsulTransport's update interval.

func WithUpdateJitter added in v1.0.1

func WithUpdateJitter(jitter time.Duration) ConsulTransportOpt

WithUpdateJitter is a ConsulTransportOpt function that sets the update jitter for ConsulTransport. It accepts a duration parameter and updates the ConsulTransport's update jitter.

type DemoTransport

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

func NewDemoTransport

func NewDemoTransport(payload []byte, interval time.Duration) *DemoTransport

func (DemoTransport) Current

func (d DemoTransport) Current(ctx context.Context, _ string) ([]byte, error)

func (DemoTransport) Updates

func (d DemoTransport) Updates(ctx context.Context, key string) (<-chan []byte, error)

type FixedTransport added in v1.0.2

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

FixedTransport is transport that returns a predefined payload for data retrieval operations.

func NewFixedTransport added in v1.0.2

func NewFixedTransport(payload []byte) *FixedTransport

NewFixedTransport creates a FixedTransport instance with a predefined payload for retrieval operations.

func (FixedTransport) Current added in v1.0.2

func (d FixedTransport) Current(_ context.Context, _ string) ([]byte, error)

Current retrieves the predefined payload associated with the FixedTransport instance.

func (FixedTransport) Updates added in v1.0.2

func (d FixedTransport) Updates(ctx context.Context, _ string) (<-chan []byte, error)

Updates creates a channel for receiving updates, closing it when the provided context is done.

type KafkaTransport added in v1.2.0

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

KafkaTransport is a transport that reads configuration from a Kafka topic. The key argument passed to Current and Updates is used as the Kafka topic name.

func NewKafkaTransport added in v1.2.0

func NewKafkaTransport(brokers []string, opts ...KafkaTransportOpt) (*KafkaTransport, error)

NewKafkaTransport creates a KafkaTransport connecting to the given brokers.

func (*KafkaTransport) Current added in v1.2.0

func (k *KafkaTransport) Current(ctx context.Context, key string) ([]byte, error)

Current retrieves the latest message value for the given topic (key). It fetches the newest offset and reads the message at that offset.

func (*KafkaTransport) Updates added in v1.2.0

func (k *KafkaTransport) Updates(ctx context.Context, key string) (<-chan []byte, error)

Updates returns a channel that streams new messages from the given topic (key) using a Kafka consumer group. The channel is closed when the context is cancelled. If the consumer group session ends and the context is still active it reconnects automatically.

type KafkaTransportOpt added in v1.2.0

type KafkaTransportOpt func(*KafkaTransport)

KafkaTransportOpt is a functional option for KafkaTransport.

func WithKafkaGroupID added in v1.2.0

func WithKafkaGroupID(groupID string) KafkaTransportOpt

WithKafkaGroupID sets the consumer group ID used by Updates. Default is "streaming-based-config".

func WithKafkaPartition added in v1.2.0

func WithKafkaPartition(partition int32) KafkaTransportOpt

WithKafkaPartition sets the partition used by Current to fetch the latest message. Default is 0.

type NatsTransport

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

NatsTransport represents a transport mechanism for accessing and manipulating data stored in NATS Key-Value store.

func NewNatsTransport

func NewNatsTransport(kv jetstream.KeyValue) *NatsTransport

NewNatsTransport creates a new NatsTransport.

func (NatsTransport) Current

func (n NatsTransport) Current(ctx context.Context, key string) ([]byte, error)

func (NatsTransport) Updates

func (n NatsTransport) Updates(ctx context.Context, key string) (<-chan []byte, error)

type NothingTransport

type NothingTransport struct{}

NothingTransport represents a type that doesn't actually perform any transportation. It is a struct with no fields and implements the Current and Updates methods of the transport interface. Both methods return empty results or nil.

func NewNothingTransport

func NewNothingTransport() *NothingTransport

NewNothingTransport creates a new NothingTransport.

func (NothingTransport) Current

func (n NothingTransport) Current(_ context.Context, _ string) ([]byte, error)

func (NothingTransport) Updates

func (n NothingTransport) Updates(_ context.Context, _ string) (<-chan []byte, error)

Jump to

Keyboard shortcuts

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