nats

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package nats is a generated GoMock package.

Package nats is a generated GoMock package.

Package nats is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(configs Configs) *Client

New creates a new NATS-KV client with the provided configuration.

func (*Client) Connect

func (c *Client) Connect()

Connect establishes a connection to NATS-KV and registers metrics using the provided configuration when the client is created.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (string, error)

func (*Client) HealthCheck

func (c *Client) HealthCheck(ctx context.Context) (any, error)

func (*Client) Set

func (c *Client) Set(ctx context.Context, key, value string) error

func (*Client) UseLogger

func (c *Client) UseLogger(logger any)

UseLogger sets the logger for the NATS-KV client which asserts the Logger interface.

func (*Client) UseMetrics

func (c *Client) UseMetrics(metrics any)

UseMetrics sets the metrics for the NATS-KV client which asserts the Metrics interface.

func (*Client) UseTracer

func (c *Client) UseTracer(tracer any)

UseTracer sets the tracer for NATS-KV client.

type Configs

type Configs struct {
	Server string
	Bucket string
}

type Health

type Health struct {
	Status  string         `json:"status,omitempty"`
	Details map[string]any `json:"details,omitempty"`
}

type JetStream

type JetStream interface {
	AccountInfo() (*nats.AccountInfo, error)
}

type KeyValue

type KeyValue interface {
	Get(key string) (entry nats.KeyValueEntry, err error)
	GetRevision(key string, revision uint64) (entry nats.KeyValueEntry, err error)
	Put(key string, value []byte) (revision uint64, err error)
	PutString(key string, value string) (revision uint64, err error)
	Create(key string, value []byte) (revision uint64, err error)
	Update(key string, value []byte, last uint64) (revision uint64, err error)
	Delete(key string, opts ...nats.DeleteOpt) error
	Purge(key string, opts ...nats.DeleteOpt) error
	Watch(keys string, opts ...nats.WatchOpt) (nats.KeyWatcher, error)
	WatchAll(opts ...nats.WatchOpt) (nats.KeyWatcher, error)
	WatchFiltered(keys []string, opts ...nats.WatchOpt) (nats.KeyWatcher, error)
	Keys(opts ...nats.WatchOpt) ([]string, error)
	ListKeys(opts ...nats.WatchOpt) (nats.KeyLister, error)
	History(key string, opts ...nats.WatchOpt) ([]nats.KeyValueEntry, error)
	Bucket() string
	PurgeDeletes(opts ...nats.PurgeOpt) error
	Status() (nats.KeyValueStatus, error)
}

type Log

type Log struct {
	Type     string `json:"type"`
	Duration int64  `json:"duration"`
	Key      string `json:"key"`
	Value    string `json:"value,omitempty"`
}

func (*Log) PrettyPrint

func (l *Log) PrettyPrint(writer io.Writer)

type Logger

type Logger interface {
	Debug(args ...any)
	Debugf(pattern string, args ...any)
	Info(args ...any)
	Infof(pattern string, args ...any)
	Error(args ...any)
	Errorf(pattern string, args ...any)
}

type Metrics

type Metrics interface {
	NewHistogram(name, desc string, buckets ...float64)

	RecordHistogram(ctx context.Context, name string, value float64, labels ...string)
}

type MockJts

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

MockJts is a mock of Jts interface.

func NewMockJts

func NewMockJts(ctrl *gomock.Controller) *MockJts

NewMockJts creates a new mock instance.

func (*MockJts) AccountInfo

func (m *MockJts) AccountInfo() (*nats.AccountInfo, error)

AccountInfo mocks base method.

func (*MockJts) EXPECT

func (m *MockJts) EXPECT() *MockJtsMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockJtsMockRecorder

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

MockJtsMockRecorder is the mock recorder for MockJts.

func (*MockJtsMockRecorder) AccountInfo

func (mr *MockJtsMockRecorder) AccountInfo() *gomock.Call

AccountInfo indicates an expected call of AccountInfo.

type MockKeyValue

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

MockKeyValue is a mock of KeyValue interface.

func NewMockKeyValue

func NewMockKeyValue(ctrl *gomock.Controller) *MockKeyValue

NewMockKeyValue creates a new mock instance.

func (*MockKeyValue) Bucket

func (m *MockKeyValue) Bucket() string

Bucket mocks base method.

func (*MockKeyValue) Create

func (m *MockKeyValue) Create(key string, value []byte) (uint64, error)

Create mocks base method.

func (*MockKeyValue) Delete

func (m *MockKeyValue) Delete(key string, opts ...nats.DeleteOpt) error

Delete mocks base method.

func (*MockKeyValue) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockKeyValue) Get

func (m *MockKeyValue) Get(key string) (nats.KeyValueEntry, error)

Get mocks base method.

func (*MockKeyValue) GetRevision

