Use metadata at top level instead of per request
@@ -8,7 +8,6 @@ package cosmosdb
import (
"bytes"
"encoding/json"
- "errors"
"fmt"
"strings"
@@ -154,7 +153,6 @@ func (c *StateStore) Get(req *state.GetRequest) (*state.GetResponse, error) {
key := req.Key
partitionKey := populatePartitionMetadata(req.Key, req.Metadata)
-
items := []CosmosItem{}
options := []documentdb.CallOption{documentdb.PartitionKey(partitionKey)}
if req.Options.Consistency == state.Strong {
@@ -299,20 +297,12 @@ func (c *StateStore) Multi(request *state.TransactionalStateRequest) error {
deletes := []CosmosItem{}
partitionKey := unknownPartitionKey
- previousPartitionKey := unknownPartitionKey
for _, o := range request.Operations {
t := o.Request.(state.KeyInt)
key := t.GetKey()
- metadata := t.GetMetadata()
-
- partitionKey = populatePartitionMetadata(key, metadata)
- if previousPartitionKey != unknownPartitionKey &&
- partitionKey != previousPartitionKey {
- return errors.New("all objects used in Multi() must have the same partition key")
- }
- previousPartitionKey = partitionKey
+ partitionKey = populatePartitionMetadata(key, request.Metadata)
if o.Operation == state.Upsert {
req := o.Request.(state.SetRequest)
