sbctransport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 6 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)

func (ConsulTransport) Updates

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

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.

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