Skip to content

Commit 309bf13

Browse files
authored
rename SaveStateItems() to SaveBulkState(); rename GetStateItems() to GetBulkState(); (#105)
1 parent c49c3f1 commit 309bf13

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

client/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ type Client interface {
5454
// SaveState saves the raw data into store using default state options.
5555
SaveState(ctx context.Context, store, key string, data []byte) error
5656

57-
// SaveStateItems saves multiple state item to store with specified options.
58-
SaveStateItems(ctx context.Context, store string, items ...*SetStateItem) error
57+
// SaveBulkState saves multiple state item to store with specified options.
58+
SaveBulkState(ctx context.Context, store string, items ...*SetStateItem) error
5959

60-
// GetState retreaves state from specific store using default consistency option.
60+
// GetState retrieves state from specific store using default consistency option.
6161
GetState(ctx context.Context, store, key string) (item *StateItem, err error)
6262

63-
// GetStateWithConsistency retreaves state from specific store using provided state consistency.
63+
// GetStateWithConsistency retrieves state from specific store using provided state consistency.
6464
GetStateWithConsistency(ctx context.Context, store, key string, meta map[string]string, sc StateConsistency) (item *StateItem, err error)
6565

66-
// GetBulkItems retreaves state for multiple keys from specific store.
67-
GetBulkItems(ctx context.Context, store string, keys []string, parallelism int32) ([]*StateItem, error)
66+
// GetBulkState retrieves state for multiple keys from specific store.
67+
GetBulkState(ctx context.Context, store string, keys []string, parallelism int32) ([]*StateItem, error)
6868

6969
// DeleteState deletes content from store using default state options.
7070
DeleteState(ctx context.Context, store, key string) error

client/state.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ func (c *GRPCClient) ExecuteStateTransaction(ctx context.Context, store string,
184184
// SaveState saves the raw data into store using default state options.
185185
func (c *GRPCClient) SaveState(ctx context.Context, store, key string, data []byte) error {
186186
item := &SetStateItem{Key: key, Value: data}
187-
return c.SaveStateItems(ctx, store, item)
187+
return c.SaveBulkState(ctx, store, item)
188188
}
189189

190190
// SaveStateItems saves the multiple state item to store.
191-
func (c *GRPCClient) SaveStateItems(ctx context.Context, store string, items ...*SetStateItem) error {
191+
func (c *GRPCClient) SaveBulkState(ctx context.Context, store string, items ...*SetStateItem) error {
192192
if store == "" {
193193
return errors.New("nil store")
194194
}
@@ -215,7 +215,7 @@ func (c *GRPCClient) SaveStateItems(ctx context.Context, store string, items ...
215215
}
216216

217217
// GetBulkItems retreaves state for multiple keys from specific store.
218-
func (c *GRPCClient) GetBulkItems(ctx context.Context, store string, keys []string, parallelism int32) ([]*StateItem, error) {
218+
func (c *GRPCClient) GetBulkState(ctx context.Context, store string, keys []string, parallelism int32) ([]*StateItem, error) {
219219
if store == "" {
220220
return nil, errors.New("nil store")
221221
}

client/state_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestSaveState(t *testing.T) {
7272
Key: key,
7373
Value: []byte(data),
7474
}
75-
err := testClient.SaveStateItems(ctx, store, item)
75+
err := testClient.SaveBulkState(ctx, store, item)
7676
assert.Nil(t, err)
7777
})
7878

@@ -126,7 +126,7 @@ func TestDeleteState(t *testing.T) {
126126
})
127127

128128
t.Run("save data again with etag, meta", func(t *testing.T) {
129-
err := testClient.SaveStateItems(ctx, store, &SetStateItem{
129+
err := testClient.SaveBulkState(ctx, store, &SetStateItem{
130130
Key: key,
131131
Value: []byte(data),
132132
Etag: "100",
@@ -185,7 +185,7 @@ func TestStateTransactions(t *testing.T) {
185185
})
186186

187187
t.Run("exec upserts", func(t *testing.T) {
188-
items, err := testClient.GetBulkItems(ctx, store, keys, 10)
188+
items, err := testClient.GetBulkState(ctx, store, keys, 10)
189189
assert.Nil(t, err)
190190
assert.NotNil(t, items)
191191
assert.Len(t, items, len(keys))
@@ -207,7 +207,7 @@ func TestStateTransactions(t *testing.T) {
207207
})
208208

209209
t.Run("get and validate inserts", func(t *testing.T) {
210-
items, err := testClient.GetBulkItems(ctx, store, keys, 10)
210+
items, err := testClient.GetBulkState(ctx, store, keys, 10)
211211
assert.Nil(t, err)
212212
assert.NotNil(t, items)
213213
assert.Len(t, items, len(keys))
@@ -224,7 +224,7 @@ func TestStateTransactions(t *testing.T) {
224224
})
225225

226226
t.Run("ensure deletes", func(t *testing.T) {
227-
items, err := testClient.GetBulkItems(ctx, store, keys, 3)
227+
items, err := testClient.GetBulkState(ctx, store, keys, 3)
228228
assert.Nil(t, err)
229229
assert.NotNil(t, items)
230230
assert.Len(t, items, 0)

example/client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555
Consistency: dapr.StateConsistencyStrong,
5656
},
5757
}
58-
if err := client.SaveStateItems(ctx, store, item2); err != nil {
58+
if err := client.SaveBulkState(ctx, store, item2); err != nil {
5959
panic(err)
6060
}
6161
fmt.Println("data item saved")

0 commit comments

Comments
 (0)