sbctransport

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: Apache-2.0 Imports: 7 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.

Functions

This section is empty.

Types

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 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