[#1628] node: Move common EACLSource interface to core pkg

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-09-08 13:32:25 +03:00 committed by fyrchik
parent 4afb928ab6
commit 4f18893d9b
7 changed files with 21 additions and 31 deletions

View file

@ -8,7 +8,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/core/container" "github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
cntClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" cntClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -162,7 +161,7 @@ func (s *ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) {
type ttlEACLStorage ttlNetCache type ttlEACLStorage ttlNetCache
func newCachedEACLStorage(v eacl.Source, ttl time.Duration) *ttlEACLStorage { func newCachedEACLStorage(v container.EACLSource, ttl time.Duration) *ttlEACLStorage {
const eaclCacheSize = 100 const eaclCacheSize = 100
lruCnrCache := newNetworkTTLCache(eaclCacheSize, ttl, func(key interface{}) (interface{}, error) { lruCnrCache := newNetworkTTLCache(eaclCacheSize, ttl, func(key interface{}) (interface{}, error) {

View file

@ -40,7 +40,6 @@ import (
"github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network"
"github.com/nspcc-dev/neofs-node/pkg/network/cache" "github.com/nspcc-dev/neofs-node/pkg/network/cache"
"github.com/nspcc-dev/neofs-node/pkg/services/control" "github.com/nspcc-dev/neofs-node/pkg/services/control"
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get" getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/tombstone" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/tombstone"
tsourse "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/tombstone/source" tsourse "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/tombstone/source"
@ -195,7 +194,7 @@ type cfgObject struct {
cnrSource container.Source cnrSource container.Source
eaclSource eacl.Source eaclSource container.EACLSource
pool cfgObjectRoutines pool cfgObjectRoutines

View file

@ -25,7 +25,6 @@ import (
placementrouter "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/route/placement" placementrouter "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/route/placement"
loadstorage "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/storage" loadstorage "github.com/nspcc-dev/neofs-node/pkg/services/container/announcement/load/storage"
containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph" containerMorph "github.com/nspcc-dev/neofs-node/pkg/services/container/morph"
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
apiClient "github.com/nspcc-dev/neofs-sdk-go/client" apiClient "github.com/nspcc-dev/neofs-sdk-go/client"
containerSDK "github.com/nspcc-dev/neofs-sdk-go/container" containerSDK "github.com/nspcc-dev/neofs-sdk-go/container"
@ -619,7 +618,7 @@ func (c *usedSpaceService) processLoadValue(_ context.Context, a containerSDK.Si
// implements interface required by container service provided by morph executor. // implements interface required by container service provided by morph executor.
type morphContainerReader struct { type morphContainerReader struct {
eacl eacl.Source eacl containerCore.EACLSource
get containerCore.Source get containerCore.Source

View file

@ -55,3 +55,16 @@ type EACL struct {
// Session within which Value was set. Nil means session absence. // Session within which Value was set. Nil means session absence.
Session *session.Container Session *session.Container
} }
// EACLSource is the interface that wraps
// basic methods of extended ACL table source.
type EACLSource interface {
// GetEACL reads the table from the source by identifier.
// It returns any error encountered.
//
// GetEACL must return exactly one non-nil value.
//
// Must return apistatus.ErrEACLNotFound if requested
// eACL table is not in source.
GetEACL(cid.ID) (*EACL, error)
}

View file

@ -10,7 +10,6 @@ import (
sessionV2 "github.com/nspcc-dev/neofs-api-go/v2/session" sessionV2 "github.com/nspcc-dev/neofs-api-go/v2/session"
containercore "github.com/nspcc-dev/neofs-node/pkg/core/container" containercore "github.com/nspcc-dev/neofs-node/pkg/core/container"
containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container" containerSvc "github.com/nspcc-dev/neofs-node/pkg/services/container"
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id" cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl" eaclSDK "github.com/nspcc-dev/neofs-sdk-go/eacl"
"github.com/nspcc-dev/neofs-sdk-go/session" "github.com/nspcc-dev/neofs-sdk-go/session"
@ -25,7 +24,7 @@ type morphExecutor struct {
// Reader is an interface of read-only container storage. // Reader is an interface of read-only container storage.
type Reader interface { type Reader interface {
containercore.Source containercore.Source
eacl.Source containercore.EACLSource
// List returns a list of container identifiers belonging // List returns a list of container identifiers belonging
// to the specified user of NeoFS system. Returns the identifiers // to the specified user of NeoFS system. Returns the identifiers

View file

@ -7,9 +7,9 @@ import (
"fmt" "fmt"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neofs-node/pkg/core/container"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine"
"github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl"
eaclV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl/v2" eaclV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl/v2"
v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2" v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2"
bearerSDK "github.com/nspcc-dev/neofs-sdk-go/bearer" bearerSDK "github.com/nspcc-dev/neofs-sdk-go/bearer"
@ -23,13 +23,13 @@ import (
// CheckerPrm groups parameters for Checker // CheckerPrm groups parameters for Checker
// constructor. // constructor.
type CheckerPrm struct { type CheckerPrm struct {
eaclSrc eacl.Source eaclSrc container.EACLSource
validator *eaclSDK.Validator validator *eaclSDK.Validator
localStorage *engine.StorageEngine localStorage *engine.StorageEngine
state netmap.State state netmap.State
} }
func (c *CheckerPrm) SetEACLSource(v eacl.Source) *CheckerPrm { func (c *CheckerPrm) SetEACLSource(v container.EACLSource) *CheckerPrm {
c.eaclSrc = v c.eaclSrc = v
return c return c
} }
@ -52,7 +52,7 @@ func (c *CheckerPrm) SetNetmapState(v netmap.State) *CheckerPrm {
// Checker implements v2.ACLChecker interfaces and provides // Checker implements v2.ACLChecker interfaces and provides
// ACL/eACL validation functionality. // ACL/eACL validation functionality.
type Checker struct { type Checker struct {
eaclSrc eacl.Source eaclSrc container.EACLSource
validator *eaclSDK.Validator validator *eaclSDK.Validator
localStorage *engine.StorageEngine localStorage *engine.StorageEngine
state netmap.State state netmap.State

View file

@ -1,19 +0,0 @@
package eacl
import (
containercore "github.com/nspcc-dev/neofs-node/pkg/core/container"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
)
// Source is the interface that wraps
// basic methods of extended ACL table source.
type Source interface {
// GetEACL reads the table from the source by identifier.
// It returns any error encountered.
//
// GetEACL must return exactly one non-nil value.
//
// Must return apistatus.ErrEACLNotFound if requested
// eACL table is not in source.
GetEACL(cid.ID) (*containercore.EACL, error)
}