public Publisher(Options?options, IServiceProvider services) { options ??= new(); Services = services; Id = options.Id; ChannelHub = options.ChannelHub; OwnsChannelHub = options.OwnsChannelHub; PublicationFactory = options.PublicationFactory; PublicationGeneric = options.PublicationGeneric; PublicationExpirationTime = options.PublicationExpirationTime; PublicationIdGenerator = options.PublicationIdGenerator; SubscriptionProcessorFactory = options.SubscriptionProcessorFactory; SubscriptionProcessorGeneric = options.SubscriptionProcessorGeneric; SubscriptionExpirationTime = options.SubscriptionExpirationTime; Clocks = options.Clocks ?? Services.Clocks(); var concurrencyLevel = HardwareInfo.GetProcessorCountPo2Factor(4); var capacity = OSInfo.IsWebAssembly ? 509 : 7919; Publications = new ConcurrentDictionary <ComputedInput, IPublication>(concurrencyLevel, capacity); PublicationsById = new ConcurrentDictionary <Symbol, IPublication>(concurrencyLevel, capacity); ChannelProcessors = new ConcurrentDictionary <Channel <BridgeMessage>, PublisherChannelProcessor>(concurrencyLevel, capacity); OnChannelAttachedHandler = OnChannelAttached; OnChannelDetachedHandler = OnChannelDetachedAsync; ChannelHub.Detached += OnChannelDetachedHandler; // Must go first ChannelHub.Attached += OnChannelAttachedHandler; }
public PresenceService( Options?options, IServiceProvider services, ILogger <PresenceService>?log = null) { options ??= new(); Log = log ?? NullLogger <PresenceService> .Instance; UpdatePeriod = options.UpdatePeriod; Clocks = options.Clocks ?? services.Clocks(); Auth = services.GetRequiredService <IAuth>(); SessionResolver = services.GetRequiredService <ISessionResolver>(); }
public TransientOperationScope(IServiceProvider services) { var loggerFactory = services.GetService <ILoggerFactory>(); Log = loggerFactory?.CreateLogger(GetType()) ?? NullLogger.Instance; Services = services; Clocks = services.Clocks(); AgentInfo = services.GetRequiredService <AgentInfo>(); Operation = new TransientOperation(true) { AgentId = AgentInfo.Id, StartTime = Clocks.SystemClock.Now, }; CommandContext = services.GetRequiredService <CommandContext>(); }
public static IMomentClock SystemClock(this IServiceProvider services) => services.Clocks().SystemClock;