feat: add scroll / iteration helpers
This commit is contained in:
parent
7d1910919c
commit
6eb7e62a0c
6 changed files with 196 additions and 11 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"net/url"
|
||||
)
|
||||
|
||||
type ReadBatchSearch struct {
|
||||
type BatchSearch struct {
|
||||
PartitionKey string `json:"partitionKey"`
|
||||
|
||||
// Prefix restricts listing to partition keys that start with this value.
|
||||
|
@ -59,7 +59,7 @@ type SearchResultItem struct {
|
|||
Values []Item `json:"v"`
|
||||
}
|
||||
|
||||
func (c *Client) ReadBatch(ctx context.Context, b Bucket, q []ReadBatchSearch) ([]BatchSearchResult, error) {
|
||||
func (c *Client) ReadBatch(ctx context.Context, b Bucket, q []BatchSearch) ([]*BatchSearchResult, error) {
|
||||
u, err := url.Parse(c.endpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -91,7 +91,7 @@ func (c *Client) ReadBatch(ctx context.Context, b Bucket, q []ReadBatchSearch) (
|
|||
return nil, fmt.Errorf("http status code %d: %s", resp.StatusCode, body)
|
||||
}
|
||||
|
||||
var items []BatchSearchResult
|
||||
var items []*BatchSearchResult
|
||||
if err := json.Unmarshal(body, &items); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -112,9 +112,9 @@ type BulkGetItem struct {
|
|||
}
|
||||
|
||||
func BulkGet(ctx context.Context, cli *Client, b Bucket, keys []ItemKey) ([]BulkGetItem, error) {
|
||||
q := make([]ReadBatchSearch, len(keys))
|
||||
q := make([]BatchSearch, len(keys))
|
||||
for i := range keys {
|
||||
q[i] = ReadBatchSearch{
|
||||
q[i] = BatchSearch{
|
||||
PartitionKey: keys[i].PartitionKey,
|
||||
Start: keys[i].SortKey,
|
||||
SingleItem: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue