public override async ValueTask <IReadOnlyList <BulkStateItem> > GetBulkStateAsync(string storeName, IReadOnlyList <string> keys, int?parallelism, CancellationToken cancellationToken = default) { ArgumentVerifier.ThrowIfNullOrEmpty(storeName, nameof(storeName)); if (keys.Count == 0) { throw new ArgumentException("keys do not contain any elements"); } var getBulkStateEnvelope = new Autogenerated.GetBulkStateRequest() { StoreName = storeName, Parallelism = parallelism ?? default(int) }; getBulkStateEnvelope.Keys.AddRange(keys); var response = await this.MakeGrpcCallHandleError( options => client.GetBulkStateAsync(getBulkStateEnvelope, options), cancellationToken); var bulkResponse = new List <BulkStateItem>(); foreach (var item in response.Items) { bulkResponse.Add(new BulkStateItem(item.Key, item.Data.ToStringUtf8(), item.Etag)); } return(bulkResponse); }
public override async Task <IReadOnlyList <BulkStateItem> > GetBulkStateAsync(string storeName, IReadOnlyList <string> keys, int?parallelism, IReadOnlyDictionary <string, string> metadata = default, CancellationToken cancellationToken = default) { ArgumentVerifier.ThrowIfNullOrEmpty(storeName, nameof(storeName)); if (keys.Count == 0) { throw new ArgumentException("keys do not contain any elements"); } var envelope = new Autogenerated.GetBulkStateRequest() { StoreName = storeName, Parallelism = parallelism ?? default }; if (metadata != null) { foreach (var kvp in metadata) { envelope.Metadata.Add(kvp.Key, kvp.Value); } } envelope.Keys.AddRange(keys); var options = CreateCallOptions(headers: null, cancellationToken); Autogenerated.GetBulkStateResponse response; try { response = await client.GetBulkStateAsync(envelope, options); } catch (RpcException ex) { throw new DaprException("State operation failed: the Dapr endpoint indicated a failure. See InnerException for details.", ex); } var bulkResponse = new List <BulkStateItem>(); foreach (var item in response.Items) { bulkResponse.Add(new BulkStateItem(item.Key, item.Data.ToStringUtf8(), item.Etag)); } return(bulkResponse); }