[#355] moprh/client: Add start/stop container estimation methods
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7a7a351f1f
commit
70aa73cbd2
4 changed files with 101 additions and 9 deletions
|
@ -15,8 +15,7 @@ var errUnsupported = errors.New("unsupported structure version")
|
||||||
// PutAuditResult saves passed audit result structure in NeoFS system
|
// PutAuditResult saves passed audit result structure in NeoFS system
|
||||||
// through Audit contract call.
|
// through Audit contract call.
|
||||||
//
|
//
|
||||||
// Returns calculated container identifier and any error
|
// Returns encountered error that caused the saving to interrupt.
|
||||||
// encountered that caused the saving to interrupt.
|
|
||||||
func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error {
|
func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error {
|
||||||
rawResult, err := result.Marshal()
|
rawResult, err := result.Marshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -33,7 +33,9 @@ type cfg struct {
|
||||||
getMethod, // get container method name for invocation
|
getMethod, // get container method name for invocation
|
||||||
listMethod, // list container method name for invocation
|
listMethod, // list container method name for invocation
|
||||||
setEACLMethod, // set eACL method name for invocation
|
setEACLMethod, // set eACL method name for invocation
|
||||||
eaclMethod string // get eACL method name for invocation
|
eaclMethod, // get eACL method name for invocation
|
||||||
|
startEstimation,
|
||||||
|
stopEstimation string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -43,16 +45,21 @@ const (
|
||||||
defaultListMethod = "list" // default list containers method name
|
defaultListMethod = "list" // default list containers method name
|
||||||
defaultEACLMethod = "eACL" // default get eACL method name
|
defaultEACLMethod = "eACL" // default get eACL method name
|
||||||
defaultSetEACLMethod = "setEACL" // default set eACL method name
|
defaultSetEACLMethod = "setEACL" // default set eACL method name
|
||||||
|
|
||||||
|
defaultStartEstimation = "startContainerEstimation"
|
||||||
|
defaultStopEstimation = "stopContainerEstimation"
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultConfig() *cfg {
|
func defaultConfig() *cfg {
|
||||||
return &cfg{
|
return &cfg{
|
||||||
putMethod: defaultPutMethod,
|
putMethod: defaultPutMethod,
|
||||||
deleteMethod: defaultDeleteMethod,
|
deleteMethod: defaultDeleteMethod,
|
||||||
getMethod: defaultGetMethod,
|
getMethod: defaultGetMethod,
|
||||||
listMethod: defaultListMethod,
|
listMethod: defaultListMethod,
|
||||||
setEACLMethod: defaultSetEACLMethod,
|
setEACLMethod: defaultSetEACLMethod,
|
||||||
eaclMethod: defaultEACLMethod,
|
eaclMethod: defaultEACLMethod,
|
||||||
|
startEstimation: defaultStartEstimation,
|
||||||
|
stopEstimation: defaultStopEstimation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +74,8 @@ func defaultConfig() *cfg {
|
||||||
// * list containers method name: List;
|
// * list containers method name: List;
|
||||||
// * set eACL method name: SetEACL;
|
// * set eACL method name: SetEACL;
|
||||||
// * get eACL method name: EACL.
|
// * get eACL method name: EACL.
|
||||||
|
// * start estimation method name: startContainerEstimation
|
||||||
|
// * stop estimation method name: stopContainerEstimation
|
||||||
//
|
//
|
||||||
// If desired option satisfies the default value, it can be omitted.
|
// If desired option satisfies the default value, it can be omitted.
|
||||||
// If multiple options of the same config value are supplied,
|
// If multiple options of the same config value are supplied,
|
||||||
|
@ -172,3 +181,31 @@ func WithEACLMethod(n string) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithStartEstimationMethod returns a client constructor option that
|
||||||
|
// specifies the method name of vote to start container size estimation.
|
||||||
|
//
|
||||||
|
// Ignores empty value.
|
||||||
|
//
|
||||||
|
// If option not provided, "startContainerEstimation" is used.
|
||||||
|
func WithStartEstimationMethod(n string) Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
if n != "" {
|
||||||
|
c.startEstimation = n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithStopEstimationMethod returns a client constructor option that
|
||||||
|
// specifies the method name of vote to stop container size estimation.
|
||||||
|
//
|
||||||
|
// Ignores empty value.
|
||||||
|
//
|
||||||
|
// If option not provided, "stopContainerEstimation" is used.
|
||||||
|
func WithStopEstimationMethod(n string) Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
if n != "" {
|
||||||
|
c.stopEstimation = n
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
35
pkg/morph/client/container/estimations.go
Normal file
35
pkg/morph/client/container/estimations.go
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package container
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type StartEstimation struct {
|
||||||
|
epoch int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *StartEstimation) SetEpoch(v int64) {
|
||||||
|
e.epoch = v
|
||||||
|
}
|
||||||
|
|
||||||
|
type StopEstimation struct {
|
||||||
|
epoch int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *StopEstimation) SetEpoch(v int64) {
|
||||||
|
e.epoch = v
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) StartEstimation(args StartEstimation) error {
|
||||||
|
return errors.Wrapf(c.client.Invoke(
|
||||||
|
c.startEstimation,
|
||||||
|
args.epoch,
|
||||||
|
), "could not invoke method (%s)", c.startEstimation)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) StopEstimation(args StopEstimation) error {
|
||||||
|
return errors.Wrapf(c.client.Invoke(
|
||||||
|
c.stopEstimation,
|
||||||
|
args.epoch,
|
||||||
|
), "could not invoke method (%s)", c.stopEstimation)
|
||||||
|
}
|
21
pkg/morph/client/container/wrapper/estimations.go
Normal file
21
pkg/morph/client/container/wrapper/estimations.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package wrapper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StartEstimation votes to produce start estimation notification.
|
||||||
|
func (w *Wrapper) StartEstimation(epoch uint64) error {
|
||||||
|
args := container.StartEstimation{}
|
||||||
|
args.SetEpoch(int64(epoch))
|
||||||
|
|
||||||
|
return w.client.StartEstimation(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopEstimation votes to produce stop estimation notification.
|
||||||
|
func (w *Wrapper) StopEstimation(epoch uint64) error {
|
||||||
|
args := container.StopEstimation{}
|
||||||
|
args.SetEpoch(int64(epoch))
|
||||||
|
|
||||||
|
return w.client.StopEstimation(args)
|
||||||
|
}
|
Loading…
Reference in a new issue