Class ApiCommandWorker<T>
- Namespace
- Virtufin.Worker.DevKit
- Assembly
- Virtufin.Worker.DevKit.dll
A CommandWorker<T> base class that provides a pre-configured Virtufin.Api.Client.ApiClient. Subclasses get Api for free (either fixed via ctor or lazily via EnsureClientFromCommand(JsonNode)).
public abstract class ApiCommandWorker<T> : CommandWorker<T>, IWorker where T : struct, Enum
Type Parameters
TThe command enum (see CommandWorker<T>).
- Inheritance
-
ApiCommandWorker<T>
- Implements
-
IWorker
- Inherited Members
Constructors
ApiCommandWorker(string)
An API command worker of type workerType, named by the naming library, with lazy ApiClient configuration.
protected ApiCommandWorker(string workerType)
Parameters
workerTypestring
ApiCommandWorker(string, string, int)
An API command worker of type workerType, named by the naming library, with a fixed API Gateway host and port.
protected ApiCommandWorker(string workerType, string apiHost, int apiPort)
Parameters
ApiCommandWorker(Uri, string)
Initializes a new ApiCommandWorker with lazy ApiClient configuration. Subclasses must call EnsureClient(string, int) or EnsureClientFromCommand(JsonNode) before using Api.
protected ApiCommandWorker(Uri source, string responseEventType)
Parameters
ApiCommandWorker(Uri, string, string, int)
Initializes a new ApiCommandWorker with a fixed API Gateway host and port.
protected ApiCommandWorker(Uri source, string responseEventType, string apiHost, int apiPort)
Parameters
Properties
Api
The API client for invoking backend services via the API Gateway. Configured via EnsureClient(string, int) or EnsureClientFromCommand(JsonNode).
protected ApiClient? Api { get; }
Property Value
- ApiClient
Gateway
Managed-path gateway implementation. Routes backend calls through
the gRPC proxy when the worker is loaded by
DotNetDllEngine. The AOT shim that pairs with this class
overrides Gateway with
Virtufin.Worker.Host.AotGatewayAdapter instead.
protected override IGatewayClient Gateway { get; }
Property Value
- IGatewayClient
Methods
EnsureClient(string, int)
Creates or reconfigures the Api client for the given host:port. Idempotent: if already configured for the same host:port, returns without change. Thread-safe.
protected void EnsureClient(string host, int port)
Parameters
EnsureClient(string, int, bool)
Ensure Api targets host:port
over TLS or plaintext, rebuilding the client only when the target changed.
protected void EnsureClient(string host, int port, bool tls)
Parameters
EnsureClientFromCommand(JsonNode)
Parses the FieldApiHost field from the
command JSON (host[:port] or http(s)://host[:port], see
ResolveEndpoint(string?, Func<string, string?>?)) and calls
EnsureClient(string, int, bool). If
the field is absent, keeps an already-configured client, else
configures one for the host process's gateway
(Configured()).
protected void EnsureClientFromCommand(JsonNode command)
Parameters
commandJsonNode