ResourceNotificationService Methods
DisposeSection titled Disposepublic class ResourceNotificationService{ public void Dispose() { // ... }}PublishUpdateAsync(IResource, string, Func<CustomResourceSnapshot, CustomResourceSnapshot>) Section titled PublishUpdateAsync(IResource, string, Func<CustomResourceSnapshot, CustomResourceSnapshot>)TaskCustomResourceSnapshot for a resource. public class ResourceNotificationService{ public Task PublishUpdateAsync( IResource resource, string resourceId, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory) { // ... }}Parameters
resourceIresourceId string The id of the resource.stateFactory Func<CustomResourceSnapshot, CustomResourceSnapshot> A factory that creates the new state based on the previous state.Remarks
PublishUpdateAsync(IResource, Func<CustomResourceSnapshot, CustomResourceSnapshot>) Section titled PublishUpdateAsync(IResource, Func<CustomResourceSnapshot, CustomResourceSnapshot>)TaskCustomResourceSnapshot for a resource. public class ResourceNotificationService{ public Task PublishUpdateAsync( IResource resource, Func<CustomResourceSnapshot, CustomResourceSnapshot> stateFactory) { // ... }}Parameters
resourceIstateFactory Func<CustomResourceSnapshot, CustomResourceSnapshot> A factory that creates the new state based on the previous state.Remarks
TryGetCurrentState(string, ResourceEvent?) Section titled TryGetCurrentState(string, ResourceEvent?)boolpublic class ResourceNotificationService{ public bool TryGetCurrentState( string resourceId, out ResourceEvent? resourceEvent) { // ... }}Parameters
resourceId stringThe resource id. This id can either exactly match the unique id of the resource or the displayed resource name if the resource name doesn't have duplicates (i.e. replicas).resourceEvent ResourceResourceEvent for the specified resource id, if found; otherwise, null.Returns
booltrue if specified resource id was found; otherwise, false.Remarks
A resource id can be either the unique id of the resource or the displayed resource name.
Projects, executables and containers typically have a unique id that combines the display name and a unique suffix. For example, a resource named cache could have a resource id of cache-. This id is used to uniquely identify the resource in the AppHost.
The resource name can be also be used to retrieve the resource state, but it must be unique. If there are multiple resources with the same name, then this method will not return a match. For example, if a resource named cache has multiple replicas, then specifing cache won't return a match.
WaitForDependenciesAsync(IResource, CancellationToken) Section titled WaitForDependenciesAsync(IResource, CancellationToken)Taskpublic class ResourceNotificationService{ public Task WaitForDependenciesAsync( IResource resource, CancellationToken cancellationToken) { // ... }}Parameters
resourceIcancellationToken CancellationToken The cancellation token.Returns
TaskA task.Exceptions
WaitForResourceAsync(string, string?, CancellationToken) Section titled WaitForResourceAsync(string, string?, CancellationToken)TaskKnownResourceStates for common states. public class ResourceNotificationService{ public Task WaitForResourceAsync( string resourceName, string? targetState = null, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
resourceName stringThe name of the resource.targetState string?optionalThe state to wait for the resource to transition to. See KnownResourceStates for common states.cancellationToken CancellationToken optionalA Threading.CancellationToken .Returns
TaskA Tasks.Task representing the wait operation.Remarks
cancellationToken is signaled, this method will throw OperationCanceledException . WaitForResourceAsync(string, IEnumerable<string>, CancellationToken) Section titled WaitForResourceAsync(string, IEnumerable<string>, CancellationToken)Task<string> KnownResourceStates for common states. public class ResourceNotificationService{ public Task<string> WaitForResourceAsync( string resourceName, IEnumerable<string> targetStates, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
resourceName stringThe name of the resource.targetStates IEnumerable<string> The set of states to wait for the resource to transition to one of. See KnownResourceStates for common states.cancellationToken CancellationToken optionalA cancellation token that cancels the wait operation when signaled.Returns
Task<string> A Tasks.Task`1 representing the wait operation and which of the target states the resource reached.Remarks
cancellationToken is signaled, this method will throw OperationCanceledException . WaitForResourceAsync(string, Func<ResourceEvent, bool>, CancellationToken) Section titled WaitForResourceAsync(string, Func<ResourceEvent, bool>, CancellationToken)Taskpublic class ResourceNotificationService{ public Task<ResourceEvent> WaitForResourceAsync( string resourceName, Func<ResourceEvent, bool> predicate, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
resourceName stringThe name of the resource.predicateFunc<ResourceEvent, bool> A predicate which is evaluated for each ResourceEvent for the selected resource.cancellationToken CancellationToken optionalA cancellation token that cancels the wait operation when signaled.Returns
Task<ResourceEvent> A Tasks.Task`1 representing the wait operation and which of the target states the resource reached.Remarks
true. If the predicate isn't satisfied before cancellationToken is signaled, this method will throw OperationCanceledException . WaitForResourceHealthyAsync(string, CancellationToken) Section titled WaitForResourceHealthyAsync(string, CancellationToken)Taskpublic class ResourceNotificationService{ public Task<ResourceEvent> WaitForResourceHealthyAsync( string resourceName, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
resourceName stringThe name of the resource.cancellationToken CancellationToken optionalThe cancellation token.Returns
Task<ResourceEvent> A task.Remarks
This method returns a task that will complete with the resource is healthy. A resource without Health annotations will be considered healthy once it reaches a Known state.
If the resource enters an unavailable state such as Known then this method will continue to wait to enable scenarios where a resource could be restarted and recover. To control this behavior use Resource or configure the default behavior with Resource.
WaitForResourceHealthyAsync(string, WaitBehavior, CancellationToken) Section titled WaitForResourceHealthyAsync(string, WaitBehavior, CancellationToken)Taskpublic class ResourceNotificationService{ public Task<ResourceEvent> WaitForResourceHealthyAsync( string resourceName, WaitBehavior waitBehavior, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
resourceName stringThe name of the resource.waitBehavior WaitcancellationToken CancellationToken optionalThe cancellation token.Returns
Task<ResourceEvent> A task.Remarks
This method returns a task that will complete with the resource is healthy. A resource without Health annotations will be considered healthy once it reaches a Known state. The Wait controls how the wait operation behaves when the resource enters an unavailable state such as Known.
When Wait is specified the wait operation will continue to wait until the resource reaches a Known state.
When Wait is specified the wait operation will throw a Distributed if the resource enters an unavailable state.
WatchAsync(CancellationToken) Section titled WatchAsync(CancellationToken)Ipublic class ResourceNotificationService{ public IAsyncEnumerable<ResourceEvent> WatchAsync( CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
cancellationToken CancellationToken optional