tree

package
v0.0.0-...-51cefd4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 2

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 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.

type RemoveNodeParams

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

RemoveNodeParams groups parameters of Pool.RemoveNode operation.

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

Read reads another list of the subtree nodes.

func (*SubTreeReader) ReadAll

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