conn

package
v3.66.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown = State(iota)
	Created
	Online
	Banned
	Offline
	Destroyed
)

Variables

This section is empty.

Functions

func UseWrapping added in v3.42.5

func UseWrapping(ctx context.Context) bool

func WithAppendOptions added in v3.40.0

func WithAppendOptions(cc grpc.ClientConnInterface, appendOpts ...grpc.CallOption) grpc.ClientConnInterface

func WithBeforeFunc added in v3.42.0

func WithBeforeFunc(
	cc grpc.ClientConnInterface,
	before func(),
) grpc.ClientConnInterface

func WithContextModifier added in v3.40.0

func WithContextModifier(
	cc grpc.ClientConnInterface,
	modifyCtx func(ctx context.Context) context.Context,
) grpc.ClientConnInterface

func WithoutWrapping added in v3.11.8

func WithoutWrapping(ctx context.Context) context.Context

Types

type Config

type Config interface {
	DialTimeout() time.Duration
	ConnectionTTL() time.Duration
	Trace() *trace.Driver
	GrpcDialOptions() []grpc.DialOption
}

type Conn

type Conn interface {
	grpc.ClientConnInterface

	Endpoint() endpoint.Endpoint

	LastUsage() time.Time

	Ping(ctx context.Context) error
	IsState(states ...State) bool
	GetState() State
	SetState(ctx context.Context, state State) State
	Unban(ctx context.Context) State
}

func New

func New(e endpoint.Endpoint, config Config, opts ...option) Conn

type Pool added in v3.7.0

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

func NewPool added in v3.7.0

func NewPool(ctx context.Context, config Config) *Pool

func (*Pool) Allow added in v3.25.1

func (p *Pool) Allow(ctx context.Context, cc Conn)

func (*Pool) Ban added in v3.25.1

func (p *Pool) Ban(ctx context.Context, cc Conn, cause error)

func (*Pool) Get added in v3.7.0

func (p *Pool) Get(endpoint endpoint.Endpoint) Conn

func (*Pool) Release added in v3.25.1

func (p *Pool) Release(ctx context.Context) (finalErr error)

func (*Pool) Take added in v3.25.1

func (p *Pool) Take(context.Context) error

type State added in v3.7.0

type State int8

func (State) Code added in v3.7.0

func (s State) Code() int

func (State) IsValid added in v3.7.0

func (s State) IsValid() bool

func (State) String added in v3.7.0

func (s State) String() string

Jump to

Keyboard shortcuts

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