mirror of https://github.com/dapr/dotnet-sdk.git
				
				
				
			Remove retry options from state apis. (#361)
* Removing retry options for state apis. * getting latest proto from dapr/dapr
This commit is contained in:
		
							parent
							
								
									fdf17b7dbb
								
							
						
					
					
						commit
						b6329539bc
					
				| 
						 | 
				
			
			@ -541,29 +541,6 @@ namespace Dapr.Client
 | 
			
		|||
                stateRequestOptions.Concurrency = GetStateConcurrencyForConcurrencyMode(stateOptions.Concurrency.Value);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (stateOptions.RetryOptions == null)
 | 
			
		||||
            {
 | 
			
		||||
                return stateRequestOptions;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            var retryPolicy = new Autogenerated.StateRetryPolicy();
 | 
			
		||||
            if (stateOptions.RetryOptions.RetryMode != null)
 | 
			
		||||
            {
 | 
			
		||||
                retryPolicy.Pattern = GetRetryPatternForRetryMode(stateOptions.RetryOptions.RetryMode.Value);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (stateOptions.RetryOptions.RetryInterval != null)
 | 
			
		||||
            {
 | 
			
		||||
                retryPolicy.Interval = Duration.FromTimeSpan(stateOptions.RetryOptions.RetryInterval.Value);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (stateOptions.RetryOptions.RetryThreshold != null)
 | 
			
		||||
            {
 | 
			
		||||
                retryPolicy.Threshold = stateOptions.RetryOptions.RetryThreshold.Value;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            stateRequestOptions.RetryPolicy = retryPolicy;
 | 
			
		||||
 | 
			
		||||
            return stateRequestOptions;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -602,16 +579,6 @@ namespace Dapr.Client
 | 
			
		|||
                _ => throw new ArgumentException($"{concurrencyMode} Concurrency Mode is not supported.")
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static Autogenerated.StateRetryPolicy.Types.RetryPattern GetRetryPatternForRetryMode(RetryMode retryMode)
 | 
			
		||||
        {
 | 
			
		||||
            return retryMode switch
 | 
			
		||||
            {
 | 
			
		||||
                RetryMode.Exponential => Autogenerated.StateRetryPolicy.Types.RetryPattern.RetryExponential,
 | 
			
		||||
                RetryMode.Linear => Autogenerated.StateRetryPolicy.Types.RetryPattern.RetryLinear,
 | 
			
		||||
                _ => throw new ArgumentException($"{retryMode} Retry Mode is not supported.")
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
        #endregion Helper Methods
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,6 @@ syntax = "proto3";
 | 
			
		|||
package dapr.proto.common.v1;
 | 
			
		||||
 | 
			
		||||
import "google/protobuf/any.proto";
 | 
			
		||||
import "google/protobuf/duration.proto";
 | 
			
		||||
 | 
			
		||||
option csharp_namespace = "Dapr.Client.Autogen.Grpc.v1";
 | 
			
		||||
option java_outer_classname = "CommonProtos";
 | 
			
		||||
| 
						 | 
				
			
			@ -95,11 +94,11 @@ message StateItem {
 | 
			
		|||
  // The metadata which will be passed to state store component.
 | 
			
		||||
  map<string,string> metadata = 4;
 | 
			
		||||
 | 
			
		||||
  // Options for concurrency, consistency, and retry_policy to save the state.
 | 
			
		||||
  // Options for concurrency and consistency to save the state.
 | 
			
		||||
  StateOptions options = 5;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StateOptions configures concurrency, consistency, and retry policy for state operations
 | 
			
		||||
// StateOptions configures concurrency and consistency for state operations
 | 
			
		||||
message StateOptions {
 | 
			
		||||
  // Enum describing the supported concurrency for state.
 | 
			
		||||
  enum StateConcurrency {
 | 
			
		||||
| 
						 | 
				
			
			@ -117,24 +116,4 @@ message StateOptions {
 | 
			
		|||
 | 
			
		||||
  StateConcurrency concurrency = 1;
 | 
			
		||||
  StateConsistency consistency = 2;
 | 
			
		||||
  StateRetryPolicy retry_policy = 3;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// StateRetryPolicy represents retry policy to set and delete state operations.
 | 
			
		||||
message StateRetryPolicy {
 | 
			
		||||
  // Enum describing the support retry pattern
 | 
			
		||||
  enum RetryPattern {
 | 
			
		||||
    RETRY_UNSPECIFIED = 0;
 | 
			
		||||
    RETRY_LINEAR = 1;
 | 
			
		||||
    RETRY_EXPONENTIAL = 2;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Maximum number of retries.
 | 
			
		||||
  int32 threshold = 1;
 | 
			
		||||
 | 
			
		||||
  // Retry pattern.
 | 
			
		||||
  RetryPattern pattern = 2;
 | 
			
		||||
 | 
			
		||||
  // Initial delay between retries.
 | 
			
		||||
  google.protobuf.Duration interval = 3;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ service AppCallback {
 | 
			
		|||
  rpc ListTopicSubscriptions(google.protobuf.Empty) returns (ListTopicSubscriptionsResponse) {}
 | 
			
		||||
 | 
			
		||||
  // Subscribes events from Pubsub
 | 
			
		||||
  rpc OnTopicEvent(TopicEventRequest) returns (google.protobuf.Empty) {}
 | 
			
		||||
  rpc OnTopicEvent(TopicEventRequest) returns (TopicEventResponse) {}
 | 
			
		||||
 | 
			
		||||
  // Lists all input bindings subscribed by this app.
 | 
			
		||||
  rpc ListInputBindings(google.protobuf.Empty) returns (ListInputBindingsResponse) {}
 | 
			
		||||
| 
						 | 
				
			
			@ -41,9 +41,9 @@ service AppCallback {
 | 
			
		|||
// TopicEventRequest message is compatiable with CloudEvent spec v1.0
 | 
			
		||||
// https://github.com/cloudevents/spec/blob/v1.0/spec.md
 | 
			
		||||
message TopicEventRequest {
 | 
			
		||||
  // id identifies the event. Producers MUST ensure that source + id
 | 
			
		||||
  // id identifies the event. Producers MUST ensure that source + id 
 | 
			
		||||
  // is unique for each distinct event. If a duplicate event is re-sent
 | 
			
		||||
  // (e.g. due to a network error) it MAY have the same id.
 | 
			
		||||
  // (e.g. due to a network error) it MAY have the same id. 
 | 
			
		||||
  string id = 1;
 | 
			
		||||
 | 
			
		||||
  // source identifies the context in which an event happened.
 | 
			
		||||
| 
						 | 
				
			
			@ -53,10 +53,10 @@ message TopicEventRequest {
 | 
			
		|||
  // the data encoded in the URI is defined by the event producer.
 | 
			
		||||
  string source = 2;
 | 
			
		||||
 | 
			
		||||
  // The type of event related to the originating occurrence.
 | 
			
		||||
  // The type of event related to the originating occurrence. 
 | 
			
		||||
  string type = 3;
 | 
			
		||||
 | 
			
		||||
  // The version of the CloudEvents specification.
 | 
			
		||||
  // The version of the CloudEvents specification. 
 | 
			
		||||
  string spec_version = 4;
 | 
			
		||||
 | 
			
		||||
  // The content type of data value.
 | 
			
		||||
| 
						 | 
				
			
			@ -69,6 +69,10 @@ message TopicEventRequest {
 | 
			
		|||
  string topic = 6;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TopicEventResponse is response from app on published message
 | 
			
		||||
message TopicEventResponse {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BindingEventRequest represents input bindings event.
 | 
			
		||||
message BindingEventRequest {
 | 
			
		||||
  // Requried. The name of the input binding component.
 | 
			
		||||
| 
						 | 
				
			
			@ -90,7 +94,7 @@ message BindingEventResponse {
 | 
			
		|||
  // The state key values which will be stored in store_name.
 | 
			
		||||
  repeated common.v1.StateItem states = 2;
 | 
			
		||||
 | 
			
		||||
  // BindingEventConcurrency is the kind of concurrency
 | 
			
		||||
  // BindingEventConcurrency is the kind of concurrency 
 | 
			
		||||
  enum BindingEventConcurrency {
 | 
			
		||||
    // SEQUENTIAL sends data to output bindings specified in "to" sequentially.
 | 
			
		||||
    SEQUENTIAL = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -128,4 +132,4 @@ message TopicSubscription {
 | 
			
		|||
message ListInputBindingsResponse {
 | 
			
		||||
  // The list of input bindings.
 | 
			
		||||
  repeated string bindings = 1;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,23 +0,0 @@
 | 
			
		|||
// ------------------------------------------------------------
 | 
			
		||||
// Copyright (c) Microsoft Corporation.
 | 
			
		||||
// Licensed under the MIT License.
 | 
			
		||||
// ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
namespace Dapr.Client
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Represents the delay between retries.  See https://github.com/dapr/docs/blob/master/reference/api/state.md#retry-policy
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public enum RetryMode
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// The delay between retries is constant.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Linear,
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// The delay between retries doubles each time.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        Exponential,
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,36 +0,0 @@
 | 
			
		|||
// ------------------------------------------------------------
 | 
			
		||||
// Copyright (c) Microsoft Corporation.
 | 
			
		||||
// Licensed under the MIT License.
 | 
			
		||||
// ------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
namespace Dapr.Client
 | 
			
		||||
{
 | 
			
		||||
    using System;
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
    using System.Text;
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Operation retry options when perfroming operations with Dapr.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class RetryOptions
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Initial delay between retries, in milliseconds.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <remarks>
 | 
			
		||||
        ///  The interval remains constant for <see cref="RetryMode.Linear"/>.
 | 
			
		||||
        ///  The interval is doubled after each retry for <see cref="RetryMode.Exponential"/>. So, for exponential pattern, the delay after attempt n will be interval*2^(n-1).
 | 
			
		||||
        /// </remarks>
 | 
			
		||||
        public TimeSpan? RetryInterval { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Retry pattern, can be either linear or exponential.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public RetryMode? RetryMode { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Maximum number of retries.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public int? RetryThreshold { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -23,10 +23,5 @@ namespace Dapr.Client
 | 
			
		|||
        /// Concurrency mode for state operations with Dapr.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public ConcurrencyMode? Concurrency { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Retry options when perfroming operations with Dapr.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public RetryOptions RetryOptions {get; set;}
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,6 @@ namespace Dapr.Client.Test
 | 
			
		|||
    using System.Collections.Generic;
 | 
			
		||||
    using StateConsistency = Dapr.Client.Autogen.Grpc.v1.StateOptions.Types.StateConsistency;
 | 
			
		||||
    using StateConcurrency = Dapr.Client.Autogen.Grpc.v1.StateOptions.Types.StateConcurrency;
 | 
			
		||||
    using RetryPattern = Dapr.Client.Autogen.Grpc.v1.StateRetryPolicy.Types.RetryPattern;
 | 
			
		||||
    using Google.Protobuf;
 | 
			
		||||
 | 
			
		||||
    public class StateApiTest
 | 
			
		||||
| 
						 | 
				
			
			@ -352,21 +351,15 @@ namespace Dapr.Client.Test
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        [Theory]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        public async Task SaveStateAsync_ValidateOptions(
 | 
			
		||||
            ConsistencyMode consistencyMode,
 | 
			
		||||
            ConcurrencyMode concurrencyMode,
 | 
			
		||||
            RetryMode retryMode,
 | 
			
		||||
            StateConsistency expectedConsistency,
 | 
			
		||||
            StateConcurrency expectedConcurrency,
 | 
			
		||||
            RetryPattern expectedRetryMode)
 | 
			
		||||
            StateConcurrency expectedConcurrency)
 | 
			
		||||
        {
 | 
			
		||||
            // Configure Client
 | 
			
		||||
            var httpClient = new TestHttpClient();
 | 
			
		||||
| 
						 | 
				
			
			@ -378,13 +371,7 @@ namespace Dapr.Client.Test
 | 
			
		|||
            var stateOptions = new StateOptions
 | 
			
		||||
            {
 | 
			
		||||
                Concurrency = concurrencyMode,
 | 
			
		||||
                Consistency = consistencyMode,
 | 
			
		||||
                RetryOptions = new RetryOptions
 | 
			
		||||
                {
 | 
			
		||||
                    RetryInterval = TimeSpan.FromSeconds(5),
 | 
			
		||||
                    RetryMode = retryMode,
 | 
			
		||||
                    RetryThreshold = 10
 | 
			
		||||
                }
 | 
			
		||||
                Consistency = consistencyMode
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            var metadata = new Dictionary<string, string>();
 | 
			
		||||
| 
						 | 
				
			
			@ -406,9 +393,6 @@ namespace Dapr.Client.Test
 | 
			
		|||
            state.Metadata["key2"].Should().Be("value2");
 | 
			
		||||
            state.Options.Concurrency.Should().Be(expectedConcurrency);
 | 
			
		||||
            state.Options.Consistency.Should().Be(expectedConsistency);
 | 
			
		||||
            state.Options.RetryPolicy.Pattern.Should().Be(expectedRetryMode);
 | 
			
		||||
            state.Options.RetryPolicy.Threshold.Should().Be(10);
 | 
			
		||||
            state.Options.RetryPolicy.Interval.Seconds.Should().Be(5);
 | 
			
		||||
 | 
			
		||||
            var stateJson = state.Value.ToStringUtf8();
 | 
			
		||||
            var stateFromRequest = JsonSerializer.Deserialize<Widget>(stateJson);
 | 
			
		||||
| 
						 | 
				
			
			@ -417,21 +401,15 @@ namespace Dapr.Client.Test
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        [Theory]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        public async Task TrySaveStateAsync_ValidateOptions(
 | 
			
		||||
            ConsistencyMode consistencyMode,
 | 
			
		||||
            ConcurrencyMode concurrencyMode,
 | 
			
		||||
            RetryMode retryMode,
 | 
			
		||||
            StateConsistency expectedConsistency,
 | 
			
		||||
            StateConcurrency expectedConcurrency,
 | 
			
		||||
            RetryPattern expectedRetryMode)
 | 
			
		||||
            StateConcurrency expectedConcurrency)
 | 
			
		||||
        {
 | 
			
		||||
            // Configure Client
 | 
			
		||||
            var httpClient = new TestHttpClient();
 | 
			
		||||
| 
						 | 
				
			
			@ -443,13 +421,7 @@ namespace Dapr.Client.Test
 | 
			
		|||
            var stateOptions = new StateOptions
 | 
			
		||||
            {
 | 
			
		||||
                Concurrency = concurrencyMode,
 | 
			
		||||
                Consistency = consistencyMode,
 | 
			
		||||
                RetryOptions = new RetryOptions
 | 
			
		||||
                {
 | 
			
		||||
                    RetryInterval = TimeSpan.FromSeconds(5),
 | 
			
		||||
                    RetryMode = retryMode,
 | 
			
		||||
                    RetryThreshold = 10
 | 
			
		||||
                }
 | 
			
		||||
                Consistency = consistencyMode
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            var metadata = new Dictionary<string, string>();
 | 
			
		||||
| 
						 | 
				
			
			@ -472,9 +444,6 @@ namespace Dapr.Client.Test
 | 
			
		|||
            state.Metadata["key2"].Should().Be("value2");
 | 
			
		||||
            state.Options.Concurrency.Should().Be(expectedConcurrency);
 | 
			
		||||
            state.Options.Consistency.Should().Be(expectedConsistency);
 | 
			
		||||
            state.Options.RetryPolicy.Pattern.Should().Be(expectedRetryMode);
 | 
			
		||||
            state.Options.RetryPolicy.Threshold.Should().Be(10);
 | 
			
		||||
            state.Options.RetryPolicy.Interval.Seconds.Should().Be(5);
 | 
			
		||||
 | 
			
		||||
            var stateJson = state.Value.ToStringUtf8();
 | 
			
		||||
            var stateFromRequest = JsonSerializer.Deserialize<Widget>(stateJson);
 | 
			
		||||
| 
						 | 
				
			
			@ -483,21 +452,15 @@ namespace Dapr.Client.Test
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        [Theory]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        public async Task DeleteStateAsync_ValidateOptions(
 | 
			
		||||
            ConsistencyMode consistencyMode,
 | 
			
		||||
            ConcurrencyMode concurrencyMode,
 | 
			
		||||
            RetryMode retryMode,
 | 
			
		||||
            StateConsistency expectedConsistency,
 | 
			
		||||
            StateConcurrency expectedConcurrency,
 | 
			
		||||
            RetryPattern expectedRetryMode)
 | 
			
		||||
            StateConcurrency expectedConcurrency)
 | 
			
		||||
        {
 | 
			
		||||
            // Configure Client
 | 
			
		||||
            var httpClient = new TestHttpClient();
 | 
			
		||||
| 
						 | 
				
			
			@ -508,13 +471,7 @@ namespace Dapr.Client.Test
 | 
			
		|||
            var stateOptions = new StateOptions
 | 
			
		||||
            {
 | 
			
		||||
                Concurrency = concurrencyMode,
 | 
			
		||||
                Consistency = consistencyMode,
 | 
			
		||||
                RetryOptions = new RetryOptions
 | 
			
		||||
                {
 | 
			
		||||
                    RetryInterval = TimeSpan.FromSeconds(5),
 | 
			
		||||
                    RetryMode = retryMode,
 | 
			
		||||
                    RetryThreshold = 10
 | 
			
		||||
                }
 | 
			
		||||
                Consistency = consistencyMode
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            var task = daprClient.DeleteStateAsync("testStore", "test", stateOptions);
 | 
			
		||||
| 
						 | 
				
			
			@ -526,27 +483,18 @@ namespace Dapr.Client.Test
 | 
			
		|||
            request.Key.Should().Be("test");
 | 
			
		||||
            request.Options.Concurrency.Should().Be(expectedConcurrency);
 | 
			
		||||
            request.Options.Consistency.Should().Be(expectedConsistency);
 | 
			
		||||
            request.Options.RetryPolicy.Pattern.Should().Be(expectedRetryMode);
 | 
			
		||||
            request.Options.RetryPolicy.Threshold.Should().Be(10);
 | 
			
		||||
            request.Options.RetryPolicy.Interval.Seconds.Should().Be(5);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Theory]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Exponential, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryExponential)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, RetryMode.Linear, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite, RetryPattern.RetryLinear)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Eventual, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyEventual, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.FirstWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyFirstWrite)]
 | 
			
		||||
        [InlineData(ConsistencyMode.Strong, ConcurrencyMode.LastWrite, StateConsistency.ConsistencyStrong, StateConcurrency.ConcurrencyLastWrite)]
 | 
			
		||||
        public async Task TryDeleteStateAsync_ValidateOptions(
 | 
			
		||||
            ConsistencyMode consistencyMode,
 | 
			
		||||
            ConcurrencyMode concurrencyMode,
 | 
			
		||||
            RetryMode retryMode,
 | 
			
		||||
            StateConsistency expectedConsistency,
 | 
			
		||||
            StateConcurrency expectedConcurrency,
 | 
			
		||||
            RetryPattern expectedRetryMode)
 | 
			
		||||
            StateConcurrency expectedConcurrency)
 | 
			
		||||
        {
 | 
			
		||||
            // Configure Client
 | 
			
		||||
            var httpClient = new TestHttpClient();
 | 
			
		||||
| 
						 | 
				
			
			@ -557,13 +505,7 @@ namespace Dapr.Client.Test
 | 
			
		|||
            var stateOptions = new StateOptions
 | 
			
		||||
            {
 | 
			
		||||
                Concurrency = concurrencyMode,
 | 
			
		||||
                Consistency = consistencyMode,
 | 
			
		||||
                RetryOptions = new RetryOptions
 | 
			
		||||
                {
 | 
			
		||||
                    RetryInterval = TimeSpan.FromSeconds(5),
 | 
			
		||||
                    RetryMode = retryMode,
 | 
			
		||||
                    RetryThreshold = 10
 | 
			
		||||
                }
 | 
			
		||||
                Consistency = consistencyMode
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            var task = daprClient.TryDeleteStateAsync("testStore", "test", "Test_Etag", stateOptions);
 | 
			
		||||
| 
						 | 
				
			
			@ -576,9 +518,6 @@ namespace Dapr.Client.Test
 | 
			
		|||
            request.Etag.Should().Be("Test_Etag");
 | 
			
		||||
            request.Options.Concurrency.Should().Be(expectedConcurrency);
 | 
			
		||||
            request.Options.Consistency.Should().Be(expectedConsistency);
 | 
			
		||||
            request.Options.RetryPolicy.Pattern.Should().Be(expectedRetryMode);
 | 
			
		||||
            request.Options.RetryPolicy.Threshold.Should().Be(10);
 | 
			
		||||
            request.Options.RetryPolicy.Interval.Seconds.Should().Be(5);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private async void SendResponseWithState<T>(T state, TestHttpClient.Entry entry, string etag = null)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue