示例#1
0
    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;
    }
示例#2
0
 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>();
 }
示例#3
0
    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>();
    }
示例#4
0
 public static IMomentClock SystemClock(this IServiceProvider services)
 => services.Clocks().SystemClock;