getsvc

package
v0.58.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAborted = errors.New("aborted")

ErrAborted is returned to abort something.

View Source
var ErrLinker = errors.New("linker")

ErrLinker is returned when object of LINK type is received.

View Source
var ErrResponded = errors.New("responded")

ErrResponded is returned when server successfully finished processing of some request.

View Source
var ErrResponseStreamFailure = errors.New("stream failure")

ErrResponseStreamFailure is returned when response stream no longer works.

View Source
var ErrUnavailableNode = errors.New("unavailable node")

ErrUnavailableNode is returned when node is unavailable.

Functions

This section is empty.

Types

type ChunkWriter added in v0.13.0

type ChunkWriter interface {
	WriteChunk([]byte) error
}

ChunkWriter is an interface of target component to write payload chunk.

type ClientConstructor added in v0.18.0

type ClientConstructor interface {
	Get(context.Context, netmap.NodeInfo) (clientcore.MultiAddressClient, error)
}

type ForwardRequestFunc added in v0.54.0

type ForwardRequestFunc func(ctx context.Context, node clientcore.MultiAddressClient) error

ForwardRequestFunc forwards original request to remote node through passed connection and responds to the client.

If response stream fails, ErrResponseStreamFailure is returned.

If node is currently unavailable, ErrUnavailableNode is returned.

type GetECRequestTransport added in v0.54.0

type GetECRequestTransport interface {
	// CopyECParentHeaderAndPayloadFromRemoteFirstPart requests originally requested
	// object's first EC part identified by EC rule index from remote storage node
	// using conn to it. If succeeded,
	// CopyECParentHeaderAndPayloadFromRemoteFirstPart sends parent header and part
	// payload to the client, and returns:
	//  - flag whether parent header was copied or not;
	//  - payload length of original requested object in bytes;
	//  - payload length of part object in bytes;
	//  - number of part's payload bytes copied.
	//
	// If response stream fails, [ErrResponseStreamFailure] is returned.
	//
	// If the node responds with split object info,
	// CopyECParentHeaderAndPayloadFromRemoteFirstPart converts it to
	// [*object.SplitInfoError] and returns.
	//
	// If the node responds with any failure status other than 'not found', the
	// response is copied to the client and [ErrResponded] is returned.
	//
	// If the node responds with object of LINK type, [ErrLinker] is returned.
	//
	// Otherwise, no error is returned. Copying can be incomplete in this case.
	//
	// CopyECParentHeaderAndPayloadFromRemoteFirstPart is never called concurrently.
	//
	// Once CopyECParentHeaderAndPayloadFromRemoteFirstPart returns an error or set
	// copied header flag, it's no longer called.
	CopyECParentHeaderAndPayloadFromRemoteFirstPart(ctx context.Context, conn clientcore.MultiAddressClient, ruleIdx int) (bool, uint64, uint64, uint64, error)
	// CopyECParentHeaderAndPayloadFromLocalFirstPart works like CopyECParentHeaderAndPayloadFromRemoteFirstPart but locally.
	CopyECParentHeaderAndPayloadFromLocalFirstPart(ctx context.Context, storage *engine.StorageEngine, ruleIdx int) (bool, uint64, uint64, uint64, error)
	// CopyRemoteECPartRange requests specified payload range of originally
	// requested object's EC part identified by partInfo pair from remote storage
	// node using conn to it. If succeeded, CopyRemoteECPartRange sends with payload
	// range to the client, and returns number of bytes copied.
	//
	// Flag full specifies whether full range should be obtained. In this case,
	// offset is always zero and ln is a full length known in advance.
	//
	// If response stream fails, [ErrResponseStreamFailure] is returned.
	//
	// If the node responds with any failure status other than 'not found', the
	// response is copied to the client and [ErrResponded] is returned.
	//
	// Otherwise, no error is returned. Copying can be incomplete in this case.
	//
	// If controlCh is passed, CopyRemoteECPartRange blocks copying data until signal
	// from it. On true, CopyRemoteECPartRange returns [ErrAborted] instantly
	// without copying. Otherwise, i.e. if on false or close, copying starts.
	//
	// CopyRemoteECPartRange can be called concurrently for different partInfo, but
	// never for the same one.
	//
	// Once CopyRemoteECPartRange returns an error or requested range is fully
	// copied, it's no longer called for the same part.
	CopyRemoteECPartRange(ctx context.Context, conn clientcore.MultiAddressClient, partInfo iec.PartInfo, off, ln uint64, full bool, controlCh <-chan bool) (uint64, error)
	// CopyLocalECPartRange works like CopyRemoteECPartRange but locally.
	CopyLocalECPartRange(ctx context.Context, storage *engine.StorageEngine, partInfo iec.PartInfo, off, ln uint64, ch <-chan bool) (uint64, error)
}