func (m *MockKeyValue) GetRevision(key string, revision uint64) (nats.KeyValueEntry, error)

GetRevision mocks base method.

func (*MockKeyValue) History

func (m *MockKeyValue) History(key string, opts ...nats.WatchOpt) ([]nats.KeyValueEntry, error)

History mocks base method.

func (*MockKeyValue) Keys

func (m *MockKeyValue) Keys(opts ...nats.WatchOpt) ([]string, error)

Keys mocks base method.

func (*MockKeyValue) ListKeys

func (m *MockKeyValue) ListKeys(opts ...nats.WatchOpt) (nats.KeyLister, error)

ListKeys mocks base method.

func (*MockKeyValue) Purge

func (m *MockKeyValue) Purge(key string, opts ...nats.DeleteOpt) error

Purge mocks base method.

func (*MockKeyValue) PurgeDeletes

func (m *MockKeyValue) PurgeDeletes(opts ...nats.PurgeOpt) error

PurgeDeletes mocks base method.

func (*MockKeyValue) Put

func (m *MockKeyValue) Put(key string, value []byte) (uint64, error)

Put mocks base method.

func (*MockKeyValue) PutString

func (m *MockKeyValue) PutString(key, value string) (uint64, error)

PutString mocks base method.

func (*MockKeyValue) Status

func (m *MockKeyValue) Status() (nats.KeyValueStatus, error)

Status mocks base method.

func (*MockKeyValue) Update

func (m *MockKeyValue) Update(key string, value []byte, last uint64) (uint64, error)

Update mocks base method.

func (*MockKeyValue) Watch

func (m *MockKeyValue) Watch(keys string, opts ...nats.WatchOpt) (nats.KeyWatcher, error)

Watch mocks base method.

func (*MockKeyValue) WatchAll

func (m *MockKeyValue) WatchAll(opts ...nats.WatchOpt) (nats.KeyWatcher, error)

WatchAll mocks base method.

func (*MockKeyValue) WatchFiltered

func (m *MockKeyValue) WatchFiltered(keys []string, opts ...nats.WatchOpt) (nats.KeyWatcher, error)

WatchFiltered mocks base method.

type MockKeyValueEntry

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

MockKeyValueEntry for testing.

func (*MockKeyValueEntry) Bucket

func (*MockKeyValueEntry) Bucket() string

func (*MockKeyValueEntry) Created

func (*MockKeyValueEntry) Created() time.Time

func (*MockKeyValueEntry) Delta

func (*MockKeyValueEntry) Delta() uint64

func (*MockKeyValueEntry) Key

func (*MockKeyValueEntry) Key() string

func (*MockKeyValueEntry) Operation

func (*MockKeyValueEntry) Operation() nats.KeyValueOp

func (*MockKeyValueEntry) Revision

func (*MockKeyValueEntry) Revision() uint64

func (*MockKeyValueEntry) Value

func (m *MockKeyValueEntry) Value() []byte

type MockKeyValueMockRecorder

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

MockKeyValueMockRecorder is the mock recorder for MockKeyValue.

func (*MockKeyValueMockRecorder) Bucket

func (mr *MockKeyValueMockRecorder) Bucket() *gomock.Call

Bucket indicates an expected call of Bucket.

func (*MockKeyValueMockRecorder) Create

func (mr *MockKeyValueMockRecorder) Create(key, value any) *gomock.Call

Create indicates an expected call of Create.

func (*MockKeyValueMockRecorder) Delete

func (mr *MockKeyValueMockRecorder) Delete(key any, opts ...any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockKeyValueMockRecorder) Get

func (mr *MockKeyValueMockRecorder) Get(key any) *gomock.Call

Get indicates an expected call of Get.

func (*MockKeyValueMockRecorder) GetRevision

func (mr *MockKeyValueMockRecorder) GetRevision(key, revision any) *gomock.Call

GetRevision indicates an expected call of GetRevision.

func (*MockKeyValueMockRecorder) History

func (mr *MockKeyValueMockRecorder) History(key any, opts ...any) *gomock.Call

History indicates an expected call of History.

func (*MockKeyValueMockRecorder) Keys

func (mr *MockKeyValueMockRecorder) Keys(opts ...any) *gomock.Call

Keys indicates an expected call of Keys.

func (*MockKeyValueMockRecorder) ListKeys

func (mr *MockKeyValueMockRecorder) ListKeys(opts ...any) *gomock.Call

ListKeys indicates an expected call of ListKeys.

func (*MockKeyValueMockRecorder) Purge

func (mr *MockKeyValueMockRecorder) Purge(key any, opts ...any) *gomock.Call

Purge indicates an expected call of Purge.

func (*MockKeyValueMockRecorder) PurgeDeletes

func (mr *MockKeyValueMockRecorder) PurgeDeletes(opts ...any) *gomock.Call

PurgeDeletes indicates an expected call of PurgeDeletes.

