forked from TrueCloudLab/frostfs-node
Initial commit
Initial public review release v0.10.0
This commit is contained in:
commit
dadfd90dcd
276 changed files with 46331 additions and 0 deletions
15
lib/container/alias.go
Normal file
15
lib/container/alias.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/container"
|
||||
"github.com/nspcc-dev/neofs-api-go/refs"
|
||||
)
|
||||
|
||||
// Container is a type alias of Container.
|
||||
type Container = container.Container
|
||||
|
||||
// CID is a type alias of CID.
|
||||
type CID = refs.CID
|
||||
|
||||
// OwnerID is a type alias of OwnerID.
|
||||
type OwnerID = refs.OwnerID
|
134
lib/container/storage.go
Normal file
134
lib/container/storage.go
Normal file
|
@ -0,0 +1,134 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// GetParams is a group of parameters for container receiving operation.
|
||||
type GetParams struct {
|
||||
ctxValue
|
||||
|
||||
cidValue
|
||||
}
|
||||
|
||||
// GetResult is a group of values returned by container receiving operation.
|
||||
type GetResult struct {
|
||||
cnrValue
|
||||
}
|
||||
|
||||
// PutParams is a group of parameters for container storing operation.
|
||||
type PutParams struct {
|
||||
ctxValue
|
||||
|
||||
cnrValue
|
||||
}
|
||||
|
||||
// PutResult is a group of values returned by container storing operation.
|
||||
type PutResult struct {
|
||||
cidValue
|
||||
}
|
||||
|
||||
// DeleteParams is a group of parameters for container removal operation.
|
||||
type DeleteParams struct {
|
||||
ctxValue
|
||||
|
||||
cidValue
|
||||
|
||||
ownerID OwnerID
|
||||
}
|
||||
|
||||
// DeleteResult is a group of values returned by container removal operation.
|
||||
type DeleteResult struct{}
|
||||
|
||||
// ListParams is a group of parameters for container listing operation.
|
||||
type ListParams struct {
|
||||
ctxValue
|
||||
|
||||
ownerIDList []OwnerID
|
||||
}
|
||||
|
||||
// ListResult is a group of values returned by container listing operation.
|
||||
type ListResult struct {
|
||||
cidList []CID
|
||||
}
|
||||
|
||||
type cnrValue struct {
|
||||
cnr *Container
|
||||
}
|
||||
|
||||
type cidValue struct {
|
||||
cid CID
|
||||
}
|
||||
|
||||
type ctxValue struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// Storage is an interface of the storage of NeoFS containers.
|
||||
type Storage interface {
|
||||
GetContainer(GetParams) (*GetResult, error)
|
||||
PutContainer(PutParams) (*PutResult, error)
|
||||
DeleteContainer(DeleteParams) (*DeleteResult, error)
|
||||
ListContainers(ListParams) (*ListResult, error)
|
||||
// TODO: add EACL methods
|
||||
}
|
||||
|
||||
// Context is a context getter.
|
||||
func (s ctxValue) Context() context.Context {
|
||||
return s.ctx
|
||||
}
|
||||
|
||||
// SetContext is a context setter.
|
||||
func (s *ctxValue) SetContext(v context.Context) {
|
||||
s.ctx = v
|
||||
}
|
||||
|
||||
// CID is a container ID getter.
|
||||
func (s cidValue) CID() CID {
|
||||
return s.cid
|
||||
}
|
||||
|
||||
// SetCID is a container ID getter.
|
||||
func (s *cidValue) SetCID(v CID) {
|
||||
s.cid = v
|
||||
}
|
||||
|
||||
// Container is a container getter.
|
||||
func (s cnrValue) Container() *Container {
|
||||
return s.cnr
|
||||
}
|
||||
|
||||
// SetContainer is a container setter.
|
||||
func (s *cnrValue) SetContainer(v *Container) {
|
||||
s.cnr = v
|
||||
}
|
||||
|
||||
// OwnerID is an owner ID getter.
|
||||
func (s DeleteParams) OwnerID() OwnerID {
|
||||
return s.ownerID
|
||||
}
|
||||
|
||||
// SetOwnerID is an owner ID setter.
|
||||
func (s *DeleteParams) SetOwnerID(v OwnerID) {
|
||||
s.ownerID = v
|
||||
}
|
||||
|
||||
// OwnerIDList is an owner ID list getter.
|
||||
func (s ListParams) OwnerIDList() []OwnerID {
|
||||
return s.ownerIDList
|
||||
}
|
||||
|
||||
// SetOwnerIDList is an owner ID list setter.
|
||||
func (s *ListParams) SetOwnerIDList(v ...OwnerID) {
|
||||
s.ownerIDList = v
|
||||
}
|
||||
|
||||
// CIDList is a container ID list getter.
|
||||
func (s ListResult) CIDList() []CID {
|
||||
return s.cidList
|
||||
}
|
||||
|
||||
// SetCIDList is a container ID list setter.
|
||||
func (s *ListResult) SetCIDList(v []CID) {
|
||||
s.cidList = v
|
||||
}
|
83
lib/container/storage_test.go
Normal file
83
lib/container/storage_test.go
Normal file
|
@ -0,0 +1,83 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetParams(t *testing.T) {
|
||||
p := new(GetParams)
|
||||
|
||||
cid := CID{1, 2, 3}
|
||||
p.SetCID(cid)
|
||||
|
||||
require.Equal(t, cid, p.CID())
|
||||
}
|
||||
|
||||
func TestGetResult(t *testing.T) {
|
||||
r := new(GetResult)
|
||||
|
||||
cnr := &Container{
|
||||
OwnerID: OwnerID{1, 2, 3},
|
||||
}
|
||||
r.SetContainer(cnr)
|
||||
|
||||
require.Equal(t, cnr, r.Container())
|
||||
}
|
||||
|
||||
func TestPutParams(t *testing.T) {
|
||||
p := new(PutParams)
|
||||
|
||||
cnr := &Container{
|
||||
OwnerID: OwnerID{1, 2, 3},
|
||||
}
|
||||
p.SetContainer(cnr)
|
||||
|
||||
require.Equal(t, cnr, p.Container())
|
||||
}
|
||||
|
||||
func TestPutResult(t *testing.T) {
|
||||
r := new(PutResult)
|
||||
|
||||
cid := CID{1, 2, 3}
|
||||
r.SetCID(cid)
|
||||
|
||||
require.Equal(t, cid, r.CID())
|
||||
}
|
||||
|
||||
func TestDeleteParams(t *testing.T) {
|
||||
p := new(DeleteParams)
|
||||
|
||||
ownerID := OwnerID{1, 2, 3}
|
||||
p.SetOwnerID(ownerID)
|
||||
require.Equal(t, ownerID, p.OwnerID())
|
||||
|
||||
cid := CID{4, 5, 6}
|
||||
p.SetCID(cid)
|
||||
require.Equal(t, cid, p.CID())
|
||||
}
|
||||
|
||||
func TestListParams(t *testing.T) {
|
||||
p := new(ListParams)
|
||||
|
||||
ownerIDList := []OwnerID{
|
||||
{1, 2, 3},
|
||||
{4, 5, 6},
|
||||
}
|
||||
p.SetOwnerIDList(ownerIDList...)
|
||||
|
||||
require.Equal(t, ownerIDList, p.OwnerIDList())
|
||||
}
|
||||
|
||||
func TestListResult(t *testing.T) {
|
||||
r := new(ListResult)
|
||||
|
||||
cidList := []CID{
|
||||
{1, 2, 3},
|
||||
{4, 5, 6},
|
||||
}
|
||||
r.SetCIDList(cidList)
|
||||
|
||||
require.Equal(t, cidList, r.CIDList())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue