forked from TrueCloudLab/frostfs-sdk-go
[#48] client: Remove ctx == nil
checks
Much less useful after we made context to be passed explicitly. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
55b06cd764
commit
1bfa9ecdb0
17 changed files with 9 additions and 71 deletions
|
@ -52,10 +52,7 @@ func (x ResBalanceGet) Amount() accounting.Decimal {
|
|||
// Return statuses:
|
||||
// - global (see Client docs).
|
||||
func (c *Client) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*ResBalanceGet, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.accountSet:
|
||||
if !prm.accountSet {
|
||||
return nil, errorAccountNotSet
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ func writeXHeadersToMeta(xHeaders []string, h *v2session.RequestMetaHeader) {
|
|||
|
||||
// error messages.
|
||||
var (
|
||||
errorMissingContext = errors.New("missing context")
|
||||
errorMissingContainer = errors.New("missing container")
|
||||
errorMissingObject = errors.New("missing object")
|
||||
errorAccountNotSet = errors.New("account not set")
|
||||
|
|
|
@ -72,10 +72,7 @@ type ResContainerDelete struct {
|
|||
// - global (see Client docs).
|
||||
func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (*ResContainerDelete, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.idSet:
|
||||
if !prm.idSet {
|
||||
return nil, errorMissingContainer
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,7 @@ func (x ResContainerEACL) Table() eacl.Table {
|
|||
// - *apistatus.EACLNotFound.
|
||||
func (c *Client) ContainerEACL(ctx context.Context, prm PrmContainerEACL) (*ResContainerEACL, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.idSet:
|
||||
if !prm.idSet {
|
||||
return nil, errorMissingContainer
|
||||
}
|
||||
|
||||
|
|
|
@ -57,10 +57,7 @@ func (x ResContainerGet) Container() container.Container {
|
|||
// - global (see Client docs);
|
||||
// - *apistatus.ContainerNotFound.
|
||||
func (c *Client) ContainerGet(ctx context.Context, prm PrmContainerGet) (*ResContainerGet, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.idSet:
|
||||
if !prm.idSet {
|
||||
return nil, errorMissingContainer
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,7 @@ func (x ResContainerList) Containers() []cid.ID {
|
|||
// - global (see Client docs).
|
||||
func (c *Client) ContainerList(ctx context.Context, prm PrmContainerList) (*ResContainerList, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.ownerSet:
|
||||
if !prm.ownerSet {
|
||||
return nil, errorAccountNotSet
|
||||
}
|
||||
|
||||
|
|
|
@ -82,10 +82,7 @@ func (x ResContainerPut) ID() cid.ID {
|
|||
// nolint: funlen
|
||||
func (c *Client) ContainerPut(ctx context.Context, prm PrmContainerPut) (*ResContainerPut, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.cnrSet:
|
||||
if !prm.cnrSet {
|
||||
return nil, errorMissingContainer
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,7 @@ type ResContainerSetEACL struct {
|
|||
// - global (see Client docs).
|
||||
func (c *Client) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL) (*ResContainerSetEACL, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.tableSet:
|
||||
if !prm.tableSet {
|
||||
return nil, errorEACLTableNotSet
|
||||
}
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@ type ResAnnounceSpace struct {
|
|||
// - global (see Client docs).
|
||||
func (c *Client) ContainerAnnounceUsedSpace(ctx context.Context, prm PrmAnnounceSpace) (*ResAnnounceSpace, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case len(prm.announcements) == 0:
|
||||
if len(prm.announcements) == 0 {
|
||||
return nil, errorMissingAnnouncements
|
||||
}
|
||||
|
||||
|
|
|
@ -56,11 +56,6 @@ func (x ResEndpointInfo) NodeInfo() netmap.NodeInfo {
|
|||
// Return statuses:
|
||||
// - global (see Client docs).
|
||||
func (c *Client) EndpointInfo(ctx context.Context, prm PrmEndpointInfo) (*ResEndpointInfo, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
return nil, errorMissingContext
|
||||
}
|
||||
|
||||
// form request
|
||||
var req v2netmap.LocalNodeInfoRequest
|
||||
|
||||
|
@ -153,11 +148,6 @@ func (x ResNetworkInfo) Info() netmap.NetworkInfo {
|
|||
// Return statuses:
|
||||
// - global (see Client docs).
|
||||
func (c *Client) NetworkInfo(ctx context.Context, prm PrmNetworkInfo) (*ResNetworkInfo, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
return nil, errorMissingContext
|
||||
}
|
||||
|
||||
// form request
|
||||
var req v2netmap.NetworkInfoRequest
|
||||
|
||||
|
|
|
@ -125,8 +125,6 @@ func (x ResObjectDelete) Tombstone() oid.ID {
|
|||
// - *apistatus.SessionTokenExpired.
|
||||
func (c *Client) ObjectDelete(ctx context.Context, prm PrmObjectDelete) (*ResObjectDelete, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
return nil, errorMissingContainer
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
|
|
@ -301,8 +301,6 @@ func (x *ObjectReader) Read(p []byte) (int, error) {
|
|||
func (c *Client) ObjectGetInit(ctx context.Context, prm PrmObjectGet) (*ObjectReader, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
return nil, errorMissingContainer
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
@ -416,8 +414,6 @@ func (x *ResObjectHead) ReadHeader(dst *object.Object) bool {
|
|||
// - *apistatus.SessionTokenExpired.
|
||||
func (c *Client) ObjectHead(ctx context.Context, prm PrmObjectHead) (*ResObjectHead, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
return nil, errorMissingContainer
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
@ -668,8 +664,6 @@ func (x *ObjectRangeReader) Read(p []byte) (int, error) {
|
|||
func (c *Client) ObjectRangeInit(ctx context.Context, prm PrmObjectRange) (*ObjectRangeReader, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
return nil, errorMissingContainer
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
|
|
@ -166,8 +166,6 @@ func (x ResObjectHash) Checksums() [][]byte {
|
|||
// - *apistatus.SessionTokenExpired.
|
||||
func (c *Client) ObjectHash(ctx context.Context, prm PrmObjectHash) (*ResObjectHash, error) {
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.addr.GetContainerID() == nil:
|
||||
return nil, errorMissingContainer
|
||||
case prm.addr.GetObjectID() == nil:
|
||||
|
|
|
@ -245,11 +245,6 @@ func (x *ObjectWriter) Close() (*ResObjectPut, error) {
|
|||
// Returns an error if parameters are set incorrectly.
|
||||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) ObjectPutInit(ctx context.Context, prm PrmObjectPutInit) (*ObjectWriter, error) {
|
||||
// check parameters
|
||||
if ctx == nil {
|
||||
return nil, errorMissingContext
|
||||
}
|
||||
|
||||
var w ObjectWriter
|
||||
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
|
|
@ -222,10 +222,7 @@ func (x *ObjectListReader) Close() (*ResObjectSearch, error) {
|
|||
// Context is required and must not be nil. It is used for network communication.
|
||||
func (c *Client) ObjectSearchInit(ctx context.Context, prm PrmObjectSearch) (*ObjectListReader, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case !prm.cnrSet:
|
||||
if !prm.cnrSet {
|
||||
return nil, errorMissingContainer
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,6 @@ type ResAnnounceLocalTrust struct {
|
|||
func (c *Client) AnnounceLocalTrust(ctx context.Context, prm PrmAnnounceLocalTrust) (*ResAnnounceLocalTrust, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.epoch == 0:
|
||||
return nil, errorZeroEpoch
|
||||
case len(prm.trusts) == 0:
|
||||
|
@ -154,8 +152,6 @@ type ResAnnounceIntermediateTrust struct {
|
|||
func (c *Client) AnnounceIntermediateTrust(ctx context.Context, prm PrmAnnounceIntermediateTrust) (*ResAnnounceIntermediateTrust, error) {
|
||||
// check parameters
|
||||
switch {
|
||||
case ctx == nil:
|
||||
return nil, errorMissingContext
|
||||
case prm.epoch == 0:
|
||||
return nil, errorZeroEpoch
|
||||
case !prm.trustSet:
|
||||
|
|
|
@ -78,11 +78,6 @@ func (x ResSessionCreate) PublicKey() []byte {
|
|||
// Return statuses:
|
||||
// - global (see Client docs).
|
||||
func (c *Client) SessionCreate(ctx context.Context, prm PrmSessionCreate) (*ResSessionCreate, error) {
|
||||
// check context
|
||||
if ctx == nil {
|
||||
return nil, errorMissingContext
|
||||
}
|
||||
|
||||
ownerKey := c.prm.key.PublicKey
|
||||
if prm.keySet {
|
||||
ownerKey = prm.key.PublicKey
|
||||
|
|
Loading…
Reference in a new issue