radix: github.com/mediocregopher/radix/trace Index | Files

package trace

import "github.com/mediocregopher/radix/trace"

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

Package Files

cluster.go pool.go

type ClusterNodeInfo Uses

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

type ClusterRedirected Uses

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 Uses

type ClusterStateChange struct {
    IsDown bool
}

type ClusterTopoChanged Uses

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

type ClusterTrace Uses

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 Uses

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 Uses

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 Uses

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.PoolOnFull options.
    PoolConnClosedReasonPoolFull PoolConnClosedReason = "pool full"
)

All possible values of PoolConnClosedReason.

type PoolConnCreated Uses

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 Uses

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 Uses

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 Uses

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 Uses

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.

Package trace imports 1 packages (graph). Updated 2019-07-18. Refresh now. Tools for package owners.