forked from TrueCloudLab/frostfs-sdk-go
*: Update documentation
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
This commit is contained in:
parent
4fe5e6022d
commit
4b0c67ea7a
5 changed files with 40 additions and 10 deletions
|
@ -74,6 +74,10 @@ func (c *Client) Init(prm PrmInit) {
|
||||||
// One-time method call during application start-up stage (after Init ) is expected.
|
// One-time method call during application start-up stage (after Init ) is expected.
|
||||||
// Calling multiple times leads to undefined behavior.
|
// Calling multiple times leads to undefined behavior.
|
||||||
//
|
//
|
||||||
|
// Return client errors:
|
||||||
|
// - [ErrMissingServer]
|
||||||
|
// - [ErrNonPositiveTimeout]
|
||||||
|
//
|
||||||
// See also Init / Close.
|
// See also Init / Close.
|
||||||
func (c *Client) Dial(prm PrmDial) error {
|
func (c *Client) Dial(prm PrmDial) error {
|
||||||
if prm.endpoint == "" {
|
if prm.endpoint == "" {
|
||||||
|
|
|
@ -6,23 +6,38 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrMissingServer = errors.New("server address is unset or empty")
|
// ErrMissingServer is returned when server endpoint is empty in parameters.
|
||||||
|
ErrMissingServer = errors.New("server address is unset or empty")
|
||||||
|
// ErrNonPositiveTimeout is returned when any timeout is below zero in parameters.
|
||||||
ErrNonPositiveTimeout = errors.New("non-positive timeout")
|
ErrNonPositiveTimeout = errors.New("non-positive timeout")
|
||||||
|
|
||||||
ErrMissingContainer = errors.New("missing container")
|
// ErrMissingContainer is returned when container is not provided.
|
||||||
ErrMissingObject = errors.New("missing object")
|
ErrMissingContainer = errors.New("missing container")
|
||||||
ErrMissingAccount = errors.New("missing account")
|
// ErrMissingObject is returned when object is not provided.
|
||||||
ErrMissingEACL = errors.New("missing eACL table")
|
ErrMissingObject = errors.New("missing object")
|
||||||
|
// ErrMissingAccount is returned when account/owner is not provided.
|
||||||
|
ErrMissingAccount = errors.New("missing account")
|
||||||
|
// ErrMissingEACL is returned when eACL table is not provided.
|
||||||
|
ErrMissingEACL = errors.New("missing eACL table")
|
||||||
|
// ErrMissingEACLContainer is returned when container info is not provided in eACL table.
|
||||||
ErrMissingEACLContainer = errors.New("missing container in eACL table")
|
ErrMissingEACLContainer = errors.New("missing container in eACL table")
|
||||||
|
// ErrMissingAnnouncements is returned when announcements are not provided.
|
||||||
ErrMissingAnnouncements = errors.New("missing announcements")
|
ErrMissingAnnouncements = errors.New("missing announcements")
|
||||||
ErrZeroRangeLength = errors.New("zero range length")
|
// ErrZeroRangeLength is returned when range parameter has zero length.
|
||||||
ErrMissingRanges = errors.New("missing ranges")
|
ErrZeroRangeLength = errors.New("zero range length")
|
||||||
ErrZeroEpoch = errors.New("zero epoch")
|
// ErrMissingRanges is returned when empty ranges list is provided.
|
||||||
ErrMissingTrusts = errors.New("missing trusts")
|
ErrMissingRanges = errors.New("missing ranges")
|
||||||
ErrMissingTrust = errors.New("missing trust")
|
// ErrZeroEpoch is returned when zero epoch is provided.
|
||||||
|
ErrZeroEpoch = errors.New("zero epoch")
|
||||||
|
// ErrMissingTrusts is returned when empty slice of trusts is provided.
|
||||||
|
ErrMissingTrusts = errors.New("missing trusts")
|
||||||
|
// ErrMissingTrust is returned when empty trust is not provided.
|
||||||
|
ErrMissingTrust = errors.New("missing trust")
|
||||||
|
|
||||||
|
// ErrUnexpectedReadCall is returned when we already got all data but truing to get more.
|
||||||
ErrUnexpectedReadCall = errors.New("unexpected call to `Read`")
|
ErrUnexpectedReadCall = errors.New("unexpected call to `Read`")
|
||||||
|
|
||||||
|
// ErrSign is returned when unable to sign service message.
|
||||||
ErrSign SignError
|
ErrSign SignError
|
||||||
|
|
||||||
errMissingResponseField missingResponseFieldErr
|
errMissingResponseField missingResponseFieldErr
|
||||||
|
@ -56,22 +71,27 @@ func newErrInvalidResponseField(name string, err error) error {
|
||||||
return fmt.Errorf("invalid %s field in the response: %w", name, err)
|
return fmt.Errorf("invalid %s field in the response: %w", name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignError wraps another error with reason why sign process was failed.
|
||||||
type SignError struct {
|
type SignError struct {
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSignError is a constructor for [SignError].
|
||||||
func NewSignError(err error) SignError {
|
func NewSignError(err error) SignError {
|
||||||
return SignError{err: err}
|
return SignError{err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
func (e SignError) Error() string {
|
func (e SignError) Error() string {
|
||||||
return fmt.Sprintf("sign: %v", e.err)
|
return fmt.Sprintf("sign: %v", e.err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unwrap implements the error interface.
|
||||||
func (e SignError) Unwrap() error {
|
func (e SignError) Unwrap() error {
|
||||||
return e.err
|
return e.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is implements interface for correct checking current error type with [errors.Is].
|
||||||
func (e SignError) Is(target error) bool {
|
func (e SignError) Is(target error) bool {
|
||||||
switch target.(type) {
|
switch target.(type) {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -41,6 +41,8 @@ func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo {
|
||||||
// Any client's internal or transport errors are returned as `error`,
|
// Any client's internal or transport errors are returned as `error`,
|
||||||
// see [apistatus] package for NeoFS-specific error types.
|
// see [apistatus] package for NeoFS-specific error types.
|
||||||
//
|
//
|
||||||
|
// Context is required and must not be nil. It is used for network communication.
|
||||||
|
//
|
||||||
// Exactly one return value is non-nil. Server status return is returned in ResEndpointInfo.
|
// Exactly one return value is non-nil. Server status return is returned in ResEndpointInfo.
|
||||||
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
||||||
func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error) {
|
func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error) {
|
||||||
|
@ -122,6 +124,8 @@ func (x ResNetworkInfo) Info() netmap.NetworkInfo {
|
||||||
// Any client's internal or transport errors are returned as `error`,
|
// Any client's internal or transport errors are returned as `error`,
|
||||||
// see [apistatus] package for NeoFS-specific error types.
|
// see [apistatus] package for NeoFS-specific error types.
|
||||||
//
|
//
|
||||||
|
// Context is required and must not be nil. It is used for network communication.
|
||||||
|
//
|
||||||
// Exactly one return value is non-nil. Server status return is returned in ResNetworkInfo.
|
// Exactly one return value is non-nil. Server status return is returned in ResNetworkInfo.
|
||||||
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
// Reflects all internal errors in second return value (transport problems, response processing, etc.).
|
||||||
func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetworkInfo, error) {
|
func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetworkInfo, error) {
|
||||||
|
|
|
@ -157,6 +157,7 @@ func (x ResObjectHash) Checksums() [][]byte {
|
||||||
// Return errors:
|
// Return errors:
|
||||||
// - [ErrMissingContainer]
|
// - [ErrMissingContainer]
|
||||||
// - [ErrMissingObject]
|
// - [ErrMissingObject]
|
||||||
|
// - [ErrMissingRanges]
|
||||||
func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectHash, error) {
|
func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectHash, error) {
|
||||||
switch {
|
switch {
|
||||||
case prm.addr.GetContainerID() == nil:
|
case prm.addr.GetContainerID() == nil:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
|
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrOwnerExtract is returned when failed to extract account info from key.
|
||||||
var ErrOwnerExtract = errors.New("decode owner failed")
|
var ErrOwnerExtract = errors.New("decode owner failed")
|
||||||
|
|
||||||
// IDFromKey forms the ID using script hash calculated for the given key.
|
// IDFromKey forms the ID using script hash calculated for the given key.
|
||||||
|
|
Loading…
Reference in a new issue