2021-01-28 11:39:08 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
2021-05-18 08:12:51 +00:00
|
|
|
"fmt"
|
2021-11-09 20:52:29 +00:00
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
2021-01-28 11:39:08 +00:00
|
|
|
)
|
|
|
|
|
2022-01-31 13:34:01 +00:00
|
|
|
// StartEstimationPrm groups parameters of StartEstimation operation.
|
|
|
|
type StartEstimationPrm struct {
|
|
|
|
commonEstimationPrm
|
2021-01-28 11:39:08 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:34:01 +00:00
|
|
|
// StopEstimationPrm groups parameters of StopEstimation operation.
|
|
|
|
type StopEstimationPrm struct {
|
|
|
|
commonEstimationPrm
|
2021-01-28 11:39:08 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:34:01 +00:00
|
|
|
type commonEstimationPrm struct {
|
|
|
|
epoch uint64
|
2021-11-12 15:14:55 +00:00
|
|
|
|
|
|
|
client.InvokePrmOptional
|
2021-01-28 11:39:08 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:34:01 +00:00
|
|
|
// SetEpoch sets epoch.
|
|
|
|
func (p *commonEstimationPrm) SetEpoch(epoch uint64) {
|
|
|
|
p.epoch = epoch
|
2021-01-28 11:39:08 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:34:01 +00:00
|
|
|
// StartEstimation votes to produce start estimation notification.
|
|
|
|
func (c *Client) StartEstimation(p StartEstimationPrm) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
2022-01-29 13:06:36 +00:00
|
|
|
prm.SetMethod(startEstimationMethod)
|
2022-03-11 09:28:34 +00:00
|
|
|
prm.SetArgs(p.epoch)
|
2022-01-31 13:34:01 +00:00
|
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
2023-11-07 15:13:26 +00:00
|
|
|
if _, err := c.client.Invoke(prm); err != nil {
|
2022-01-29 13:06:36 +00:00
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", startEstimationMethod, err)
|
2021-05-18 08:12:51 +00:00
|
|
|
}
|
|
|
|
return nil
|
2021-04-29 13:35:26 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 13:34:01 +00:00
|
|
|
// StopEstimation votes to produce stop estimation notification.
|
|
|
|
func (c *Client) StopEstimation(p StopEstimationPrm) error {
|
2021-11-09 20:52:29 +00:00
|
|
|
prm := client.InvokePrm{}
|
2022-01-29 13:06:36 +00:00
|
|
|
prm.SetMethod(stopEstimationMethod)
|
2022-03-11 09:28:34 +00:00
|
|
|
prm.SetArgs(p.epoch)
|
2022-01-31 13:34:01 +00:00
|
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
2021-11-09 20:52:29 +00:00
|
|
|
|
2023-11-07 15:13:26 +00:00
|
|
|
if _, err := c.client.Invoke(prm); err != nil {
|
2022-01-29 13:06:36 +00:00
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", stopEstimationMethod, err)
|
2021-05-18 08:12:51 +00:00
|
|
|
}
|
|
|
|
return nil
|
2021-04-29 13:35:26 +00:00
|
|
|
}
|