Class DeviceEndpointClient
- Namespace
- Azure.Iot.Operations.Connector
- Assembly
- Azure.Iot.Operations.Connector.dll
A client for reporting the status of this device and its endpoint
public class DeviceEndpointClient : IAsyncDisposable
- Inheritance
-
DeviceEndpointClient
- Implements
- Inherited Members
Methods
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
public virtual ValueTask DisposeAsync()
Returns
- ValueTask
A task that represents the asynchronous dispose operation.
DisposeAsync(bool)
public virtual ValueTask DisposeAsync(bool disposing)
Parameters
disposingbool
Returns
GetAndUpdateDeviceStatusAsync(Func<DeviceStatus, DeviceStatus?>, bool, TimeSpan?, CancellationToken)
Get the current status of this device and then optionally update it.
public Task<DeviceStatus> GetAndUpdateDeviceStatusAsync(Func<DeviceStatus, DeviceStatus?> handler, bool onlyIfChanged = false, TimeSpan? commandTimeout = null, CancellationToken cancellationToken = default)
Parameters
handlerFunc<DeviceStatus, DeviceStatus>The function that determines the new device status when given the current device status.
onlyIfChangedboolOnly send the status update if the new status is different from the current status. If the only difference between the current and new status is a 'LastTransitionTime' field, then the statuses will be considered identical.
commandTimeoutTimeSpan?The timeout for each of the 'get' and 'update' commands.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DeviceStatus>
The latest device status after this operation.
Remarks
If after retrieving the current status, you don't want to send any updates, handler should return null.
If this happens, this function will return the latest asset status without trying to update it.
This method uses a semaphore to ensure that this same client doesn't accidentally update the device status while
another thread is in the middle of updating the same device. This ensures that the current device status provided in handler
stays accurate while any updating occurs.
ReportRuntimeHealthAsync(ConnectorRuntimeHealth, TimeSpan?, CancellationToken)
Report this device endpoint's runtime health.
public Task ReportRuntimeHealthAsync(ConnectorRuntimeHealth runtimeHealth, TimeSpan? telemetryTimeout = null, CancellationToken cancellationToken = default)
Parameters
runtimeHealthConnectorRuntimeHealthThe runtime health of this device endpoint.
telemetryTimeoutTimeSpan?The timeout to use when sending this telemetry if any telemetry is sent.
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
This method uses the DeviceEndpointRuntimeHealthReporter class, so it will de-duplicate runtime healths and will periodically report the last known runtime health for as long as this device endpoint is available. Because of that, connector applications can freely call this method repeatedly even if the runtime health hasn't changed.
SetRuntimeHealthBackgroundReportingIntervalAsync(TimeSpan, CancellationToken)
Change the interval at which this client will send background reports of the latest cached asset runtime healths
public Task SetRuntimeHealthBackgroundReportingIntervalAsync(TimeSpan reportingInterval, CancellationToken cancellationToken = default)
Parameters
reportingIntervalTimeSpanThe new reporting interval
cancellationTokenCancellationTokenCancellation token
Returns
Remarks
If background reporting is currently in progress, it will be cancelled and restarted with this new interval. If background reporting is not currently in progress, calling this method will not start it.