change translateFieldKeys to variadic function

This commit is contained in:
Travis 2020-03-05 15:38:34 -06:00
parent d06ffd207f
commit 3e4f7dd3f3
2 changed files with 4 additions and 4 deletions

4
api.go
View file

@ -966,7 +966,7 @@ func (api *API) Import(ctx context.Context, req *ImportRequest, opts ...ImportOp
if len(req.RowIDs) != 0 {
return errors.New("row ids cannot be used because field uses string keys")
}
if req.RowIDs, err = api.cluster.translateFieldKeys(ctx, field, req.RowKeys); err != nil {
if req.RowIDs, err = api.cluster.translateFieldKeys(ctx, field, req.RowKeys...); err != nil {
return errors.Wrapf(err, "translating field keys")
}
}
@ -1479,7 +1479,7 @@ func (api *API) TranslateKeys(ctx context.Context, r io.Reader) (_ []byte, err e
if err != nil {
return nil, err
}
} else if ids, err = api.cluster.translateFieldKeys(ctx, field, req.Keys); err != nil {
} else if ids, err = api.cluster.translateFieldKeys(ctx, field, req.Keys...); err != nil {
return nil, errors.Wrapf(err, "translating field keys")
}
}

View file

@ -2087,7 +2087,7 @@ func (c *cluster) setStatic(hosts []string) error {
// translateFieldKey gets a single key from translateFieldKeys.
func (c *cluster) translateFieldKey(ctx context.Context, field *Field, key string) (uint64, error) {
ids, err := c.translateFieldKeys(ctx, field, []string{key})
ids, err := c.translateFieldKeys(ctx, field, key)
if err != nil {
return 0, err
} else if len(ids) == 0 {
@ -2102,7 +2102,7 @@ func (c *cluster) translateFieldKey(ctx context.Context, field *Field, key strin
// is read-only (i.e. it's not the primary translate
// store), then this method will forward the translation
// request to the coordinator.
func (c *cluster) translateFieldKeys(ctx context.Context, field *Field, keys []string) ([]uint64, error) {
func (c *cluster) translateFieldKeys(ctx context.Context, field *Field, keys ...string) ([]uint64, error) {
ids, err := field.TranslateStore().TranslateKeys(keys)
// If we get a "read only" error, then forward the request
// to the coordinator.