[#121] client: Make client parameter fields public #127
2 changed files with 24 additions and 13 deletions
|
@ -30,7 +30,7 @@ type PrmContainerPut struct {
|
|||
// SetContainer sets structured information about new FrostFS container.
|
||||
// Required parameter.
|
||||
//
|
||||
// NOTE: method is deprecated
|
||||
// Deprecated: Use PrmContainerPut.Container instead.
|
||||
func (x *PrmContainerPut) SetContainer(cnr container.Container) {
|
||||
x.Container = &cnr
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ func (x *PrmContainerPut) SetContainer(cnr container.Container) {
|
|||
// - session operation MUST be session.VerbContainerPut (ForVerb)
|
||||
// - token MUST be signed using private key of the owner of the container to be saved
|
||||
//
|
||||
// NOTE: method is deprecated
|
||||
// Deprecated: Use PrmContainerPut.Session instead.
|
||||
fyrchik marked this conversation as resolved
Outdated
fyrchik
commented
We already have somewhat common syntax: We already have somewhat common syntax: `// Deprecated: use XXX instead.` (see `.pb.go` files for example). I am not sure this^ pattern will be picked by `staticcheck`.
aarifullin
commented
Good! Thank you Good! Thank you
|
||||
func (x *PrmContainerPut) WithinSession(s session.Container) {
|
||||
x.Session = &s
|
||||
}
|
||||
|
|
33
pool/pool.go
33
pool/pool.go
|
@ -407,7 +407,7 @@ func (c *clientWrapper) containerPut(ctx context.Context, prm PrmContainerPut) (
|
|||
}
|
||||
|
||||
start := time.Now()
|
||||
res, err := cl.ContainerPut(ctx, prm.prmClient)
|
||||
res, err := cl.ContainerPut(ctx, prm.ClientParams)
|
||||
c.incRequests(time.Since(start), methodContainerPut)
|
||||
var st apistatus.Status
|
||||
if res != nil {
|
||||
|
@ -417,13 +417,13 @@ func (c *clientWrapper) containerPut(ctx context.Context, prm PrmContainerPut) (
|
|||
return cid.ID{}, fmt.Errorf("container put on client: %w", err)
|
||||
}
|
||||
|
||||
if !prm.waitParamsSet {
|
||||
prm.waitParams.setDefaults()
|
||||
if prm.WaitParams == nil {
|
||||
prm.WaitParams = defaultWaitParams()
|
||||
}
|
||||
|
||||
idCnr := res.ID()
|
||||
|
||||
err = waitForContainerPresence(ctx, c, idCnr, &prm.waitParams)
|
||||
err = waitForContainerPresence(ctx, c, idCnr, prm.WaitParams)
|
||||
if err = c.handleError(ctx, nil, err); err != nil {
|
||||
return cid.ID{}, fmt.Errorf("wait container presence on client: %w", err)
|
||||
}
|
||||
|
@ -1221,6 +1221,13 @@ func (x *WaitParams) setDefaults() {
|
|||
x.pollInterval = 5 * time.Second
|
||||
}
|
||||
|
||||
func defaultWaitParams() *WaitParams {
|
||||
dkirillov marked this conversation as resolved
Outdated
dkirillov
commented
Do we need this function to be exported? Do we need this function to be exported?
aarifullin
commented
Good point Good point
|
||||
return &WaitParams{
|
||||
timeout: 120 * time.Second,
|
||||
pollInterval: 5 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
// checkForPositive panics if any of the wait params isn't positive.
|
||||
func (x *WaitParams) checkForPositive() {
|
||||
if x.timeout <= 0 || x.pollInterval <= 0 {
|
||||
|
@ -1400,35 +1407,39 @@ func (x *PrmObjectSearch) SetFilters(filters object.SearchFilters) {
|
|||
|
||||
// PrmContainerPut groups parameters of PutContainer operation.
|
||||
type PrmContainerPut struct {
|
||||
prmClient sdkClient.PrmContainerPut
|
||||
ClientParams sdkClient.PrmContainerPut
|
||||
dkirillov marked this conversation as resolved
Outdated
dkirillov
commented
Maybe it's better to name it Maybe it's better to name it `ClientPrm` or `ClientParams`?
aarifullin
commented
Fixed Fixed
|
||||
|
||||
waitParams WaitParams
|
||||
waitParamsSet bool
|
||||
WaitParams *WaitParams
|
||||
}
|
||||
|
||||
// SetContainer container structure to be used as a parameter of the base
|
||||
// client's operation.
|
||||
//
|
||||
// See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerPut.SetContainer.
|
||||
//
|
||||
// Deprecated: Use PrmContainerPut.ClientParams.Container instead.
|
||||
func (x *PrmContainerPut) SetContainer(cnr container.Container) {
|
||||
x.prmClient.SetContainer(cnr)
|
||||
x.ClientParams.SetContainer(cnr)
|
||||
}
|
||||
|
||||
// WithinSession specifies session to be used as a parameter of the base
|
||||
// client's operation.
|
||||
//
|
||||
// See git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client.PrmContainerPut.WithinSession.
|
||||
//
|
||||
// Deprecated: Use PrmContainerPut.ClientParams.Session instead.
|
||||
func (x *PrmContainerPut) WithinSession(s session.Container) {
|
||||
x.prmClient.WithinSession(s)
|
||||
x.ClientParams.WithinSession(s)
|
||||
}
|
||||
|
||||
// SetWaitParams specifies timeout params to complete operation.
|
||||
// If not provided the default one will be used.
|
||||
// Panics if any of the wait params isn't positive.
|
||||
//
|
||||
// Deprecated: Use PrmContainerPut.ClientParams.WaitParams instead.
|
||||
func (x *PrmContainerPut) SetWaitParams(waitParams WaitParams) {
|
||||
waitParams.checkForPositive()
|
||||
x.waitParams = waitParams
|
||||
x.waitParamsSet = true
|
||||
x.WaitParams = &waitParams
|
||||
}
|
||||
|
||||
// PrmContainerGet groups parameters of GetContainer operation.
|
||||
|
|
Loading…
Reference in a new issue
I used pointer type for both
Container
andSession
to avoidcnrSet
,sessionSet
flags because this may cause errors