/// <summary> /// Initializes a new instance of the <see cref="ApolloSubscriptionServer{TSchema}" /> class. /// </summary> /// <param name="schema">The schema instance this sever will use for various comparisons.</param> /// <param name="options">The user configured options for this server.</param> /// <param name="eventRouter">The listener watching for new events that need to be communicated /// to clients managed by this server.</param> /// <param name="logger">The logger to record server events to, if any.</param> public ApolloSubscriptionServer( TSchema schema, SubscriptionServerOptions <TSchema> options, ISubscriptionEventRouter eventRouter, IGraphEventLogger logger = null) { _schema = Validation.ThrowIfNullOrReturn(schema, nameof(schema)); _serverOptions = Validation.ThrowIfNullOrReturn(options, nameof(options)); _eventRouter = Validation.ThrowIfNullOrReturn(eventRouter, nameof(eventRouter)); _clients = new HashSet <ApolloClientProxy <TSchema> >(); _eventSendSemaphore = new SemaphoreSlim(_serverOptions.MaxConcurrentClientNotifications); _logger = logger != null ? new ApolloServerEventLogger <TSchema>(this, logger) : null; _subCountByName = new Dictionary <SubscriptionEventName, HashSet <ApolloClientProxy <TSchema> > >( SubscriptionEventNameEqualityComparer.Instance); this.Id = Guid.NewGuid().ToString(); }
/// <summary> /// Initializes a new instance of the <see cref="AzureServiceBusSubscriptionListener" /> class. /// </summary> /// <param name="loggerFactory">The logger factory.</param> /// <param name="router">The internal router to which deserialzied messages /// should be pushed.</param> /// <param name="cnnString">The CNN string.</param> /// <param name="topic">The topic.</param> /// <param name="subscriptionName">Name of the subscription.</param> public GraphQLAzureServiceBusListenerService( ILoggerFactory loggerFactory, ISubscriptionEventRouter router, string cnnString, string topic, string subscriptionName) { _logger = loggerFactory?.CreateLogger("GraphQLAzureServiceBusDemo"); _router = Validation.ThrowIfNullOrReturn(router, nameof(router)); _cnnString = Validation.ThrowIfNullWhiteSpaceOrReturn(cnnString, nameof(cnnString), false); _topic = Validation.ThrowIfNullWhiteSpaceOrReturn(topic, nameof(topic), false); _subscription = Validation.ThrowIfNullWhiteSpaceOrReturn(subscriptionName, nameof(subscriptionName), false); _serializationOptions = new JsonSerializerOptions(); _serializationOptions.PropertyNameCaseInsensitive = true; _serializationOptions.WriteIndented = true; _serializationOptions.Converters.Add(new SubscriptionEventConverter()); }
/// <summary> /// Initializes a new instance of the <see cref="InProcessSubscriptionPublisher"/> class. /// </summary> /// <param name="eventRouter">The event router to push messages to.</param> public InProcessSubscriptionPublisher(ISubscriptionEventRouter eventRouter = null) { _eventRouter = Validation.ThrowIfNullOrReturn(eventRouter, nameof(eventRouter)); }