Table of Contents

Class RemoteServiceInvokerBase

Namespace
GroupeIsa.Neos.ClusterCommunication
Assembly
GroupeIsa.Neos.ClusterCommunication.dll

A base client for interacting with endpoints over HTTP protocol.

public abstract class RemoteServiceInvokerBase : IRemoteServiceInvoker
Inheritance
RemoteServiceInvokerBase
Implements
Derived
Inherited Members

Constructors

RemoteServiceInvokerBase(IHttpClientFactory, IHttpContextAccessor, IApplicationContext, IDaprIdProvider, INeosTracer, INeosLogger)

Initializes a new instance of the RemoteServiceInvokerBase class.

protected RemoteServiceInvokerBase(IHttpClientFactory httpClientFactory, IHttpContextAccessor httpContextAccessor, IApplicationContext applicationContext, IDaprIdProvider daprIdProvider, INeosTracer neosTracer, INeosLogger logger)

Parameters

httpClientFactory IHttpClientFactory

The http client factory.

httpContextAccessor IHttpContextAccessor

Provides access to the current HttpContext.

applicationContext IApplicationContext

The application context.

daprIdProvider IDaprIdProvider

The dapr id provider.

neosTracer INeosTracer

The Neos tracer for tracing activities.

logger INeosLogger

The logger.

Fields

ImageMediaType

Represents the Image media type.

protected const string ImageMediaType = "image/*"

Field Value

string

JsonMediaType

Represents the JSON media type.

protected const string JsonMediaType = "application/json"

Field Value

string

Properties

ApplicationContext

Gets the application context.

protected IApplicationContext ApplicationContext { get; }

Property Value

IApplicationContext

BaseUrl

Gets request base URL.

protected string BaseUrl { get; init; }

Property Value

string

ClientLogicalName

Gets The logical name of the HTTP client to create.

protected string ClientLogicalName { get; init; }

Property Value

string

HttpContextAccessor

Gets the HTTP context accessor.

protected IHttpContextAccessor HttpContextAccessor { get; }

Property Value

IHttpContextAccessor

Methods

GetByteArrayAsync(RemoteServiceOptions)

Send a GET request with the specified options and return the response body as a byte array.

public Task<byte[]> GetByteArrayAsync(RemoteServiceOptions options)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

Returns

Task<byte[]>

A Task<TResult> that will return when the operation has completed with byte array.

GetByteArrayAsync(RemoteServiceOptions, CancellationToken)

Send a GET request with the specified options and return the response body as a byte array.

public abstract Task<byte[]> GetByteArrayAsync(RemoteServiceOptions options, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<byte[]>

A Task<TResult> that will return when the operation has completed with byte array.

GetServiceIdAsync(RemoteServiceOptions, CancellationToken)

Gets the service identifier (dapr id).

protected Task<string> GetServiceIdAsync(RemoteServiceOptions options, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The remote service options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<string>

The service identifier (dapr id).

GetStringAsync(RemoteServiceOptions)

Send a GET request with the specified options and return the response body as a string.

public Task<string> GetStringAsync(RemoteServiceOptions options)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

Returns

Task<string>

A Task<TResult> that will return when the operation has completed with string.

GetStringAsync(RemoteServiceOptions, CancellationToken)

Send a GET request with the specified options and return the response body as a string.

public abstract Task<string> GetStringAsync(RemoteServiceOptions options, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<string>

A Task<TResult> that will return when the operation has completed with string.

InvokeAsync(RemoteServiceOptions)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public Task InvokeAsync(RemoteServiceOptions options)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

Returns

Task

A Task<TResult> that will return when the operation has completed.

InvokeAsync(RemoteServiceOptions, CancellationToken)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public abstract Task InvokeAsync(RemoteServiceOptions options, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task

A Task<TResult> that will return when the operation has completed.

InvokeAsync<TResponse>(RemoteServiceOptions)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public Task<TResponse?> InvokeAsync<TResponse>(RemoteServiceOptions options)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

Returns

Task<TResponse>

A Task<TResult> that will return when the operation has completed.

Type Parameters

TResponse

The type of the data that will be JSON deserialized from the response body.

InvokeAsync<TResponse>(RemoteServiceOptions, CancellationToken)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public abstract Task<TResponse?> InvokeAsync<TResponse>(RemoteServiceOptions options, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<TResponse>

A Task<TResult> that will return when the operation has completed.

Type Parameters

TResponse

The type of the data that will be JSON deserialized from the response body.

InvokeWithResponseAsync<TResponse>(RemoteServiceOptions, CancellationToken)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method. Returns both the deserialized response data and the complete HTTP response message.

public Task<RemoteServiceResponse<TResponse>> InvokeWithResponseAsync<TResponse>(RemoteServiceOptions options, CancellationToken cancellationToken = default)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<RemoteServiceResponse<TResponse>>

A Task<TResult> that will return when the operation has completed with response data and HTTP response message.

Type Parameters

TResponse

The type of the data that will be JSON deserialized from the response body.

SendAsync(RemoteServiceOptions, HttpClient?)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public Task<HttpResponseMessage> SendAsync(RemoteServiceOptions options, HttpClient? client = null)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

client HttpClient

Provides a HTTP client for sending HTTP requests and receiving HTTP responses.

Returns

Task<HttpResponseMessage>

A Task<TResult> that will return when the operation has completed.

SendAsync(RemoteServiceOptions, HttpClient?, CancellationToken)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public virtual Task<HttpResponseMessage> SendAsync(RemoteServiceOptions options, HttpClient? client, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

client HttpClient

Provides a HTTP client for sending HTTP requests and receiving HTTP responses.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<HttpResponseMessage>

A Task<TResult> that will return when the operation has completed.

SendAsync(RemoteServiceOptions, CancellationToken)

Performs service invocation for the service identified by options.ServiceId.ServiceId and invokes the resource specified by options.Path.Path with the options.HttpMethod.HttpMethod HTTP method.

public Task<HttpResponseMessage> SendAsync(RemoteServiceOptions options, CancellationToken cancellationToken)

Parameters

options RemoteServiceOptions

The options to invoke the method on.

cancellationToken CancellationToken

A CancellationToken that can be used to cancel the operation.

Returns

Task<HttpResponseMessage>

A Task<TResult> that will return when the operation has completed.

SendAsync(HttpRequestMessage, HttpClient?, CancellationToken)

Sends an HTTP request as an asynchronous operation.

public Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpClient? client = null, CancellationToken cancellationToken = default)

Parameters

request HttpRequestMessage

The HTTP request message to send.

client HttpClient

Provides a HTTP client for sending HTTP requests and receiving HTTP responses.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<HttpResponseMessage>

A Task<TResult> that will return when the operation has completed.