Patch cosmosdb first-write without etag state test (#1069)
Co-authored-by: Artur Souza <artursouza.ms@outlook.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
This commit is contained in:
parent
d62eee779d
commit
ce0674fb48
|
@ -16,7 +16,7 @@ resource cosmosDb 'Microsoft.DocumentDB/databaseAccounts@2021-04-15' = {
|
||||||
tags: confTestTags
|
tags: confTestTags
|
||||||
properties: {
|
properties: {
|
||||||
consistencyPolicy: {
|
consistencyPolicy: {
|
||||||
defaultConsistencyLevel: 'Session'
|
defaultConsistencyLevel: 'Strong' // Needed by conformance test state.go
|
||||||
}
|
}
|
||||||
locations: [
|
locations: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
"github.com/a8m/documentdb"
|
"github.com/a8m/documentdb"
|
||||||
"github.com/agrea/ptr"
|
"github.com/agrea/ptr"
|
||||||
|
"github.com/google/uuid"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
|
||||||
"github.com/dapr/components-contrib/contenttype"
|
"github.com/dapr/components-contrib/contenttype"
|
||||||
|
@ -241,10 +242,10 @@ func (c *StateStore) Set(req *state.SetRequest) error {
|
||||||
options := []documentdb.CallOption{documentdb.PartitionKey(partitionKey)}
|
options := []documentdb.CallOption{documentdb.PartitionKey(partitionKey)}
|
||||||
|
|
||||||
if req.ETag != nil {
|
if req.ETag != nil {
|
||||||
var etag string
|
options = append(options, documentdb.IfMatch((*req.ETag)))
|
||||||
if req.ETag != nil {
|
}
|
||||||
etag = *req.ETag
|
if req.Options.Concurrency == state.FirstWrite && (req.ETag == nil || *req.ETag == "") {
|
||||||
}
|
etag := uuid.NewString()
|
||||||
options = append(options, documentdb.IfMatch((etag)))
|
options = append(options, documentdb.IfMatch((etag)))
|
||||||
}
|
}
|
||||||
if req.Options.Consistency == state.Strong {
|
if req.Options.Consistency == state.Strong {
|
||||||
|
@ -295,11 +296,7 @@ func (c *StateStore) Delete(req *state.DeleteRequest) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.ETag != nil {
|
if req.ETag != nil {
|
||||||
var etag string
|
options = append(options, documentdb.IfMatch((*req.ETag)))
|
||||||
if req.ETag != nil {
|
|
||||||
etag = *req.ETag
|
|
||||||
}
|
|
||||||
options = append(options, documentdb.IfMatch((etag)))
|
|
||||||
}
|
}
|
||||||
if req.Options.Consistency == state.Strong {
|
if req.Options.Consistency == state.Strong {
|
||||||
options = append(options, documentdb.ConsistencyLevel(documentdb.Strong))
|
options = append(options, documentdb.ConsistencyLevel(documentdb.Strong))
|
||||||
|
|
Loading…
Reference in New Issue