func (*MockKeyValueMockRecorder) Put

func (mr *MockKeyValueMockRecorder) Put(key, value any) *gomock.Call

Put indicates an expected call of Put.

func (*MockKeyValueMockRecorder) PutString

func (mr *MockKeyValueMockRecorder) PutString(key, value any) *gomock.Call

PutString indicates an expected call of PutString.

func (*MockKeyValueMockRecorder) Status

func (mr *MockKeyValueMockRecorder) Status() *gomock.Call

Status indicates an expected call of Status.

func (*MockKeyValueMockRecorder) Update

func (mr *MockKeyValueMockRecorder) Update(key, value, last any) *gomock.Call

Update indicates an expected call of Update.

func (*MockKeyValueMockRecorder) Watch

func (mr *MockKeyValueMockRecorder) Watch(keys any, opts ...any) *gomock.Call

Watch indicates an expected call of Watch.

func (*MockKeyValueMockRecorder) WatchAll

func (mr *MockKeyValueMockRecorder) WatchAll(opts ...any) *gomock.Call

WatchAll indicates an expected call of WatchAll.

func (*MockKeyValueMockRecorder) WatchFiltered

func (mr *MockKeyValueMockRecorder) WatchFiltered(keys any, opts ...any) *gomock.Call

WatchFiltered indicates an expected call of WatchFiltered.

type MockLogger

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

MockLogger is a mock of Logger interface.

func NewMockLogger

func NewMockLogger(ctrl *gomock.Controller) *MockLogger

NewMockLogger creates a new mock instance.

func (*MockLogger) Debug

func (m *MockLogger) Debug(args ...any)

Debug mocks base method.

func (*MockLogger) Debugf

func (m *MockLogger) Debugf(pattern string, args ...any)

Debugf mocks base method.

func (*MockLogger) EXPECT

func (m *MockLogger) EXPECT() *MockLoggerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLogger) Error

func (m *MockLogger) Error(args ...any)

Error mocks base method.

func (*MockLogger) Errorf

func (m *MockLogger) Errorf(pattern string, args ...any)

Errorf mocks base method.

func (*MockLogger) Info

func (m *MockLogger) Info(args ...any)

Info mocks base method.

func (*MockLogger) Infof

func (m *MockLogger) Infof(pattern string, args ...any)

Infof mocks base method.

type MockLoggerMockRecorder

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

MockLoggerMockRecorder is the mock recorder for MockLogger.

func (*MockLoggerMockRecorder) Debug

func (mr *MockLoggerMockRecorder) Debug(args ...any) *gomock.Call

Debug indicates an expected call of Debug.

func (*MockLoggerMockRecorder) Debugf

func (mr *MockLoggerMockRecorder) Debugf(pattern any, args ...any) *gomock.Call

Debugf indicates an expected call of Debugf.

func (*MockLoggerMockRecorder) Error

func (mr *MockLoggerMockRecorder) Error(args ...any) *gomock.Call

Error indicates an expected call of Error.

func (*MockLoggerMockRecorder) Errorf

func (mr *MockLoggerMockRecorder) Errorf(pattern any, args ...any) *gomock.Call

Errorf indicates an expected call of Errorf.

func (*MockLoggerMockRecorder) Info

func (mr *MockLoggerMockRecorder) Info(args ...any) *gomock.Call

Info indicates an expected call of Info.

func (*MockLoggerMockRecorder) Infof

func (mr *MockLoggerMockRecorder) Infof(pattern any, args ...any) *gomock.Call

Infof indicates an expected call of Infof.

type MockMetrics

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

MockMetrics is a mock of Metrics interface.

func NewMockMetrics

func NewMockMetrics(ctrl *gomock.Controller) *MockMetrics

NewMockMetrics creates a new mock instance.

func (*MockMetrics) EXPECT

func (m *MockMetrics) EXPECT() *MockMetricsMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMetrics) NewHistogram

func (m *MockMetrics) NewHistogram(name, desc string, buckets ...float64)

NewHistogram mocks base method.

func (*MockMetrics) RecordHistogram

func (m *MockMetrics) RecordHistogram(ctx context.Context, name string, value float64, labels ...string)

RecordHistogram mocks base method.

type MockMetricsMockRecorder

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

MockMetricsMockRecorder is the mock recorder for MockMetrics.

func (*MockMetricsMockRecorder) NewHistogram

func (mr *MockMetricsMockRecorder) NewHistogram(name, desc any, buckets ...any) *gomock.Call

NewHistogram indicates an expected call of NewHistogram.

func (*MockMetricsMockRecorder) RecordHistogram

func (mr *MockMetricsMockRecorder) RecordHistogram(ctx, name, value any, labels ...any) *gomock.Call

RecordHistogram indicates an expected call of RecordHistogram.

Jump to

Keyboard shortcuts

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