Пример #1
0
        public SystemContext(IOptions <OspSystemConfiguration> systemConfiguration,
                             IDistributedWithPubSubCache distributedWithPubSubCache)
        {
            ArgumentValidation.Validate(nameof(systemConfiguration), systemConfiguration);
            ArgumentValidation.Validate(nameof(distributedWithPubSubCache), distributedWithPubSubCache);

            _systemConfiguration        = systemConfiguration.Value;
            _distributedWithPubSubCache = distributedWithPubSubCache;

            var sharedSettings = new MongoConnectionOptions
            {
                MongoDbHost          = _systemConfiguration.DatabaseHost,
                MongoDbUsername      = _systemConfiguration.AdminUser,
                MongoDbPassword      = _systemConfiguration.AdminUserPassword,
                AuthenticationSource = _systemConfiguration.AuthenticationDatabaseName
            };

            _ckCaches = new ConcurrentDictionary <string, ICkCache>();

            _repositoryClient = new MongoRepositoryClient(sharedSettings);
            OspSystemDatabase = _repositoryClient.GetRepository(_systemConfiguration.SystemDatabaseName);

            _tenantCollection        = OspSystemDatabase.GetCollection <SystemEntities.OspTenant>();
            _configurationCollection = OspSystemDatabase.GetCollection <OspConfiguration>();

            var sub = _distributedWithPubSubCache.Subscribe <string>(CacheCommon.KeyTenantUpdate);

            sub.OnMessage(message =>
            {
                RemoveCkCache(message.Message);
                return(Task.CompletedTask);
            });
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="systemContext"></param>
        /// <param name="distributedCache"></param>
        public ServiceHookService(ISystemContext systemContext, IDistributedWithPubSubCache distributedCache)
        {
            _systemContext = systemContext;
            var sub = distributedCache.Subscribe <string>(CacheCommon.KeyTenantUpdate);

            sub.OnMessage(async message => { await SyncDataSourceAndCreateJobsAsync(); });
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sgIdentityProviderStore">Data storage of identity providers</param>
        /// <param name="schemeProvider">Scheme provider</param>
        /// <param name="authSchemeCreatorFactory">Factory to resolve creators of auth providers.</param>
        /// <param name="distributedCache">Memory cache do distribute events (if identity providers has changed.</param>
        public DynamicAuthSchemeService(IOspIdentityProviderStore sgIdentityProviderStore,
                                        IAuthenticationSchemeProvider schemeProvider,
                                        IAuthSchemeCreatorFactory authSchemeCreatorFactory,
                                        IDistributedWithPubSubCache distributedCache)
        {
            _sgIdentityProviderStore  = sgIdentityProviderStore;
            _schemeProvider           = schemeProvider;
            _authSchemeCreatorFactory = authSchemeCreatorFactory;

            var channel = distributedCache.Subscribe <string>(CacheCommon.KeyIdentityProviderUpdate);

            channel.OnMessage(async message => { await ConfigureAsync(); });
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ospService">The OSP service</param>
        /// <param name="distributedWithPubSubCache"></param>
        public SchemaContext(IOspService ospService, IDistributedWithPubSubCache distributedWithPubSubCache)
        {
            _ospService = ospService;

            _cache = new MemoryCache(new MemoryCacheOptions
            {
                SizeLimit = 64
            });

            var sub = distributedWithPubSubCache.Subscribe <string>(CacheCommon.KeyTenantUpdate);

            sub.OnMessage(message =>
            {
                _cache.Remove(message.Message.MakeKey());
                return(Task.CompletedTask);
            });
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="clientStore">Client store object to access all available clients.</param>
 /// <param name="distributedCache">Instance of distributed cache</param>
 public CorsPolicyProvider(IOspClientStore clientStore, IDistributedWithPubSubCache distributedCache)
 {
     _clientStore = clientStore;
     _channel     = distributedCache.Subscribe <string>(CacheCommon.KeyCorsClients);
     _channel.OnMessage(OnInvalidateData);
 }