cluster

package
v3.22.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxGetConnTimeout = 10 * time.Second
)

Variables

View Source
var (
	// ErrClusterClosed returned when requested on a closed cluster.
	ErrClusterClosed = xerrors.Wrap(fmt.Errorf("cluster closed"))

	// ErrClusterEmpty returned when no connections left in cluster.
	ErrClusterEmpty = xerrors.Wrap(fmt.Errorf("cluster empty"))
)

Functions

func DiffEndpoints

func DiffEndpoints(curr, next []endpoint.Endpoint, eq, add, del func(i, j int))

func SortEndpoints

func SortEndpoints(es []endpoint.Endpoint)

func WithEndpoint added in v3.7.0

func WithEndpoint(ctx context.Context, endpoint Endpoint) context.Context

Types

type Cluster

type Cluster struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(
	ctx context.Context,
	config config.Config,
	pool conn.Pool,
) *Cluster

func (*Cluster) Close

func (c *Cluster) Close(ctx context.Context) (err error)

func (*Cluster) Force

func (c *Cluster) Force()

Force reexpore cluster

func (*Cluster) Get

func (c *Cluster) Get(ctx context.Context) (cc conn.Conn, err error)

Get returns next available connection. It returns error on given deadline cancellation or when cluster become closed.

func (*Cluster) Insert

func (c *Cluster) Insert(ctx context.Context, e endpoint.Endpoint, opts ...CrudOption)

Insert inserts new connection into the cluster.

func (*Cluster) Pessimize

func (c *Cluster) Pessimize(ctx context.Context, cc conn.Conn, cause error)

Pessimize connection in underling pool

func (*Cluster) Remove

func (c *Cluster) Remove(ctx context.Context, e endpoint.Endpoint, opts ...CrudOption)

Remove removes and closes previously inserted connection.

func (*Cluster) SetExplorer

func (c *Cluster) SetExplorer(repeater repeater.Repeater)

type CrudOption added in v3.21.0

type CrudOption func(h *crudOptionsHolder)

func WithoutLock added in v3.11.4

func WithoutLock() CrudOption

type Endpoint added in v3.7.0

type Endpoint interface {
	NodeID() uint32
}

func ContextEndpoint added in v3.7.0

func ContextEndpoint(ctx context.Context) (e Endpoint, ok bool)

type Explorer added in v3.10.0

type Explorer interface {
	SetExplorer(repeater repeater.Repeater)
	Force()
}

type Getter added in v3.16.10

type Getter interface {
	// Get returns next available connection.
	// It returns error on given deadline cancellation or when cluster become closed.
	Get(ctx context.Context) (cc conn.Conn, err error)
}

type Inserter added in v3.16.10

type Inserter interface {
	// Insert inserts endpoint to cluster
	Insert(ctx context.Context, endpoint endpoint.Endpoint, opts ...CrudOption)
}

type Remover added in v3.16.10

type Remover interface {
	// Remove removes endpoint from cluster
	Remove(ctx context.Context, endpoint endpoint.Endpoint, opts ...CrudOption)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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