Class ProtoDeviceConnect
Runs one device transport connect under its configured timeout - the rule every shipped device transport shares: the attempt token is the timeout authority, so any failure that surfaces after it fires - an OperationCanceledException or a transport that aborts the connect another way - is reported as a TimeoutException naming the target. A caller's own cancellation is never reclassified, and the caller keeps ownership of the connection it created.
public static class ProtoDeviceConnect
- Inheritance
-
ProtoDeviceConnect
- Inherited Members
Methods
WithTimeoutAsync<TConnection>(string, TimeSpan, Func<CancellationToken, Task<TConnection>>, CancellationToken)
Connects through connect with a linked token that expires after
timeout, so the transport call cannot outlive the connect bound. The
connection the call returns is returned unchanged; a transport that owns its socket disposes it
on failure itself.
public static Task<TConnection> WithTimeoutAsync<TConnection>(string target, TimeSpan timeout, Func<CancellationToken, Task<TConnection>> connect, CancellationToken cancellationToken)
Parameters
targetstringWhat the timeout message names: the address, or a path for an in-process endpoint.
timeoutTimeSpanThe registered connect timeout.
connectFunc<CancellationToken, Task<TConnection>>The transport's connect call, invoked with the attempt token.
cancellationTokenCancellationTokenThe caller's cancellation; it wins over the timeout.
Returns
- Task<TConnection>
The transport's connection.
Type Parameters
TConnectionThe transport's connection type.
Exceptions
- TimeoutException
The attempt token fired before the connect completed.