public override async Task DeleteAsync(ActorActivatorState obj) { var state = (State)obj; await DisposeCore(state.Actor); await DisposeCore(state.Scope); }
public async Task DeleteAsync_NotDisposable() { var activator = new DefaultActorActivator(); var host = new ActorHost(ActorTypeInformation.Get(typeof(TestActor)), ActorId.CreateRandom(), JsonSerializerDefaults.Web, NullLoggerFactory.Instance, ActorProxy.DefaultProxyFactory); var actor = new TestActor(host); var state = new ActorActivatorState(actor); await activator.DeleteAsync(state); // does not throw }
public async Task DeleteAsync_NotDisposable() { var activator = new DefaultActorActivator(); var host = ActorHost.CreateForTest <TestActor>(); var actor = new TestActor(host); var state = new ActorActivatorState(actor); await activator.DeleteAsync(state); // does not throw }
/// <summary> /// Deletes the actor instance and cleans up all associated resources. /// </summary> /// <param name="state"> /// The <see cref="ActorActivatorState" /> instance that was created during creation of the actor. /// </param> /// <returns> /// A task that represents the asynchronous completion of the operation. /// </returns> /// <remarks> /// Implementations should not interact with lifecycle callback methods on the <see cref="Actor" /> type. /// These methods will be called by the runtime. /// </remarks> public async override ValueTask DeleteAsync(ActorActivatorState state) { if (state.Actor is IAsyncDisposable asyncDisposable) { await asyncDisposable.DisposeAsync(); } else if (state.Actor is IDisposable disposable) { disposable.Dispose(); } }
public async Task DeleteAsync_AsyncDisposable() { var activator = new DefaultActorActivator(); var host = new ActorHost(ActorTypeInformation.Get(typeof(AsyncDisposableActor)), ActorId.CreateRandom(), JsonSerializerDefaults.Web, NullLoggerFactory.Instance, ActorProxy.DefaultProxyFactory); var actor = new AsyncDisposableActor(host); var state = new ActorActivatorState(actor); await activator.DeleteAsync(state); Assert.True(actor.IsDisposed); }
public async Task DeleteAsync_Disposable() { var activator = new DefaultActorActivator(); var host = new ActorHost(ActorTypeInformation.Get(typeof(DisposableActor)), ActorId.CreateRandom(), NullLoggerFactory.Instance); var actor = new DisposableActor(host); var state = new ActorActivatorState(actor); await activator.DeleteAsync(state); // does not throw Assert.True(actor.IsDisposed); }
public async Task DeleteAsync_AsyncDisposable() { var activator = new DefaultActorActivator(); var host = ActorHost.CreateForTest <AsyncDisposableActor>(); var actor = new AsyncDisposableActor(host); var state = new ActorActivatorState(actor); await activator.DeleteAsync(state); Assert.True(actor.IsDisposed); }
public override Task DeleteAsync(ActorActivatorState state) { DeleteCallCount++; return(base.DeleteAsync(state)); }
/// <summary> /// Deletes the actor instance and cleans up all associated resources. /// </summary> /// <param name="state"> /// The <see cref="ActorActivatorState" /> instance that was created during creation of the actor. /// </param> /// <returns> /// A task that represents the asynchronous completion of the operation. /// </returns> /// <remarks> /// Implementations should not interact with lifecycle callback methods on the <see cref="Actor" /> type. /// These methods will be called by the runtime. /// </remarks> public abstract Task DeleteAsync(ActorActivatorState state);