syncmap

package
v0.0.0-...-7838e69 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parameter

type Parameter interface {
	// contains filtered or unexported methods
}

Parameter is the interface for service parameters.

func WithLogLevel

func WithLogLevel(logLevel zerolog.Level) Parameter

WithLogLevel sets the log level for the module.

func WithMonitor

func WithMonitor(monitor metrics.LockerMonitor) Parameter

WithMonitor sets the monitor for this module.

type Service

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

Service provides a global account locker using sync.Map

func New

func New(ctx context.Context, params ...Parameter) (*Service, error)

New creates a new in-memory fetcher.

func (*Service) Lock

func (s *Service) Lock(key [48]byte)

Lock acquires a lock for a given public key. If more than one lock is being acquired in a batch, ensure that PreLock() is called beforehand and PostLock() afterwards.

func (*Service) PostLock

func (s *Service) PostLock()

PostLock must be called after locking one or more public keys. It frees the locker-wide mutex obtained by PreLock().

func (*Service) PreLock

func (s *Service) PreLock()

PreLock must be called prior to locking one or more public keys. It obtains a locker-wide mutex, to ensure that only one goroutine can be locking or unlocking groups of public keys at a time.

func (*Service) Unlock

func (s *Service) Unlock(key [48]byte)

Unlock frees a lock for a given public key.

Jump to

Keyboard shortcuts

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