trace

package
v3.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package trace contains all the types provided for tracing within the radix package. With tracing a user is able to pull out fine-grained runtime events as they happen, which is useful for gathering metrics, logging, performance analysis, etc...

BIG LOUD DISCLAIMER DO NOT IGNORE THIS: while the main radix package is stable and will always remain backwards compatible, trace is still under active development and may undergo changes to its types and other features. The methods in the main radix package which invoke trace types are guaranteed to remain stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterNodeInfo

type ClusterNodeInfo struct {
	Addr      string
	Slots     [][2]uint16
	IsPrimary bool
}

type ClusterRedirected

type ClusterRedirected struct {
	Addr          string
	Key           string
	Moved, Ask    bool
	RedirectCount int

	// If true, then the MOVED/ASK error which was received will not be honored,
	// and the call to Do will be returning the MOVED/ASK error.
	Final bool
}

type ClusterStateChange added in v3.3.1

type ClusterStateChange struct {
	IsDown bool
}

type ClusterTopoChanged

type ClusterTopoChanged struct {
	Added   []ClusterNodeInfo
	Removed []ClusterNodeInfo
	Changed []ClusterNodeInfo
}

type ClusterTrace

type ClusterTrace struct {
	// StateChange is called when the cluster becomes down or becomes available again.
	StateChange func(ClusterStateChange)
	// TopoChanged is called when the cluster's topology changed.
	TopoChanged func(ClusterTopoChanged)
	// Redirected is called when radix.Do responded 'MOVED' or 'ASKED'.
	Redirected func(ClusterRedirected)
}

type PoolCommon

type PoolCommon struct {
	// Network and Addr indicate the network/address the Pool was created with
	// (useful for differentiating different redis instances in a Cluster).
	Network, Addr string

	// PoolSize and BufferSize indicate the Pool size and buffer size that the
	// Pool was initialized with.
	PoolSize, BufferSize int
}

PoolCommon contains information which is passed into all Pool-related callbacks.

type PoolConnClosed

type PoolConnClosed struct {
	PoolCommon

	// AvailCount indicates the total number of connections the Pool is holding
	// on to which are available for usage at the moment the trace occurs.
	AvailCount int

	// The reason the connection was closed.
	Reason PoolConnClosedReason
}

PoolConnClosed is passed into the PoolTrace.ConnClosed callback whenever the Pool closes a connection.

type PoolConnClosedReason

type PoolConnClosedReason string

PoolConnClosedReason enumerates all the different reasons a connection might be closed and trigger a ConnClosed trace.

const (
	// PoolConnClosedReasonPoolClosed indicates a connection was closed because
	// the Close method was called on Pool.
	PoolConnClosedReasonPoolClosed PoolConnClosedReason = "pool closed"

	// PoolConnClosedReasonBufferDrain indicates a connection was closed due to
	// a buffer drain event. See radix.PoolOnFullBuffer.
	PoolConnClosedReasonBufferDrain PoolConnClosedReason = "buffer drained"

	// PoolConnClosedReasonPoolFull indicates a connection was closed due to
	// the Pool already being full. See The radix.PoolOnFullClose options.
	PoolConnClosedReasonPoolFull PoolConnClosedReason = "pool full"

	// PoolConnClosedReasonConnExpired indicates a connection was closed because
	// the connection was expired. See The radix.PoolMaxLifetime options.
	PoolConnClosedReasonConnExpired PoolConnClosedReason = "conn expired"
)

All possible values of PoolConnClosedReason.

type PoolConnCreated

type PoolConnCreated struct {
	PoolCommon

	// The reason the connection was created.
	Reason PoolConnCreatedReason

	// How long it took to create the connection.
	ConnectTime time.Duration

	// If connection creation failed, this is the error it failed with.
	Err error
}

PoolConnCreated is passed into the PoolTrace.ConnCreated callback whenever the Pool creates a new connection.

type PoolConnCreatedReason

type PoolConnCreatedReason string

PoolConnCreatedReason enumerates all the different reasons a connection might be created and trigger a ConnCreated trace.

const (
	// PoolConnCreatedReasonInitialization indicates a connection was being
	// created during initialization of the Pool (i.e. within NewPool).
	PoolConnCreatedReasonInitialization PoolConnCreatedReason = "initialization"

	// PoolConnCreatedReasonRefill indicates a connection was being created
	// during a refill event (see radix.PoolRefillInterval).
	PoolConnCreatedReasonRefill PoolConnCreatedReason = "refill"

	// PoolConnCreatedReasonPoolEmpty indicates a connection was being created
	// because the Pool was empty and an Action requires one. See the
	// radix.PoolOnEmpty options.
	PoolConnCreatedReasonPoolEmpty PoolConnCreatedReason = "pool empty"
)

All possible values of PoolConnCreatedReason.

type PoolDoCompleted

type PoolDoCompleted struct {
	PoolCommon

	// AvailCount indicates the total number of connections the Pool is holding
	// on to which are available for usage at the moment the trace occurs.
	AvailCount int

	// How long it took to send command.
	ElapsedTime time.Duration

	// This is the error returned from redis.
	Err error
}

PoolDoCompleted is passed into the PoolTrace.DoCompleted callback whenever Pool finished to run Do function.

type PoolInitCompleted

type PoolInitCompleted struct {
	PoolCommon

	// AvailCount indicates the total number of connections the Pool is holding
	// on to which are available for usage at the moment the trace occurs.
	AvailCount int

	// How long it took to fill all connections.
	ElapsedTime time.Duration
}

PoolInitCompleted is passed into the PoolTrace.InitCompleted callback whenever Pool initialized. This must be called once.

type PoolTrace

type PoolTrace struct {
	// ConnCreated is called when the Pool creates a new connection. The
	// provided Err indicates whether the connection successfully completed.
	ConnCreated func(PoolConnCreated)

	// ConnClosed is called before closing the connection.
	ConnClosed func(PoolConnClosed)

	// DoCompleted is called after command execution. Must consider race condition
	// for manipulating variables in DoCompleted callback since DoComplete
	// function can be called in many go-routines.
	DoCompleted func(PoolDoCompleted)

	// InitCompleted is called after pool fills its connections
	InitCompleted func(PoolInitCompleted)
}

PoolTrace is passed into radix.NewPool via radix.PoolWithTrace, and contains callbacks which will be triggered for specific events during the Pool's runtime.

All callbacks are called synchronously.

Jump to

Keyboard shortcuts

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