Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - func Get(ctx context.Context, priv *keys.PrivateKey, u *url.URL, addr string) (io.ReadCloser, error)
 - func GetClient(ctx context.Context, addr string, timeout time.Duration) (*client.Client, error)
 - func GetWithClient(ctx context.Context, c Client, priv *keys.PrivateKey, u *url.URL, ...) (io.ReadCloser, error)
 - func IsContextCanceledErr(err error) bool
 - func ObjectSearch(ctx context.Context, c Client, priv *keys.PrivateKey, containerID cid.ID, ...) (<-chan client.SearchResultItem, <-chan error)
 - type BasicService
 - type Client
 
Constants ¶
const ( // DefaultTimeout is the default timeout for NeoFS requests. DefaultTimeout = 10 * time.Minute // DefaultDownloaderWorkersCount is the default number of workers downloading blocks. DefaultDownloaderWorkersCount = 500 // DefaultBatchSize is the default size of the batch to upload in parallel // and search latest fully uploaded batch. DefaultBatchSize = 128000 // DefaultBlockAttribute is the default attribute name for block objects. DefaultBlockAttribute = "Block" // DefaultStateAttribute is the default attribute name for state objects. DefaultStateAttribute = "State" // DefaultKVBatchSize is a number of contract storage key-value objects to // flush to the node's DB in a batch. DefaultKVBatchSize = 1000 // DefaultSearchBatchSize is a number of objects to search in a batch. DefaultSearchBatchSize = 1000 )
Constants related to NeoFS block storage.
const ( // DefaultDialTimeout is a default timeout used to establish connection with // NeoFS storage nodes. DefaultDialTimeout = 30 * time.Second // DefaultStreamTimeout is a default timeout used for NeoFS streams processing. // It has significantly large value to reliably avoid timeout problems with heavy // SEARCH requests. DefaultStreamTimeout = 10 * time.Minute // DefaultHealthcheckTimeout is a timeout for request to NeoFS storage node to // decide if it is alive. DefaultHealthcheckTimeout = 10 * time.Second )
Constants related to NeoFS pool request timeouts.
const ( // MaxRetries is the maximum number of retries for a single operation. MaxRetries = 5 // InitialBackoff is the initial backoff duration. InitialBackoff = 500 * time.Millisecond // BackoffFactor is the factor by which the backoff duration is multiplied. BackoffFactor = 2 // MaxBackoff is the maximum backoff duration. MaxBackoff = 20 * time.Second )
Constants related to retry mechanism.
const (
	// URIScheme is the name of neofs URI scheme.
	URIScheme = "neofs"
)
    Variables ¶
var ( ErrInvalidScheme = errors.New("invalid URI scheme") ErrMissingObject = errors.New("object ID is missing from URI") ErrInvalidContainer = errors.New("container ID is invalid") ErrInvalidObject = errors.New("object ID is invalid") ErrInvalidRange = errors.New("object range is invalid (expected 'Offset|Length')") ErrInvalidCommand = errors.New("invalid command") )
Various validation errors.
Functions ¶
func Get ¶
func Get(ctx context.Context, priv *keys.PrivateKey, u *url.URL, addr string) (io.ReadCloser, error)
Get returns a neofs object from the provided url. URI scheme is "neofs:<Container-ID>/<Object-ID/<Command>/<Params>". If Command is not provided, full object is requested.
func GetClient ¶ added in v0.108.0
GetClient returns a NeoFS client configured with the specified address and context. If timeout is 0, the default timeout will be used.
func GetWithClient ¶
func GetWithClient(ctx context.Context, c Client, priv *keys.PrivateKey, u *url.URL, wrapClientCloser bool) (io.ReadCloser, error)
GetWithClient returns a neofs object from the provided url using the provided client. URI scheme is "neofs:<Container-ID>/<Object-ID/<Command>/<Params>". If Command is not provided, full object is requested. If wrapClientCloser is true, the client will be closed when the returned ReadCloser is closed.
func IsContextCanceledErr ¶ added in v0.110.0
IsContextCanceledErr returns whether error is a wrapped context.Canceled. Ref. https://github.com/nspcc-dev/neofs-sdk-go/issues/624.
func ObjectSearch ¶
func ObjectSearch(ctx context.Context, c Client, priv *keys.PrivateKey, containerID cid.ID, filters object.SearchFilters, attrs []string) (<-chan client.SearchResultItem, <-chan error)
ObjectSearch returns a channel of object search results from the provided container.
Types ¶
type BasicService ¶ added in v0.110.0
type BasicService struct {
	Pool        *pool.Pool
	Account     *wallet.Account
	ContainerID cid.ID
	Ctx         context.Context
	CtxCancel   context.CancelFunc
}
    BasicService is a minimal service structure for NeoFS fetchers.
func NewBasicService ¶ added in v0.110.0
func NewBasicService(cfg config.NeoFSService) (BasicService, error)
NewBasicService creates a new BasicService instance.
func (*BasicService) Retry ¶ added in v0.110.0
func (sfs *BasicService) Retry(action func() error) error
Retry is a retry mechanism for executing an action with exponential backoff.
type Client ¶
type Client interface {
	SearchObjects(ctx context.Context, cnr cid.ID, filters object.SearchFilters, attrs []string, cursor string, signer neofscrypto.Signer, opts client.SearchObjectsOptions) ([]client.SearchResultItem, string, error)
	ObjectGetInit(ctx context.Context, container cid.ID, id oid.ID, s user.Signer, get client.PrmObjectGet) (object.Object, *client.PayloadReader, error)
	ObjectRangeInit(ctx context.Context, container cid.ID, id oid.ID, offset uint64, length uint64, s user.Signer, objectRange client.PrmObjectRange) (*client.ObjectRangeReader, error)
	ObjectHead(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm client.PrmObjectHead) (*object.Object, error)
	ObjectHash(ctx context.Context, containerID cid.ID, objectID oid.ID, signer user.Signer, prm client.PrmObjectHash) ([][]byte, error)
	Close() error
}
    Client is a NeoFS client interface.