Describe the proposal
Currently, the SDK allows you to make the following call:
await daprClient.SaveStateAsync<Foo>(
"storename",
"key",
new Foo(),
new StateOptions
{
Concurrency = ConcurrencyMode.FirstWrite
});
The problem with the call is that we're asking Dapr to do something impossible. FirstWrite OCC will only work if we send an ETag along with the request. SaveStateAsync will never send the ETag, for that you need to call TrySaveStateAsync.
The call will succeed but it won't use FirstWrite OCC. There are other situations where you can give Dapr state management a command/hint that cannot be fulfilled by the underlying state store, such as asking for strong consistency if the data store doesn't support it. However, the FirstWrite issue can be caught early at the SDK level.
I propose throwing an exception with a clear message explaining that you need ETag/TrySaveState to use FirstWrite.
Describe the proposal
Currently, the SDK allows you to make the following call:
The problem with the call is that we're asking Dapr to do something impossible. FirstWrite OCC will only work if we send an ETag along with the request.
SaveStateAsyncwill never send the ETag, for that you need to callTrySaveStateAsync.The call will succeed but it won't use FirstWrite OCC. There are other situations where you can give Dapr state management a command/hint that cannot be fulfilled by the underlying state store, such as asking for strong consistency if the data store doesn't support it. However, the FirstWrite issue can be caught early at the SDK level.
I propose throwing an exception with a clear message explaining that you need ETag/TrySaveState to use FirstWrite.