InvergeDocs
.NETAPI reference

Transports & dispatchers

Transports & dispatchers in the .NET SDK.

SymbolKindSummary
HttpClientTransportclassThe default transport, over HttpClient.
INexusDispatcherinterfaceDecides what actually happens when a resource method is called.
INexusTransportinterfaceSends one HTTP request.
NexusTransportResponseclassA transport-level HTTP response, before any Nexus semantics.

HttpClientTransport

class
class Inverge.Nexus.Transport.HttpClientTransport

The default transport, over HttpClient.

With no client supplied, every NexusClient in the process shares one pooled HttpClient. That is the correct default for a library: a client per instance exhausts sockets under load, and a client that lives forever without a connection lifetime never notices a DNS change. On modern targets the shared handler recycles connections every five minutes for exactly that reason.

In an ASP.NET Core or worker app, prefer handing in a client from IHttpClientFactory — services.AddNexus() does this — so the app's own handler pipeline, resilience policies and DNS behaviour apply. An injected client is owned by the caller and is never disposed here.

HttpClientTransport

constructor
new HttpClientTransport()

Uses the process-wide shared HttpClient.

HttpClientTransport

constructor
new HttpClientTransport(HttpClient client)

Uses a caller-supplied HttpClient, which it does not dispose.

Parameters

Prop

Type

Dispose()

method
void Dispose()

SendAsync()

method
Task<NexusTransportResponse> SendAsync(string method, string url, IReadOnlyDictionary<string, string> headers, byte[]? body, TimeSpan timeout, CancellationToken cancellationToken)

Parameters

Prop

Type

Returns Task<NexusTransportResponse>

INexusDispatcher

interface
interface Inverge.Nexus.Dispatch.INexusDispatcher

Decides what actually happens when a resource method is called.

Implement this to hand delivery to your own infrastructure — a queue, a durable outbox, a hosted channel — so Nexus traffic inherits whatever reliability guarantees the rest of your system has.

DispatchAsync()

method
Task<JsonNode?> DispatchAsync(NexusRequest request, CancellationToken cancellationToken)

Delivers a request. A dispatcher that does not deliver inline returns null, so calls that need the response cannot be used with one.

Parameters

Prop

Type

Returns Task<JsonNode?>

FlushAsync()

method
Task FlushAsync(TimeSpan timeout, CancellationToken cancellationToken)

Waits for in-flight deliveries. A no-op for a synchronous dispatcher.

Parameters

Prop

Type

StopAsync()

method
Task StopAsync(TimeSpan timeout)

Releases resources, flushing first.

Parameters

Prop

Type

INexusTransport

interface
interface Inverge.Nexus.Transport.INexusTransport

Sends one HTTP request. Implement this to put the SDK's traffic through your own pipeline — a proxy, a recorded fixture, a test double.

An implementation should return a NexusTransportResponse for any status the server actually produced, including 4xx and 5xx: turning those into Nexus errors is the client's job, and it needs the server's own message to do it. Throw NexusTransportException only for genuine network-level failures.

SendAsync()

method
Task<NexusTransportResponse> SendAsync(string method, string url, IReadOnlyDictionary<string, string> headers, byte[]? body, TimeSpan timeout, CancellationToken cancellationToken)

Sends the request and returns whatever the server answered.

Parameters

Prop

Type

Returns Task<NexusTransportResponse>

NexusTransportResponse

class
class Inverge.Nexus.Transport.NexusTransportResponse

A transport-level HTTP response, before any Nexus semantics.

NexusTransportResponse

constructor
new NexusTransportResponse(int status, byte[]? body = null, IReadOnlyDictionary<string, string>? headers = null)

Creates a response.

Parameters

Prop

Type

Body

property
byte[] Body { get; }

The raw body bytes.

Headers

property
IReadOnlyDictionary<string, string> Headers { get; }

Response headers. Keys are compared case-insensitively.

IsSuccess

property
bool IsSuccess { get; }

Whether the status is 2xx.

Status

property
int Status { get; }

The HTTP status code.

Text

property
string Text { get; }

The body decoded as UTF-8.

ReadJson()

method
JsonNode? ReadJson()

The body parsed as JSON, or null when it is empty or not JSON.

A non-JSON body is a normal outcome — a proxy's HTML error page, a 204 — so this returns null rather than throwing. The caller still has Text for the error it reports.

Returns JsonNode?

On this page