コード例 #1
0
        public async override Task InvokeMethodAsync(HttpRequestMessage request, CancellationToken cancellationToken = default)
        {
            ArgumentVerifier.ThrowIfNull(request, nameof(request));

            var response = await InvokeMethodWithResponseAsync(request, cancellationToken);

            try
            {
                response.EnsureSuccessStatusCode();
            }
            catch (HttpRequestException ex)
            {
                // Our code path for creating requests places these keys in the request properties. We don't want to fail
                // if they are not present.
                request.Properties.TryGetValue(AppIdKey, out var appId);
                request.Properties.TryGetValue(MethodNameKey, out var methodName);

                throw new InvocationException(
                          appId: appId as string,
                          methodName: methodName as string,
                          innerException: ex,
                          response: response);
            }
        }
コード例 #2
0
ファイル: DaprClientGrpc.cs プロジェクト: amolenk/dotnet-sdk
 /// <inheritdoc/>
 public override Task PublishEventAsync(string pubsubName, string topicName, CancellationToken cancellationToken = default)
 {
     ArgumentVerifier.ThrowIfNullOrEmpty(pubsubName, nameof(pubsubName));
     ArgumentVerifier.ThrowIfNullOrEmpty(topicName, nameof(topicName));
     return(MakePublishRequest(pubsubName, topicName, string.Empty, cancellationToken));
 }
コード例 #3
0
 /// <summary>
 /// Overrides the default endpoint used by IDaprClient for conencting to Dapr runtime.
 /// </summary>
 /// <param name="daprEndpoint">Endpoint to use for making calls to Dapr runtime.
 /// Default endpoint used is http://127.0.0.1:DAPR_GRPC_PORT.</param>
 /// <returns>DaprClientBuilder instance.</returns>
 public DaprClientBuilder UseEndpoint(string daprEndpoint)
 {
     ArgumentVerifier.ThrowIfNullOrEmpty(daprEndpoint, nameof(daprEndpoint));
     this.daprEndpoint = daprEndpoint;
     return(this);
 }
コード例 #4
0
 /// <inheritdoc/>
 public override Task PublishEventAsync <TContent>(string topicName, TContent content, CancellationToken cancellationToken = default)
 {
     ArgumentVerifier.ThrowIfNullOrEmpty(topicName, nameof(topicName));
     ArgumentVerifier.ThrowIfNull(content, nameof(content));
     return(MakePublishRequest(topicName, content, cancellationToken));
 }
コード例 #5
0
 /// <inheritdoc/>
 public override Task PublishEventAsync <TData>(string topicName, TData data, CancellationToken cancellationToken = default)
 {
     ArgumentVerifier.ThrowIfNullOrEmpty(topicName, nameof(topicName));
     ArgumentVerifier.ThrowIfNull(data, nameof(data));
     return(MakePublishRequest(topicName, data, cancellationToken));
 }
コード例 #6
0
 /// <summary>
 /// Overrides the HTTP endpoint used by <see cref="DaprClient" /> for communicating with the Dapr runtime.
 /// </summary>
 /// <param name="httpEndpoint">
 /// The URI endpoint to use for HTTP calls to the Dapr runtime. The default value will be
 /// <c>http://127.0.0.1:DAPR_HTTP_PORT</c> where <c>DAPR_HTTP_PORT</c> represents the value of the
 /// <c>DAPR_HTTP_PORT</c> environment variable.
 /// </param>
 /// <returns>The <see cref="DaprClientBuilder" /> instance.</returns>
 public DaprClientBuilder UseHttpEndpoint(string httpEndpoint)
 {
     ArgumentVerifier.ThrowIfNullOrEmpty(httpEndpoint, nameof(httpEndpoint));
     this.HttpEndpoint = httpEndpoint;
     return(this);
 }
コード例 #7
0
 /// <summary>
 /// Overrides the gRPC endpoint used by <see cref="DaprClient" /> for communicating with the Dapr runtime.
 /// </summary>
 /// <param name="grpcEndpoint">
 /// The URI endpoint to use for gRPC calls to the Dapr runtime. The default value will be
 /// <c>http://127.0.0.1:DAPR_GRPC_PORT</c> where <c>DAPR_GRPC_PORT</c> represents the value of the
 /// <c>DAPR_GRPC_PORT</c> environment variable.
 /// </param>
 /// <returns>The <see cref="DaprClientBuilder" /> instance.</returns>
 public DaprClientBuilder UseGrpcEndpoint(string grpcEndpoint)
 {
     ArgumentVerifier.ThrowIfNullOrEmpty(grpcEndpoint, nameof(grpcEndpoint));
     this.GrpcEndpoint = grpcEndpoint;
     return(this);
 }