[#907] morph/container: Add native name and zone to PutArgs

Add `PutArgs.SetNativeNameWithZone` method which sets native name and zone
for container. Call `putNamed` method of Container contract if name is set,
otherwise call `put` method.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-10-12 17:46:45 +03:00 committed by Alex Vanin
parent 36c5e4c527
commit 7db47c88bf
2 changed files with 57 additions and 9 deletions

View file

@ -29,6 +29,7 @@ type Option func(*cfg)
type cfg struct {
putMethod, // put container method name for invocation
putNamedMethod, // put named container method name for invocation
putSizeMethod, // put container size method name for invocation
listSizesMethod, // list container sizes method name for invocation
getSizeMethod, // get container size method name for invocation
@ -55,6 +56,8 @@ const (
defaultPutSizeMethod = "putContainerSize" // default "put container size" method name
defaultListSizesMethod = "listContainerSizes" // default "list container sizes" method name
defaultGetSizeMethod = "getContainerSize" // default "get container size" method name
defaultPutNamedMethod = "putNamed" // default put named container method name
)
func defaultConfig() *cfg {
@ -71,6 +74,8 @@ func defaultConfig() *cfg {
putSizeMethod: defaultPutSizeMethod,
listSizesMethod: defaultListSizesMethod,
getSizeMethod: defaultGetSizeMethod,
putNamedMethod: defaultPutNamedMethod,
}
}
@ -270,3 +275,17 @@ func WithGetSizeMethod(n string) Option {
}
}
}
// WithPutNamedMethod returns a client constructor option that
// specifies the method name of "put named container" operation.
//
// Ignores empty value.
//
// If option not provided, "putNamed" is used.
func WithPutNamedMethod(n string) Option {
return func(c *cfg) {
if n != "" {
c.putNamedMethod = n
}
}
}