tree

package
v0.0.0-...-0352b5b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNodeNotFound is returned from Tree service in case of not found error.
	ErrNodeNotFound = errors.New("not found")

	// ErrNodeAccessDenied is returned from Tree service in case of access denied error.
	ErrNodeAccessDenied = errors.New("access denied")
)
View Source
var ErrUnhealthyEndpoint = errors.New("unhealthy endpoint")

ErrUnhealthyEndpoint is returned when client in the pool considered unavailable.

Functions

func GetRequestID

func GetRequestID(ctx context.Context) string

GetRequestID fetch tree pool request identifier from context.

func SetRequestID

func SetRequestID(ctx context.Context, reqID string) context.Context

SetRequestID sets request identifier to context so when some operations are logged in tree pool this identifier also be logged.

Types

type AddNodeByPathParams

type AddNodeByPathParams struct {
	CID           cid.ID
	TreeID        string
	Path          []string
	Meta          map[string]string
	PathAttribute string
	BearerToken   []byte
}

AddNodeByPathParams groups parameters of Pool.AddNodeByPath operation.

type AddNodeParams

type AddNodeParams struct {
	CID         cid.ID
	TreeID      string
	Parent      uint64
	Meta        map[string]string
	BearerToken []byte
}

AddNodeParams groups parameters of Pool.AddNode operation.

type GetNodesParams

type GetNodesParams struct {
	CID           cid.ID
	TreeID        string
	Path          []string
	Meta          []string
	PathAttribute string
	LatestOnly    bool
	AllAttrs      bool
	BearerToken   []byte
}

GetNodesParams groups parameters of Pool.GetNodes operation.

type GetSubTreeParams

type GetSubTreeParams struct {
	CID         cid.ID
	TreeID      string
	RootID      []uint64
	Depth       uint32
	BearerToken []byte
	Order       SubTreeSort
}

GetSubTreeParams groups parameters of Pool.GetSubTree operation.

type InitParameters

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

InitParameters contains values used to initialize connection Pool.

func (*InitParameters) AddNode

func (x *InitParameters) AddNode(nodeParam pool.NodeParam)

AddNode append information about the node to which you want to connect.

func (*InitParameters) SetClientRebalanceInterval

func (x *InitParameters) SetClientRebalanceInterval(interval time.Duration)

SetClientRebalanceInterval specifies the interval for updating nodes health status.

See also Pool.Dial.

func (*InitParameters) SetGRPCDialOptions

func (x *InitParameters) SetGRPCDialOptions(opts ...grpc.DialOption)

SetGRPCDialOptions sets the gRPC dial options for new gRPC tree client connection.

func (*InitParameters) SetHealthcheckTimeout

func (x *InitParameters) SetHealthcheckTimeout(timeout time.Duration)

SetHealthcheckTimeout specifies the timeout for request to node to decide if it is alive.

See also Pool.Dial.

func (*InitParameters) SetKey

func (x *InitParameters) SetKey(key *keys.PrivateKey)

SetKey specifies default key to be used for the protocol communication by default.

func (*InitParameters) SetLogger

func (x *InitParameters) SetLogger(logger *zap.Logger)

SetLogger specifies logger.

func (*InitParameters) SetMaxRequestAttempts

func (x *InitParameters) SetMaxRequestAttempts(maxAttempts int)

SetMaxRequestAttempts sets the max attempt to make successful request. Default value is 0 that means the number of attempts equals to number of nodes in pool.

func (*InitParameters) SetNodeDialTimeout

func (x *InitParameters) SetNodeDialTimeout(timeout time.Duration)

SetNodeDialTimeout specifies the timeout for connection to be established.

func (*InitParameters) SetNodeStreamTimeout

func (x *InitParameters) SetNodeStreamTimeout(timeout time.Duration)

SetNodeStreamTimeout specifies the timeout for individual operations in streaming RPC.

type MethodIndex

type MethodIndex int

MethodIndex index of method in list of statuses in Pool.

func (MethodIndex) String

func (m MethodIndex) String() string

String implements fmt.Stringer.

type MoveNodeParams

type MoveNodeParams struct {
	CID         cid.ID
	TreeID      string
	NodeID      uint64
	ParentID    uint64
	Meta        map[string]string
	BearerToken []byte
}

MoveNodeParams groups parameters of Pool.MoveNode operation.

type Pool

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

Pool represents virtual connection to the FrostFS tree services network to communicate with multiple FrostFS tree services without thinking about switching between servers due to their unavailability.

Pool can be created and initialized using NewPool function. Before executing the FrostFS tree operations using the Pool, connection to the servers MUST BE correctly established (see Dial method).

func NewPool

func NewPool(options InitParameters) (*Pool, error)

NewPool creates connection pool using parameters.

func (*Pool) AddNode

func (p *Pool) AddNode(ctx context.Context, prm AddNodeParams) (uint64, error)

AddNode invokes eponymous method from TreeServiceClient.

Can return predefined errors: * ErrNodeNotFound * ErrNodeAccessDenied.

func (*Pool) AddNodeByPath

func (p *Pool) AddNodeByPath(ctx context.Context, prm AddNodeByPathParams) (uint64, error)

AddNodeByPath invokes eponymous method from TreeServiceClient.

Can return predefined errors: * ErrNodeNotFound * ErrNodeAccessDenied.

func (*Pool) Close

func (p *Pool) Close() error

Close closes the Pool and releases all the associated resources.

func (*Pool) Dial

func (p *Pool) Dial(ctx context.Context) error

Dial establishes a connection to the tree servers from the FrostFS network. It also starts a routine that checks the health of the nodes and updates the weights of the nodes for balancing. Returns an error describing failure reason.

If failed, the Pool SHOULD NOT be used.

See also InitParameters.SetClientRebalanceInterval.

func (*Pool) GetNodes

GetNodes invokes eponymous method from TreeServiceClient.

Can return predefined errors: * ErrNodeNotFound * ErrNodeAccessDenied.

func (*Pool) GetSubTree

func (p *Pool) GetSubTree(ctx context.Context, prm GetSubTreeParams) (*SubTreeReader, error)

GetSubTree invokes eponymous method from TreeServiceClient.

Can return predefined errors: * ErrNodeNotFound * ErrNodeAccessDenied.

func (*Pool) MoveNode

func (p *Pool) MoveNode(ctx context.Context, prm MoveNodeParams) error

MoveNode invokes eponymous method from TreeServiceClient.

Can return predefined errors: * ErrNodeNotFound * ErrNodeAccessDenied.

func (*Pool) RemoveNode

func (p *Pool) RemoveNode(ctx context.Context, prm RemoveNodeParams) error

RemoveNode invokes eponymous method from TreeServiceClient.

Can return predefined errors: * ErrNodeNotFound * ErrNodeAccessDenied.

func (*Pool) Statistic

func (p *Pool) Statistic() Statistic

Statistic returns tree pool statistics.

type RemoveNodeParams

type RemoveNodeParams struct {
	CID         cid.ID
	TreeID      string
	NodeID      uint64
	BearerToken []byte
}

RemoveNodeParams groups parameters of Pool.RemoveNode operation.

type Statistic

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

Statistic is metrics of the tree pool.

func (*Statistic) AverageAddNode

func (s *Statistic) AverageAddNode() time.Duration

func (*Statistic) AverageAddNodeByPath

func (s *Statistic) AverageAddNodeByPath() time.Duration

func (*Statistic) AverageGetNodes

func (s *Statistic) AverageGetNodes() time.Duration

func (*Statistic) AverageGetSubTree

func (s *Statistic) AverageGetSubTree() time.Duration

func (*Statistic) AverageMoveNode

func (s *Statistic) AverageMoveNode() time.Duration

func (*Statistic) AverageRemoveNode

func (s *Statistic) AverageRemoveNode() time.Duration

func (*Statistic) Requests

func (s *Statistic) Requests() (requests uint64)

type SubTreeReader

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

SubTreeReader is designed to read list of subtree nodes FrostFS tree service.

Must be initialized using Pool.GetSubTree, any other usage is unsafe.

func (*SubTreeReader) Next

Next gets the next node from subtree.

func (*SubTreeReader) Read

func (x *SubTreeReader) Read(buf []*tree.GetSubTreeResponseBody) (int, error)

Read reads another list of the subtree nodes.

func (*SubTreeReader) ReadAll

func (x *SubTreeReader) ReadAll() ([]*tree.GetSubTreeResponseBody, error)

ReadAll reads all nodes subtree nodes.

type SubTreeSort

type SubTreeSort int32

SubTreeSort defines an order of nodes returned from GetSubTree RPC.

const (
	// NoneOrder does not specify order of nodes returned in GetSubTree RPC.
	NoneOrder SubTreeSort = iota
	// AscendingOrder specifies ascending alphabetical order of nodes based on FilePath attribute.
	AscendingOrder
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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