jetstream

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LockValidity   = 60 * time.Second
	LockRetryDelay = 100 * time.Millisecond
)

Functions

func AcquireJetstreamConn

func AcquireJetstreamConn(ctx context.Context, conf *v1alpha1.JetstreamClientSpec, lg *slog.Logger) (nats.JetStreamContext, error)

Types

type Lock

type Lock struct {
	*lock.LockOptions
	// contains filtered or unexported fields
}

func NewLock

func NewLock(js nats.JetStreamContext, prefix, key string, lg *slog.Logger, options *lock.LockOptions) *Lock

func (*Lock) Key

func (l *Lock) Key() string

func (*Lock) Lock

func (l *Lock) Lock(ctx context.Context) (<-chan struct{}, error)

func (*Lock) TryLock

func (l *Lock) TryLock(ctx context.Context) (acquired bool, done <-chan struct{}, err error)

func (*Lock) Unlock

func (l *Lock) Unlock() error

type LockManager

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

Requires jetstream 2.9+

func NewLockManager

func NewLockManager(
	ctx context.Context,
	js nats.JetStreamContext,
	prefix string,
	tracer trace.Tracer,
	lg *slog.Logger,
) *LockManager

func (*LockManager) Health

func (l *LockManager) Health(ctx context.Context) (conditions []string, err error)

func (*LockManager) NewLock

func (l *LockManager) NewLock(key string, opts ...lock.LockOption) lock.Lock

Jump to

Keyboard shortcuts

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