forked from TrueCloudLab/frostfs-s3-gw
cd64f41ce8
Make `tokens`, `authmate` and `layer` packages to depend from locally defined `NeoFS` interface of the virtual connection to NeoFS network. Create internal `neofs` package and implement these interfaces through `pool.Pool` there. Implement mediators between `NeoFS` interfaces and `neofs.NeoFS` implementation. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/nspcc-dev/neofs-s3-gw/api/layer"
|
|
"github.com/nspcc-dev/neofs-s3-gw/internal/neofs"
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
)
|
|
|
|
// mediator which implements layer.NeoFS through neofs.NeoFS.
|
|
type layerNeoFS struct {
|
|
*neofs.NeoFS
|
|
}
|
|
|
|
func (x *layerNeoFS) CreateContainer(ctx context.Context, prm layer.PrmContainerCreate) (*cid.ID, error) {
|
|
return x.NeoFS.CreateContainer(ctx, neofs.PrmContainerCreate{
|
|
Creator: prm.Creator,
|
|
Policy: prm.Policy,
|
|
Name: prm.Name,
|
|
Time: prm.Time,
|
|
BasicACL: prm.BasicACL,
|
|
SessionToken: prm.SessionToken,
|
|
LocationConstraintAttribute: prm.LocationConstraintAttribute,
|
|
})
|
|
}
|
|
|
|
func (x *layerNeoFS) CreateObject(ctx context.Context, prm layer.PrmObjectCreate) (*oid.ID, error) {
|
|
return x.NeoFS.CreateObject(ctx, neofs.PrmObjectCreate{
|
|
Creator: prm.Creator,
|
|
Container: prm.Container,
|
|
Time: time.Now().UTC(),
|
|
Filename: prm.Filename,
|
|
PayloadSize: prm.PayloadSize,
|
|
Attributes: prm.Attributes,
|
|
Payload: prm.Payload,
|
|
BearerToken: prm.BearerToken,
|
|
PrivateKey: prm.PrivateKey,
|
|
})
|
|
}
|