forked from TrueCloudLab/frostfs-node
[#1101] *: Adopt interface changes of API client from SDK library
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
674f520da7
commit
4f3323f084
14 changed files with 94 additions and 246 deletions
|
@ -301,6 +301,7 @@ func initCfg(path string) *cfg {
|
|||
},
|
||||
clientCache: cache.NewSDKClientCache(
|
||||
apiclient.WithDialTimeout(apiclientconfig.DialTimeout(appCfg)),
|
||||
apiclient.WithDefaultPrivateKey(&key.PrivateKey),
|
||||
),
|
||||
persistate: persistate,
|
||||
|
||||
|
|
|
@ -279,20 +279,17 @@ func (r *remoteLoadAnnounceProvider) InitRemote(srv loadroute.ServerInfo) (loadc
|
|||
|
||||
return &remoteLoadAnnounceWriterProvider{
|
||||
client: c,
|
||||
key: r.key,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type remoteLoadAnnounceWriterProvider struct {
|
||||
client client.Client
|
||||
key *ecdsa.PrivateKey
|
||||
}
|
||||
|
||||
func (p *remoteLoadAnnounceWriterProvider) InitWriter(ctx context.Context) (loadcontroller.Writer, error) {
|
||||
return &remoteLoadAnnounceWriter{
|
||||
ctx: ctx,
|
||||
client: p.client,
|
||||
key: p.key,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -300,7 +297,6 @@ type remoteLoadAnnounceWriter struct {
|
|||
ctx context.Context
|
||||
|
||||
client client.Client
|
||||
key *ecdsa.PrivateKey
|
||||
|
||||
buf []containerSDK.UsedSpaceAnnouncement
|
||||
}
|
||||
|
@ -312,7 +308,11 @@ func (r *remoteLoadAnnounceWriter) Put(a containerSDK.UsedSpaceAnnouncement) err
|
|||
}
|
||||
|
||||
func (r *remoteLoadAnnounceWriter) Close() error {
|
||||
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, r.buf, apiClient.WithKey(r.key))
|
||||
var cliPrm apiClient.AnnounceSpacePrm
|
||||
|
||||
cliPrm.SetValues(r.buf)
|
||||
|
||||
_, err := r.client.AnnounceContainerUsedSpace(r.ctx, cliPrm)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
|||
p.SetPrivateKey(rtp.key)
|
||||
p.SetEpoch(rtp.eiCtx.Epoch())
|
||||
p.SetIteration(rtp.eiCtx.I())
|
||||
p.SetTrust(apiPeerToPeerTrust)
|
||||
p.SetTrust(*apiPeerToPeerTrust)
|
||||
|
||||
_, err := internalclient.AnnounceIntermediate(p)
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ func (x *AnnounceLocalPrm) SetEpoch(epoch uint64) {
|
|||
}
|
||||
|
||||
// SetTrusts sets list of local trust values.
|
||||
func (x *AnnounceLocalPrm) SetTrusts(ts []*reputation.Trust) {
|
||||
x.cliPrm.SetTrusts(ts)
|
||||
func (x *AnnounceLocalPrm) SetTrusts(ts []reputation.Trust) {
|
||||
x.cliPrm.SetValues(ts)
|
||||
}
|
||||
|
||||
// AnnounceLocalRes groups resulting values of AnnounceLocal operation.
|
||||
|
@ -67,7 +67,7 @@ type AnnounceLocalRes struct{}
|
|||
func AnnounceLocal(prm AnnounceLocalPrm) (res AnnounceLocalRes, err error) {
|
||||
var cliRes *client.AnnounceLocalTrustRes
|
||||
|
||||
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
||||
cliRes, err = prm.cli.AnnounceLocalTrust(prm.ctx, prm.cliPrm)
|
||||
if err == nil {
|
||||
// pull out an error from status
|
||||
err = apistatus.ErrFromStatus(cliRes.Status())
|
||||
|
@ -94,8 +94,8 @@ func (x *AnnounceIntermediatePrm) SetIteration(iter uint32) {
|
|||
}
|
||||
|
||||
// SetTrust sets current global trust value computed at the iteration.
|
||||
func (x *AnnounceIntermediatePrm) SetTrust(t *reputation.PeerToPeerTrust) {
|
||||
x.cliPrm.SetTrust(t)
|
||||
func (x *AnnounceIntermediatePrm) SetTrust(t reputation.PeerToPeerTrust) {
|
||||
x.cliPrm.SetCurrentValue(t)
|
||||
}
|
||||
|
||||
// AnnounceIntermediateRes groups resulting values of AnnounceIntermediate operation.
|
||||
|
@ -110,7 +110,7 @@ type AnnounceIntermediateRes struct{}
|
|||
func AnnounceIntermediate(prm AnnounceIntermediatePrm) (res AnnounceIntermediateRes, err error) {
|
||||
var cliRes *client.AnnounceIntermediateTrustRes
|
||||
|
||||
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm, prm.opts...)
|
||||
cliRes, err = prm.cli.AnnounceIntermediateTrust(prm.ctx, prm.cliPrm)
|
||||
if err == nil {
|
||||
// pull out an error from status
|
||||
err = apistatus.ErrFromStatus(cliRes.Status())
|
||||
|
|
|
@ -67,7 +67,7 @@ type RemoteTrustWriter struct {
|
|||
client coreclient.Client
|
||||
key *ecdsa.PrivateKey
|
||||
|
||||
buf []*reputationapi.Trust
|
||||
buf []reputationapi.Trust
|
||||
}
|
||||
|
||||
func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
||||
|
@ -79,7 +79,7 @@ func (rtp *RemoteTrustWriter) Write(t reputation.Trust) error {
|
|||
apiTrust.SetValue(t.Value().Float64())
|
||||
apiTrust.SetPeer(apiPeer)
|
||||
|
||||
rtp.buf = append(rtp.buf, apiTrust)
|
||||
rtp.buf = append(rtp.buf, *apiTrust)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue