public async Task UpsertMetadataAsync(EventMetadata metadata) { _ = metadata ?? throw new ArgumentNullException(nameof(metadata)); try { if (State.Metadata != null && metadata.ResourceUriString != this.GetPrimaryKeyString()) { throw new ResourceIdentityMismatchException("Metadata resource mismatch."); } State.Metadata = metadata; ISigmaAlgebra resourceList = GrainFactory.GetGrain <ISigmaAlgebra>("resourcelist"); await resourceList.AddAsync(metadata.ResourceUriString); await WriteStateAsync(); } catch (Exception ex) { await logger?.LogErrorAsync(ex, $"Pi-system UpdateMetadataAsync '{metadata.ResourceUriString}'"); await NotifyErrorAsync(ex); throw; } }
public async Task ClearAsync() { try { foreach (ISubscription item in State.Subscriptions.Values) { string id = await item.GetIdAsync(); if (id != null) { await UnsubscribeAsync(id); } } if (State.Metadata != null) { ISigmaAlgebra resourceList = GrainFactory.GetGrain <ISigmaAlgebra>("resourcelist"); await resourceList.RemoveAsync(State.Metadata.ResourceUriString); } await ClearStateAsync(); } catch (Exception ex) { await logger?.LogErrorAsync(ex, "Pi-system clear."); await NotifyErrorAsync(ex); throw; } }
public async Task ClearAsync() { foreach (ISubscription item in State.Subscriptions.Values) { string id = await item.GetIdAsync(); if (id != null) { await UnsubscribeAsync(id); } } if (State.Metadata != null) { ISigmaAlgebra resourceList = GrainFactory.GetGrain <ISigmaAlgebra>("resourcelist"); await resourceList.RemoveAsync(State.Metadata.ResourceUriString); } await ClearStateAsync(); }
public async Task UpsertMetadataAsync(EventMetadata metadata) { if (metadata == null) { throw new ArgumentNullException("metadata"); } if (State.Metadata != null && metadata.ResourceUriString != this.GetPrimaryKeyString()) { Trace.TraceWarning("Resource metadata identifier mismatch failed for resource metadata upsert."); Exception ex = new ResourceIdentityMismatchException(String.Format("Resource metadata {0} does not match grain identity {1}", State.Metadata.ResourceUriString, this.GetPrimaryKeyString())); await NotifyErrorAsync(ex); throw ex; } State.Metadata = metadata; ISigmaAlgebra resourceList = GrainFactory.GetGrain <ISigmaAlgebra>("resourcelist"); await resourceList.AddAsync(metadata.ResourceUriString); await WriteStateAsync(); }
/// <summary> /// Returns of list of resources in Orleans. /// </summary> /// <returns>Array of resource URIs.</returns> public async Task <List <string> > GetSigmaAlgebraAsync() { ISigmaAlgebra resourceList = client.GetGrain <ISigmaAlgebra>("resourcelist"); return(await resourceList.GetListAsync()); }
public async Task <ListContinuationToken> GetSigmaAlgebraAsync(ListContinuationToken token) { ISigmaAlgebra resourceList = client.GetGrain <ISigmaAlgebra>("resourcelist"); return(await resourceList.GetListAsync(token)); }