public async Task <bool> RenewResourceObserverLeaseAsync(string resourceUriString, string leaseKey, TimeSpan lifetime) { IPiSystem resource = GetPiSystem(resourceUriString); return(await resource.RenewObserverLeaseAsync(leaseKey, lifetime)); }
public async Task <ActionResult <IEnumerable <string> > > GetPiSystemSubscriptionList(string resourceUriString) { try { if (string.IsNullOrEmpty(resourceUriString)) { throw new ArgumentNullException("resourceUriString"); } IPiSystem pisystem = graphManager.GetPiSystem(resourceUriString); if (pisystem == null) { logger?.LogWarning($"Pi-system '{resourceUriString}' is null."); } else { logger?.LogInformation($"Returned pi-system '{resourceUriString}'."); } IEnumerable <string> list = await pisystem.GetSubscriptionListAsync(); return(StatusCode(200, list)); } catch (Exception ex) { logger?.LogError(ex, $"Error getting subscriptions from pi-system."); return(StatusCode(500, ex.Message)); } }
/// <summary> /// Add an error observer to a resource. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <param name="lifetime">The lifetime of the lease.</param> /// <param name="observer">Error observer to receive events.</param> /// <returns>A unique string for the lease key, whic is used to refresh the lease for the observer.</returns> public async Task <string> AddResourceObserverAsync(string resourceUriString, TimeSpan lifetime, ErrorObserver observer) { IErrorObserver objRef = await client.CreateObjectReference <IErrorObserver>(observer); IPiSystem resource = GetPiSystem(resourceUriString); return(await resource.AddObserverAsync(lifetime, objRef)); }
/// <summary> /// Adds or updates a resource's metadata. /// </summary> /// <param name="metadata">Metadata that describes the resource.</param> /// <returns></returns> public async Task UpsertPiSystemMetadataAsync(EventMetadata metadata) { Uri uri = new Uri(metadata.ResourceUriString); metadata.ResourceUriString = uri.ToCanonicalString(false); IPiSystem resource = GetPiSystem(metadata.ResourceUriString); await resource.UpsertMetadataAsync(metadata); }
public async Task UnsubscribeAsync(string subscriptionUriString, string identity) { Uri uri = new Uri(subscriptionUriString); string resourceUriString = uri.ToCanonicalString(false, true); IPiSystem resource = GetPiSystem(resourceUriString); await resource.UnsubscribeAsync(subscriptionUriString, identity); }
/// <summary> /// Unsubscribes a subscription from a resource. /// </summary> /// <param name="subscriptionUriString">Unique URI for the subscription.</param> /// <returns></returns> public async Task UnsubscribeAsync(string subscriptionUriString) { //get the resource to unsubscribe Uri uri = new Uri(subscriptionUriString); string resourceUriString = uri.ToCanonicalString(false, true); IPiSystem resource = GetPiSystem(resourceUriString); //unsubscribe from the resource await resource.UnsubscribeAsync(subscriptionUriString); }
private async Task UnsubscribeFromResourceAsync() { //unsubscribe from resource string uriString = State.Metadata.SubscriptionUriString; Uri uri = new Uri(uriString); string resourceUriString = uriString.Replace("/" + uri.Segments[uri.Segments.Length - 1], ""); IPiSystem resource = GrainFactory.GetGrain <IPiSystem>(resourceUriString); if (State.Metadata != null && !string.IsNullOrEmpty(State.Metadata.SubscriptionUriString)) { await resource.UnsubscribeAsync(State.Metadata.SubscriptionUriString); } }
public async Task <string> SubscribeAsync(string resourceUriString, SubscriptionMetadata metadata) { Uri uri = new Uri(resourceUriString); string subscriptionUriString = uri.ToCanonicalString(true) + Guid.NewGuid(); metadata.SubscriptionUriString = subscriptionUriString; ISubscription subscription = GetSubscription(subscriptionUriString); await subscription.UpsertMetadataAsync(metadata); IPiSystem resource = GetPiSystem(uri.ToCanonicalString(false)); await resource.SubscribeAsync(subscription); return(subscriptionUriString); }
private async void Sink_OnResponse(object sender, EventSinkResponseArgs e) { IPiSystem pisystem = GrainFactory.GetGrain <IPiSystem>(e.Message.ResourceUri); await pisystem.PublishAsync(e.Message); }
/// <summary> /// Clears the resource; equivalent to deleting the resource. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <returns></returns> public async Task ClearPiSystemAsync(string resourceUriString) { IPiSystem resource = GetPiSystem(resourceUriString); await resource.ClearAsync(); }
/// <summary> /// Removes an observer from a resource. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <param name="leaseKey">Unqiue string of the observer's lease.</param> /// <returns></returns> public async Task RemoveResourceObserverAsync(string resourceUriString, string leaseKey) { IPiSystem resource = GetPiSystem(resourceUriString); await resource.RemoveObserverAsync(leaseKey); }
/// <summary> /// Gets a list of subscription URIs subscribed to the resource. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <returns>Array of subscription URIs subscribed to the resource.</returns> public async Task <IEnumerable <string> > GetPiSystemSubscriptionListAsync(string resourceUriString) { IPiSystem resource = GetPiSystem(resourceUriString); return(await resource.GetSubscriptionListAsync()); }
/// <summary> /// Publishes a message to a resources with indexes. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <param name="message">Message to publishes.</param> /// <param name="indexes">Indexes used to filter subscriptions to subset.</param> /// <returns></returns> public async Task PublishAsync(string resourceUriString, EventMessage message, List <KeyValuePair <string, string> > indexes) { IPiSystem resource = GetPiSystem(resourceUriString); await resource.PublishAsync(message, indexes); }
/// <summary> /// Publishes a message to a resource. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <param name="message">Message to publish.</param> /// <returns></returns> public async Task PublishAsync(string resourceUriString, EventMessage message) { IPiSystem resource = GetPiSystem(resourceUriString); await resource.PublishAsync(message); }
public async Task <CommunicationMetrics> GetPiSystemMetricsAsync(string resourceUriString) { IPiSystem resource = GetPiSystem(resourceUriString); return(await resource.GetMetricsAsync()); }
/// <summary> /// Get a resource's metadata. /// </summary> /// <param name="resourceUriString">Unique URI that identifies the resource.</param> /// <returns>Resource's metadata.</returns> public async Task <EventMetadata> GetPiSystemMetadataAsync(string resourceUriString) { IPiSystem resource = GetPiSystem(resourceUriString); return(await resource.GetMetadataAsync()); }