hotpairs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	LaneNormal = "normal"
	LaneHot    = "hot"
)
View Source
const (
	QueueLaneMetaKey = "queue_lane"
	QueuePairMetaKey = "queue_pair_key"
)

Variables

This section is empty.

Functions

func AssignQueueLane

func AssignQueueLane(ctx context.Context, manager *Manager, counter PairLaneCounter, txn *model.Transaction) error

func IsLockContentionError

func IsLockContentionError(err error) bool

func PairKeyForTransaction

func PairKeyForTransaction(manager *Manager, txn *model.Transaction) string

func QueueLaneFromMetadata

func QueueLaneFromMetadata(meta map[string]interface{}) string

func RecordContention

func RecordContention(ctx context.Context, manager *Manager, source, destination, currency string, err error)

func ResolveQueueLane

func ResolveQueueLane(ctx context.Context, manager *Manager, counter PairLaneCounter, source, destination, currency string) (string, error)

Types

type Config

type Config struct {
	Enabled                 bool
	HotQueueName            string
	HotPairTTL              time.Duration
	LockContentionThreshold int
}

type Manager

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

func NewManager

func NewManager(client redis.UniversalClient, cfg Config) *Manager

func (*Manager) ActivateHot

func (m *Manager) ActivateHot(ctx context.Context, pairKey string) error

func (*Manager) Enabled

func (m *Manager) Enabled() bool

func (*Manager) GetState

func (m *Manager) GetState(ctx context.Context, pairKey string) (State, error)

func (*Manager) HasRecentContention

func (m *Manager) HasRecentContention(ctx context.Context, pairKey string) (bool, error)

func (*Manager) HotQueueName

func (m *Manager) HotQueueName() string

func (*Manager) PairKey

func (m *Manager) PairKey(source, destination, currency string) string

func (*Manager) RecordContention

func (m *Manager) RecordContention(ctx context.Context, pairKey string) (int64, bool, error)

func (*Manager) SetNormal

func (m *Manager) SetNormal(ctx context.Context, pairKey string) error

func (*Manager) StartCoolingDown

func (m *Manager) StartCoolingDown(ctx context.Context, pairKey string) error

type PairLaneCounter

type PairLaneCounter interface {
	CountQueuedTransactionsForPairLane(ctx context.Context, source, destination, currency, lane string) (int, error)
}

type State

type State string
const (
	StateNormal      State = "normal"
	StatePromoting   State = "promoting"
	StateHot         State = "hot"
	StateCoolingDown State = "cooling_down"
)

Jump to

Keyboard shortcuts

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