[#607] object/put: Make client constructor to work with group address

Make Object Put service to work with `AddressGroup` instead of `Address` in
order to support multiple addresses of the storage node.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-22 14:12:57 +03:00 committed by Leonard Lyubich
parent 6e5d7f84af
commit 8972f84672
8 changed files with 89 additions and 49 deletions

View file

@ -158,6 +158,17 @@ func (x *coreClientConstructor) Get(addr network.Address) (coreclient.Client, er
return c.(coreclient.Client), nil
}
type addressGroupClientConstructor coreClientConstructor
func (x *addressGroupClientConstructor) Get(addrGroup network.AddressGroup) (c coreclient.Client, err error) {
addrGroup.IterateAddresses(func(addr network.Address) bool {
c, err = (*coreClientConstructor)(x).Get(addr)
return true
})
return
}
func initObjectService(c *cfg) {
ls := c.cfgObject.cfgLocalStorage.localStorage
keyStorage := util.NewKeyStorage(&c.key.PrivateKey, c.privateTokenStore)
@ -183,6 +194,8 @@ func initObjectService(c *cfg) {
coreConstructor := (*coreClientConstructor)(clientConstructor)
groupConstructor := (*addressGroupClientConstructor)(coreConstructor)
irFetcher := &innerRingFetcher{
sidechain: c.cfgMorph.client,
}
@ -199,7 +212,7 @@ func initObjectService(c *cfg) {
),
replicator.WithLocalStorage(ls),
replicator.WithRemoteSender(
putsvc.NewRemoteSender(keyStorage, coreConstructor),
putsvc.NewRemoteSender(keyStorage, groupConstructor),
),
)
@ -251,7 +264,7 @@ func initObjectService(c *cfg) {
sPut := putsvc.NewService(
putsvc.WithKeyStorage(keyStorage),
putsvc.WithClientConstructor(coreConstructor),
putsvc.WithClientConstructor(groupConstructor),
putsvc.WithMaxSizeSource(c),
putsvc.WithLocalStorage(ls),
putsvc.WithContainerSource(c.cfgObject.cnrStorage),