GetECRequestTransport is used to serve GET requests for EC objects.

type GetTransportFunc added in v0.54.0

type GetTransportFunc func(context.Context, clientcore.MultiAddressClient) error

GetTransportFunc continues to serve current GET request from remote node through passed connection.

type HeadPrm added in v0.13.0

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

HeadPrm groups parameters of Head service call.

func (*HeadPrm) SetCommonParameters added in v0.13.0

func (p *HeadPrm) SetCommonParameters(common *util.CommonPrm)

SetCommonParameters sets common parameters of the operation.

func (*HeadPrm) SetForwardRequestFunc added in v0.54.0

func (p *HeadPrm) SetForwardRequestFunc(f ForwardRequestFunc)

SetForwardRequestFunc specifies transport implementation for request forwarding to container nodes by non-container server.

func (*HeadPrm) SetHeaderWriter added in v0.13.0

func (p *HeadPrm) SetHeaderWriter(w internal.HeaderWriter)

SetHeaderWriter sets target component to write the object header.

func (*HeadPrm) SetSubmitHeadResponseFunc added in v0.53.0

func (p *HeadPrm) SetSubmitHeadResponseFunc(f SubmitHeadResponseFunc)

SetSubmitHeadResponseFunc specifies handler to pass results of [HeadPrm.SetRequestForwarder] argument into.

func (*HeadPrm) SetTransportFunc added in v0.54.0

func (p *HeadPrm) SetTransportFunc(f HeadTransportFunc)

SetTransportFunc specifies request transport callback to use for receiving response from remote node by in-container server.

The f should return:

  • response buffer and object header protobuf without an error on OK
  • object.SplitInfoError on OK with corresponding body field
  • apistatus.ErrObjectNotFound on 404 status
  • (respBuf, iprotobuf.BuffersSlice{}, nil) on other API statuses
  • any transport error

Once results successfully received, it is forwarded untouched to handler which must be set via HeadPrm.SetSubmitHeadResponseFunc.

The f is never called concurrently.

func (*HeadPrm) WithAddress added in v0.27.0

func (p *HeadPrm) WithAddress(addr oid.Address)

WithAddress sets object address to be read.

func (*HeadPrm) WithBuffer added in v0.52.0

func (p *HeadPrm) WithBuffer(buffer []byte, submitLenFn func(int))

WithBuffer specifies a buffer into which header of the requested object is optionally written. The submitLenFn parameter is a callback for number of bytes written. If buffer is unused, submitLenFn is not called.

func (*HeadPrm) WithCachedSignerKey added in v0.36.0

func (p *HeadPrm) WithCachedSignerKey(signerKey *ecdsa.PrivateKey)

WithCachedSignerKey sets optional key for all further requests.

func (*HeadPrm) WithContainer added in v0.53.0

func (p *HeadPrm) WithContainer(cnr container.Container)

WithContainer sets container data to be used.

func (*HeadPrm) WithRawFlag added in v0.27.0

func (p *HeadPrm) WithRawFlag(raw bool)

WithRawFlag sets flag of raw reading.

type HeadTransportFunc added in v0.54.0

HeadTransportFunc sends currently served HEAD request to remote node through passed connection and returns buffered response with requested object's header binary in it.

type HeaderValidator added in v0.53.0

type HeaderValidator interface {
	ValidateHeader(*object.Object) error
}

HeaderValidator is an optional interface for validating object headers before suppressing them from the response.

type NeoFSNetwork added in v0.43.0

type NeoFSNetwork interface {
	// GetNodesForObject returns descriptors of storage nodes matching storage
	// policy of the referenced object for now. Nodes are identified by their public
	// keys and can be repeated in different lists. First len(repRules) lists relate
	// to replication, the rest len(ecRules) - to EC.
	//
	// repRules specifies replication rules: the number (N) of primary object
	// holders for each list (L) so:
	//  - size of each L >= N;
	//  - first N nodes of each L are primary data holders while others (if any)
	//    are backup.
	//
	// ecRules specifies erasure coding rules for all objects in the container: each
	// object is split into [iec.Rule.DataPartNum] data and [iec.Rule.ParityPartNum]
	// parity parts. Each i-th part most expected to be located on SN described by
	// i-th list element. In general, list len is a multiple of CBF, and the part is
	// expected on N with index M*i, M in [0,CBF). Then part is expected on SN
	// for i+1-th part and so on.
	//
	// GetNodesForObject does not change resulting slices and their elements.
	//
	// Returns [apistatus.ContainerNotFound] if requested container is missing in
	// the network.
	GetNodesForObject(oid.Address) (nodeRules [][]netmap.NodeInfo, repRules []uint, ecRules []iec.Rule, err error)
	// IsLocalNodePublicKey checks whether given binary-encoded public key is
	// assigned in the network map to a local storage node providing [Service].
	IsLocalNodePublicKey([]byte) bool
}

NeoFSNetwork provides access to the NeoFS network to get information necessary for the Service to work.

type ObjectWriter added in v0.13.0

type ObjectWriter interface {
	internal.HeaderWriter
	ChunkWriter
}

ObjectWriter is an interface of target component to write object.

type Option

type Option func(*cfg)

Option is a Service's constructor option.

func WithClientConstructor added in v0.18.0

func WithClientConstructor(v ClientConstructor) Option

WithClientConstructor returns option to set constructor of remote node clients.

func WithKeyStorage added in v0.26.1

func WithKeyStorage(store *util.KeyStorage) Option

WithKeyStorage returns option to set private key storage for session tokens and node key.

func WithLocalStorageEngine added in v0.13.0

func WithLocalStorageEngine(e *engine.StorageEngine) Option

WithLocalStorageEngine returns option to set local storage instance.

func WithLogger added in v0.13.0

func WithLogger(l *zap.Logger) Option

WithLogger returns option to specify Get service's logger.

func WithNNSResolver added in v0.51.0

func WithNNSResolver(resolver sessionv2.NNSResolver) Option

WithNNSResolver returns option to set NNS resolver for checking session token subjects.

type Prm

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

Prm groups parameters of Get service call.

func (Prm) GetBuffer added in v0.52.0

func (p Prm) GetBuffer() ([]byte, SubmitStreamFunc)

GetBuffer returns buffer settings set using Prm.WithBuffer.

func (Prm) HasRange added in v0.55.0

func (p Prm) HasRange() bool

HasRange reports whether a fixed or extended payload range is configured.

func (Prm) IsFullRange added in v0.55.0

func (p Prm) IsFullRange() bool

IsFullRange checks whether payload range is set and corresponds to full payload.

func (*Prm) MarkPayloadOnly added in v0.53.0

func (p *Prm) MarkPayloadOnly()

MarkPayloadOnly requests payload without an object header.

func (Prm) PayloadOnly added in v0.53.0

func (p Prm) PayloadOnly() bool

PayloadOnly reports whether only payload was requested.

func (Prm) Range added in v0.53.0

func (p Prm) Range() *object.Range

Range returns payload range settings.

func (Prm) RangeMode added in v0.55.0

func (p Prm) RangeMode() blobstor.PayloadRangeMode

RangeMode returns kind of requested range.

func (*Prm) RequireEACLRecheck added in v0.54.0

func (p *Prm) RequireEACLRecheck()

RequireEACLRecheck marks request as requiring object header on internal full-GETs so eACL can be rechecked against header fields when needed.

func (Prm) ResolveRange added in v0.55.0

func (p Prm) ResolveRange(payloadLen uint64) (uint64, uint64, error)

ResolveRange resolves the requested payload range against payloadLen.

func (*Prm) SetCommonParameters added in v0.13.0

func (p *Prm) SetCommonParameters(common *util.CommonPrm)

SetCommonParameters sets common parameters of the operation.

func (*Prm) SetForwardRequestFunc added in v0.54.0

func (p *Prm) SetForwardRequestFunc(f ForwardRequestFunc)

SetForwardRequestFunc specifies transport implementation for request forwarding to container nodes by non-container server.

func (*Prm) SetObjectWriter added in v0.13.0

func (p *Prm) SetObjectWriter(w ObjectWriter)

SetObjectWriter sets target component to write the object.

func (*Prm) SetRange added in v0.53.0

func (p *Prm) SetRange(rng *object.Range)

SetRange sets range of the requested payload data.

func (*Prm) SetRangeBounds added in v0.55.0

func (p *Prm) SetRangeBounds(first, last uint64)

