pool

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 30 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEphemeralKey

func NewEphemeralKey() (*ecdsa.PrivateKey, error)

NewEphemeralKey creates new private key used for NeoFS session. It'll be removed after refactoring to use neo-go crypto library.

Types

type Accounting

type Accounting interface {
	Balance(ctx context.Context, owner *owner.ID, opts ...CallOption) (*accounting.Decimal, error)
}

type Builder

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

Builder is an interim structure used to collect node addresses/weights and build connection pool subsequently.

func (*Builder) AddNode

func (pb *Builder) AddNode(address string, priority int, weight float64) *Builder

AddNode adds address/weight pair to node PoolBuilder list.

func (*Builder) Build

func (pb *Builder) Build(ctx context.Context, options *BuilderOptions) (Pool, error)

Build creates new pool based on current PoolBuilder state and options.

type BuilderOptions

type BuilderOptions struct {
	Key                       *ecdsa.PrivateKey
	Logger                    *zap.Logger
	NodeConnectionTimeout     time.Duration
	NodeRequestTimeout        time.Duration
	ClientRebalanceInterval   time.Duration
	SessionTokenThreshold     time.Duration
	SessionExpirationDuration uint64
	// contains filtered or unexported fields
}

BuilderOptions contains options used to build connection pool.

type CallOption

type CallOption func(config *callConfig)

func WithBearer

func WithBearer(token *token.BearerToken) CallOption

func WithKey

func WithKey(key *ecdsa.PrivateKey) CallOption

func WithSession

func WithSession(token *session.Token) CallOption

type Client

Client is a wrapper for client.Client to generate mock.

type Container

type Container interface {
	PutContainer(ctx context.Context, cnr *container.Container, opts ...CallOption) (*cid.ID, error)
	GetContainer(ctx context.Context, cid *cid.ID, opts ...CallOption) (*container.Container, error)
	ListContainers(ctx context.Context, ownerID *owner.ID, opts ...CallOption) ([]*cid.ID, error)
	DeleteContainer(ctx context.Context, cid *cid.ID, opts ...CallOption) error
	GetEACL(ctx context.Context, cid *cid.ID, opts ...CallOption) (*eacl.Table, error)
	SetEACL(ctx context.Context, table *eacl.Table, opts ...CallOption) error
}

type ContainerPollingParams

type ContainerPollingParams struct {
	CreationTimeout time.Duration
	PollInterval    time.Duration
}

ContainerPollingParams contains parameters used in polling is a container created or not.

func DefaultPollingParams

func DefaultPollingParams() *ContainerPollingParams

DefaultPollingParams creates ContainerPollingParams with default values.

type NodeParam

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

type NodesParam

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

type Object

type Object interface {
	PutObject(ctx context.Context, hdr object.Object, payload io.Reader, opts ...CallOption) (*oid.ID, error)
	DeleteObject(ctx context.Context, addr address.Address, opts ...CallOption) error
	GetObject(context.Context, address.Address, ...CallOption) (*ResGetObject, error)
	HeadObject(context.Context, address.Address, ...CallOption) (*object.Object, error)
	ObjectRange(ctx context.Context, addr address.Address, off, ln uint64, opts ...CallOption) (*ResObjectRange, error)
	SearchObjects(context.Context, cid.ID, object.SearchFilters, ...CallOption) (*ResObjectSearch, error)
}

type Pool

type Pool interface {
	Object
	Container
	Accounting
	Connection() (Client, *session.Token, error)
	OwnerID() *owner.ID
	WaitForContainerPresence(context.Context, *cid.ID, *ContainerPollingParams) error
	Close()
}

Pool is an interface providing connection artifacts on request.

type ResGetObject

type ResGetObject struct {
	Header object.Object

	Payload io.ReadCloser
}

type ResObjectRange

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

func (*ResObjectRange) Close

func (x *ResObjectRange) Close() error

func (*ResObjectRange) Read

func (x *ResObjectRange) Read(p []byte) (int, error)

type ResObjectSearch

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

func (*ResObjectSearch) Close

func (x *ResObjectSearch) Close()

func (*ResObjectSearch) Iterate

func (x *ResObjectSearch) Iterate(f func(oid.ID) bool) error

func (*ResObjectSearch) Read

func (x *ResObjectSearch) Read(buf []oid.ID) (int, error)

type Sampler

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

Sampler implements weighted random number generation using Vose's Alias Method (https://www.keithschwarz.com/darts-dice-coins/).

func NewSampler

func NewSampler(probabilities []float64, source rand.Source) *Sampler

NewSampler creates new Sampler with a given set of probabilities using given source of randomness. Created Sampler will produce numbers from 0 to len(probabilities).

func (*Sampler) Next

func (g *Sampler) Next() int

Next returns the next (not so) random number from Sampler.

type SessionCache

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

func NewCache

func NewCache() (*SessionCache, error)

func (*SessionCache) DeleteByPrefix

func (c *SessionCache) DeleteByPrefix(prefix string)

func (*SessionCache) Get

func (c *SessionCache) Get(key string) *session.Token

func (*SessionCache) GetAccessTime

func (c *SessionCache) GetAccessTime(key string) (time.Time, bool)

func (*SessionCache) Put

func (c *SessionCache) Put(key string, token *session.Token) bool

Jump to

Keyboard shortcuts

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