SetRangeBounds requests an inclusive payload range from first to last.

func (*Prm) SetRangeFrom added in v0.55.0

func (p *Prm) SetRangeFrom(first uint64)

SetRangeFrom requests payload bytes from first to the end.

func (*Prm) SetRangeSuffix added in v0.55.0

func (p *Prm) SetRangeSuffix(length uint64)

SetRangeSuffix requests the last length payload bytes.

func (*Prm) SetTransportFunc added in v0.54.0

func (p *Prm) SetTransportFunc(f GetTransportFunc)

SetTransportFunc specifies request transport callback to use for streaming responses from remote node by in-container server.

The f should return:

  • nil on completed object transmission
  • apistatus.ErrObjectNotFound on 404 status
  • nil on other API statuses
  • any other transport/protocol error otherwise

The f is never called concurrently.

func (*Prm) WithAddress

func (p *Prm) WithAddress(addr oid.Address)

WithAddress sets object address to be read.

func (*Prm) WithBuffer added in v0.52.0

func (p *Prm) WithBuffer(buffer []byte, interceptHeaderBinaryFn func([]byte) error, submitStreamFn SubmitStreamFunc)

WithBuffer specifies a buffer into which header of the requested object is optionally written. The submitStreamFn parameter is a callback for number of bytes written and stream of remaining bytes. If buffer is unused, submitStreamFn is not called. The stream must be finally closed by the caller.

If interceptHeaderBinaryFn is specified, it's called instantly once header is read (never concurrently). If it returns an error, whole operation is aborted with this error.

func (*Prm) WithCachedSignerKey added in v0.36.0

func (p *Prm) WithCachedSignerKey(signerKey *ecdsa.PrivateKey)

WithCachedSignerKey sets optional key for all further requests.

func (*Prm) WithContainer added in v0.53.0

func (p *Prm) WithContainer(cnr container.Container)

WithContainer sets container data to be used.

func (*Prm) WithECReturnAnyPart added in v0.55.0

func (p *Prm) WithECReturnAnyPart()

WithECReturnAnyPart makes return any EC part local node has, if recuested part ID is not found.

func (*Prm) WithECTransport added in v0.54.0

func (p *Prm) WithECTransport(transport GetECRequestTransport)

WithECTransport specifies transport layer to for EC handling.

func (*Prm) WithRawFlag added in v0.27.0

func (p *Prm) WithRawFlag(raw bool)

WithRawFlag sets flag of raw reading.

type RequestForwarder added in v0.19.0

type RequestForwarder func(context.Context, clientcore.MultiAddressClient) (*object.Object, error)

type Service

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

Service utility serving requests of Object.Get service.

func New added in v0.13.0

func New(neoFSNet NeoFSNetwork, opts ...Option) *Service

New creates, initializes and returns utility serving Object.Get service requests.

func (*Service) Get

func (s *Service) Get(ctx context.Context, prm Prm) error

Get serves a request to get an object by address, and returns Streamer instance.

func (*Service) Head added in v0.13.0

func (s *Service) Head(ctx context.Context, prm HeadPrm) error

Head reads object header from container.

Returns ErrNotFound if the header was not received for the call. Returns SplitInfoError if object is virtual and raw flag is set.

type SimpleObjectWriter added in v0.13.0

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

func NewSimpleObjectWriter added in v0.13.0

func NewSimpleObjectWriter() *SimpleObjectWriter

func (*SimpleObjectWriter) Object added in v0.13.0

func (s *SimpleObjectWriter) Object() *object.Object

func (*SimpleObjectWriter) WriteChunk added in v0.13.0

func (s *SimpleObjectWriter) WriteChunk(p []byte) error

func (*SimpleObjectWriter) WriteHeader added in v0.13.0

func (s *SimpleObjectWriter) WriteHeader(obj *object.Object) error

type SubmitDataStreamFunc added in v0.53.0

type SubmitDataStreamFunc = func(io.ReadCloser)

SubmitDataStreamFunc is a handler of data stream.

type SubmitHeadResponseFunc added in v0.53.0

type SubmitHeadResponseFunc = func(mem.BufferSlice, iprotobuf.BuffersSlice)

SubmitHeadResponseFunc accepts result of [ForwardHeadRequestFunc].

type SubmitStreamFunc added in v0.52.0

type SubmitStreamFunc = func(int, io.ReadCloser)

SubmitStreamFunc is a callback for partially read object stream.

Jump to

Keyboard shortcuts

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