Example #1
0
 public ConfigService(IKeyValueStore keyValueStore, IMailSender mailSender)
 {
     if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
     if (mailSender == null) throw new ArgumentNullException("mailSender");
     _keyValueStore = keyValueStore;
     _mailSender = mailSender;
 }
Example #2
0
 public ConfigService(IKeyValueStore keyValueStore, IPushalotClient pushalotClient)
 {
     if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
     if (pushalotClient == null) throw new ArgumentNullException("pushalotClient");
     _keyValueStore = keyValueStore;
     _pushalotClient = pushalotClient;
 }
        private static void SaveSession(NancyContext ctx, IKeyValueStore store)
        {
            if (ctx.Request == null || ctx.Request.Session == null || !ctx.Request.Session.HasChanged)
                return;

            string id;
            if (ctx.Request.Cookies.ContainsKey(GetCookieName()))
            {
                id = ctx.Request.Cookies[GetCookieName()];
            }
            else
            {
                // TODO: Should we give a way to override how the id is generated?
                // TODO: Should we encrypt / hash the id so people can not just try out other values?
                id = Guid.NewGuid().ToString();
                ctx.Response.AddCookie(GetCookieName(), id);
            }

            IDictionary<string, object> items = new Dictionary<string, object>();
            foreach (var item in ctx.Request.Session)
            {
                items.Add(item.Key, item.Value);
            }

            store.Save(id, items);
        }
Example #4
0
        public SessionHandler(ILogger<SessionHandler> logger,
            IEnvironment environment,
            IFileSystem fileSystem,
            IKeyValueStore keyValueStore,
            IMessageBus messageBus,
            ISession session,
            ITorrentInfoRepository torrentInfoRepository,
            ITorrentMetadataRepository metadataRepository)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            if (environment == null) throw new ArgumentNullException("environment");
            if (fileSystem == null) throw new ArgumentNullException("fileSystem");
            if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
            if (messageBus == null) throw new ArgumentNullException("messageBus");
            if (session == null) throw new ArgumentNullException("session");
            if (torrentInfoRepository == null) throw new ArgumentNullException("torrentInfoRepository");
            if (metadataRepository == null) throw new ArgumentNullException("metadataRepository");

            _logger = logger;
            _environment = environment;
            _fileSystem = fileSystem;
            _keyValueStore = keyValueStore;
            _messageBus = messageBus;
            _session = session;
            _torrentInfoRepository = torrentInfoRepository;
            _metadataRepository = metadataRepository;
            _muted = new List<string>();
            _alertsThread = new Thread(ReadAlerts);
        }
Example #5
0
 public HttpServer(ILogger<HttpServer> logger, INancyBootstrapper bootstrapper, IKeyValueStore keyValueStore)
 {
     if (logger == null) throw new ArgumentNullException("logger");
     if (bootstrapper == null) throw new ArgumentNullException("bootstrapper");
     if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
     _logger = logger;
     _bootstrapper = bootstrapper;
     _keyValueStore = keyValueStore;
 }
Example #6
0
 public AdviceInterceptor(Func<IAspectEnvironment, IList<IAspect>, IList<IAspect>> getAspects, IKeyValueStore store, IEnumerable<IAspect> availableAspects, object concreteInstance, Type interfaceType)
 {
     _availableAspects = new List<IAspect>(availableAspects);
     _getAspects = getAspects;
     _keyValueStore = store;
     _concreteInstance = concreteInstance;
     _interfaceType = interfaceType;
     _aspectEnvironmentDict = new Dictionary<MethodInfo, AspectEnvironment>();
 }
Example #7
0
 public PushalotNotifier(ILogger<PushalotNotifier> logger, IPushalotClient pushalotClient, IKeyValueStore keyValueStore)
 {
     if (logger == null) throw new ArgumentNullException("logger");
     if (pushalotClient == null) throw new ArgumentNullException("pushalotClient");
     if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
     _logger = logger;
     _pushalotClient = pushalotClient;
     _keyValueStore = keyValueStore;
 }
Example #8
0
        public MonoTorrentEngine(IFileSystem fs, IMessageBus mbus, IDataRepository data, IKeyValueStore kvs)
        {
            _kvs = kvs;
            _data = data;
            _fs = fs;
            _mbus = mbus;

            _mbus.Subscribe<ISettingChanged>(SettingChanged);

            _torrentFileSavePath = Path.Combine(HdknConfig.GetPath("Paths.Data"), "Torrents");
        }
 public When_saving_a_session()
 {
     var boot = new ConfigurableBootstrapper(with =>
     {
         with.DisableAutoRegistration();
         with.Module<SessionTestModule>();
     });
     _Store = A.Fake<IKeyValueStore>();
     KeyValueStoreSessions.Enable(boot, _Store);
     _Browser = new Browser(boot);
 }
 public When_loading_a_session()
 {
     var boot = new ConfigurableBootstrapper(with =>
     {
         with.DisableAutoRegistration();
         with.Module<SessionTestModule>();
     });
     _Store = A.Fake<IKeyValueStore>();
     A.CallTo(() => _Store.Load<IDictionary<string, object>>("12345")).Returns(new Dictionary<string, object> { { "TestVariable", "TestValue" } });
     KeyValueStoreSessions.Enable(boot, _Store);
     _Browser = new Browser(boot);
 }
Example #11
0
        public MailerNotifier(ILogger<MailerNotifier> logger,
            IKeyValueStore keyValueStore,
            IMailSender mailSender)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
            if (mailSender == null) throw new ArgumentNullException("mailSender");

            _logger = logger;
            _keyValueStore = keyValueStore;
            _mailSender = mailSender;
        }
Example #12
0
 public AutoAddPlugin(IKeyValueStore keyValueStore,
     IDataRepository dataRepository,
     IBitTorrentEngine bitTorrentEngine,
     IFileSystem fileSystem,
     ITimerFactory timerFactory)
 {
     _keyValueStore = keyValueStore;
     _dataRepository = dataRepository;
     _bitTorrentEngine = bitTorrentEngine;
     _fileSystem = fileSystem;
     _timerFactory = timerFactory;
 }
Example #13
0
 public FolderScanner(IFileSystem fileSystem,
     IKeyValueStore keyValueStore,
     IAutoAddRepository autoAddRepository,
     IMessageBus messageBus)
 {
     if (fileSystem == null) throw new ArgumentNullException("fileSystem");
     if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
     if (autoAddRepository == null) throw new ArgumentNullException("autoAddRepository");
     if (messageBus == null) throw new ArgumentNullException("messageBus");
     _fileSystem = fileSystem;
     _keyValueStore = keyValueStore;
     _autoAddRepository = autoAddRepository;
     _messageBus = messageBus;
 }
Example #14
0
        public DefaultHttpServer(IKeyValueStore kvs, IFileSystem fs, IEnumerable<IApiAction> actions)
        {
            _fs = fs;
            _kvs = kvs;
            _actions = actions;

            var binding = HdknConfig.ConfigManager["WebUI.Url"];

            _listener = new HttpListener();
            _listener.Prefixes.Add(binding);
            _listener.AuthenticationSchemes = AuthenticationSchemes.Basic;

            UnzipWebUI();
        }
        private static Response LoadSession(NancyContext ctx, IKeyValueStore store)
        {
            if (ctx == null || ctx.Request == null)
                return null;

            IDictionary<string, object> items = null;
            if (ctx.Request.Cookies.ContainsKey(GetCookieName()))
            {
                var id = ctx.Request.Cookies[GetCookieName()];
                if (!string.IsNullOrEmpty(id))
                    items = store.Load<IDictionary<string, object>>(id);
            }
            ctx.Request.Session = new Session(items ?? new Dictionary<string, object>());
            return null;
        }
Example #16
0
        internal HdknTorrentManager(TorrentManager manager, IKeyValueStore kvs, IFileSystem fileSystem, IMessageBus mbus)
        {
            _manager = manager;
            _settings = new HdknTorrentSettings(manager.Settings);
            _torrent = new HdknTorrent(manager.Torrent);

            foreach (var t in _manager.TrackerManager.TrackerTiers)
            {
                foreach (var t2 in t.GetTrackers())
                {
                    _trackers.Add(new HdknTracker(t2));
                }
            }

            _kvs = kvs;
            _fileSystem = fileSystem;
            _mbus = mbus;
            _startTime = DateTime.Now;
        }
 public InMemoryKeyValueCache(IKeyValueStore store)
 {
     _store = store;
 }
 public TopicActor(IKeyValueStore <Subscribers> subscriptionStore)
 {
     _subscriptionStore = subscriptionStore;
 }
Example #19
0
 public ProductInfoStore(IKeyValueStore <string, string> productInfoEntityStore, string edgeProductInfo)
 {
     this.productInfoEntityStore = Preconditions.CheckNotNull(productInfoEntityStore, nameof(productInfoEntityStore));
     this.edgeProductInfo        = Preconditions.CheckNotNull(edgeProductInfo, nameof(edgeProductInfo));
 }
 public WrappedKeyValueStore(IKeyValueStore <Bytes, byte[]> wrapped, ISerDes <K> keySerdes, ISerDes <V> valueSerdes)
     : base(wrapped)
 {
     this.keySerdes   = keySerdes;
     this.valueSerdes = valueSerdes;
 }
Example #21
0
 public RocksDbWriter(IConfigurationProvider config, IKeyValueStore store)
 {
     _config    = config;
     _store     = store;
     _writeLock = new Semaphore(1, 2, "Sir.RocksDb");
 }
Example #22
0
 public FileStore(IKeyValueStore keyValueStore, string user)
 {
     _keyValueStore = keyValueStore;
     _user = user;
 }
Example #23
0
 public ListDirectories(IKeyValueStore keyValueStore, IFileSystem fileSystem)
 {
     _keyValueStore = keyValueStore;
     _fileSystem = fileSystem;
 }
 public MockDelayKeyValueStore(IKeyValueStore fallbackStore)
 {
     this.fallbackStore = fallbackStore;
 }
Example #25
0
 internal CassandraResourceStore(IKeyValueStore <string, IdentityResource> identityStore, IKeyValueStore <string, ApiResource> apiStore)
 {
     _identityStore = identityStore;
     _apiStore      = apiStore;
 }
Example #26
0
 public DefaultHttpServer(IKeyValueStore keyValueStore, IRegistryReader registryReader, IFileSystem fileSystem)
 {
     _keyValueStore = keyValueStore;
     _registryReader = registryReader;
     _fileSystem = fileSystem;
 }
 public GraphSettingsService(IKeyValueStore keyValueStore)
 {
     _keyValueStore = keyValueStore;
 }
Example #28
0
 public bool FirstTime(IKeyValueStore keyValueStore)
 {
     var firstTime = keyValueStore.GetValue("FirstTime", true);
     keyValueStore.SetValue("FirstTime", false);
     return firstTime;
 }
Example #29
0
 // Constructor used at run-time
 public MainVM(IStringResources stringResources, IKeyValueStore keyValueStore)
 {
     Message = FirstTime(keyValueStore)
         ? stringResources.Welcome
         : stringResources.HelloAgain;
 }
Example #30
0
 public PatriciaTree(IKeyValueStore keyValueStore)
     : this(keyValueStore, EmptyTreeHash, false, true)
 {
 }
Example #31
0
        protected override void Load(ContainerBuilder builder)
        {
            // IMetricsListener
            builder.Register(
                c =>
                this.metricsConfig.Enabled
                            ? new MetricsListener(this.metricsConfig.ListenerConfig, c.Resolve <IMetricsProvider>())
                            : new NullMetricsListener() as IMetricsListener)
            .As <IMetricsListener>()
            .SingleInstance();

            // IMetricsProvider
            builder.Register(
                c =>
                this.metricsConfig.Enabled
                            ? new MetricsProvider(MetricsConstants.EdgeHubMetricPrefix, this.iothubHostName, this.edgeDeviceId)
                            : new NullMetricsProvider() as IMetricsProvider)
            .As <IMetricsProvider>()
            .SingleInstance();

            // ISignatureProvider
            builder.Register(
                c =>
            {
                ISignatureProvider signatureProvider = this.edgeHubConnectionString.Map(
                    cs =>
                {
                    IotHubConnectionStringBuilder csBuilder = IotHubConnectionStringBuilder.Create(cs);
                    return(new SharedAccessKeySignatureProvider(csBuilder.SharedAccessKey) as ISignatureProvider);
                })
                                                       .GetOrElse(
                    () =>
                {
                    string edgeHubGenerationId = this.edgeHubGenerationId.Expect(() => new InvalidOperationException("Generation ID missing"));
                    string workloadUri         = this.workloadUri.Expect(() => new InvalidOperationException("workloadUri is missing"));
                    string workloadApiVersion  = this.workloadApiVersion.Expect(() => new InvalidOperationException("workloadUri version is missing"));
                    return(new HttpHsmSignatureProvider(this.edgeHubModuleId, edgeHubGenerationId, workloadUri, workloadApiVersion, Constants.WorkloadApiVersion) as ISignatureProvider);
                });
                return(signatureProvider);
            })
            .As <ISignatureProvider>()
            .SingleInstance();

            // Detect system environment
            builder.Register(c => new SystemEnvironment())
            .As <ISystemEnvironment>()
            .SingleInstance();

            // DataBase options
            builder.Register(c => new RocksDbOptionsProvider(c.Resolve <ISystemEnvironment>(), this.optimizeForPerformance, this.storageMaxTotalWalSize, this.storageLogLevel))
            .As <IRocksDbOptionsProvider>()
            .SingleInstance();

            // IDbStoreProvider
            builder.Register(
                c =>
            {
                var loggerFactory = c.Resolve <ILoggerFactory>();
                ILogger logger    = loggerFactory.CreateLogger(typeof(RoutingModule));

                if (this.usePersistentStorage)
                {
                    // Create partitions for messages and twins
                    var partitionsList = new List <string> {
                        Core.Constants.MessageStorePartitionKey, Core.Constants.TwinStorePartitionKey, Core.Constants.CheckpointStorePartitionKey
                    };
                    try
                    {
                        IDbStoreProvider dbStoreprovider = DbStoreProvider.Create(
                            c.Resolve <IRocksDbOptionsProvider>(),
                            this.storagePath,
                            partitionsList);
                        logger.LogInformation($"Created persistent store at {this.storagePath}");
                        return(dbStoreprovider);
                    }
                    catch (Exception ex) when(!ExceptionEx.IsFatal(ex))
                    {
                        logger.LogError(ex, "Error creating RocksDB store. Falling back to in-memory store.");
                        return(new InMemoryDbStoreProvider());
                    }
                }
                else
                {
                    logger.LogInformation($"Using in-memory store");
                    return(new InMemoryDbStoreProvider());
                }
            })
            .As <IDbStoreProvider>()
            .SingleInstance();

            // IProductInfoStore
            builder.Register(
                c =>
            {
                var storeProvider = c.Resolve <IStoreProvider>();
                IKeyValueStore <string, string> entityStore = storeProvider.GetEntityStore <string, string>("ProductInfo");
                return(new ProductInfoStore(entityStore, this.productInfo));
            })
            .As <IProductInfoStore>()
            .SingleInstance();

            // Task<Option<IEncryptionProvider>>
            builder.Register(
                async c =>
            {
                Option <IEncryptionProvider> encryptionProviderOption = await this.workloadUri
                                                                        .Map(
                    async uri =>
                {
                    var encryptionProvider = await EncryptionProvider.CreateAsync(
                        this.storagePath,
                        new Uri(uri),
                        this.workloadApiVersion.Expect(() => new InvalidOperationException("Missing workload API version")),
                        Constants.WorkloadApiVersion,
                        this.edgeHubModuleId,
                        this.edgeHubGenerationId.Expect(() => new InvalidOperationException("Missing generation ID")),
                        Constants.InitializationVectorFileName) as IEncryptionProvider;
                    return(Option.Some(encryptionProvider));
                })
                                                                        .GetOrElse(() => Task.FromResult(Option.None <IEncryptionProvider>()));
                return(encryptionProviderOption);
            })
            .As <Task <Option <IEncryptionProvider> > >()
            .SingleInstance();

            // IStoreProvider
            builder.Register(c => new StoreProvider(c.Resolve <IDbStoreProvider>()))
            .As <IStoreProvider>()
            .SingleInstance();

            // ITokenProvider
            builder.Register(c => new ClientTokenProvider(c.Resolve <ISignatureProvider>(), this.iothubHostName, this.edgeDeviceId, this.edgeHubModuleId, TimeSpan.FromHours(1)))
            .Named <ITokenProvider>("EdgeHubClientAuthTokenProvider")
            .SingleInstance();

            // ITokenProvider
            builder.Register(
                c =>
            {
                string deviceId = WebUtility.UrlEncode(this.edgeDeviceId);
                string moduleId = WebUtility.UrlEncode(this.edgeHubModuleId);
                return(new ClientTokenProvider(c.Resolve <ISignatureProvider>(), this.iothubHostName, deviceId, moduleId, TimeSpan.FromHours(1)));
            })
            .Named <ITokenProvider>("EdgeHubServiceAuthTokenProvider")
            .SingleInstance();

            builder.Register(
                c =>
            {
                var loggerFactory = c.Resolve <ILoggerFactory>();
                var logger        = loggerFactory.CreateLogger <RoutingModule>();
                return(Proxy.Parse(this.proxy, logger));
            })
            .As <Option <IWebProxy> >()
            .SingleInstance();

            // Task<IDeviceScopeIdentitiesCache>
            builder.Register(
                async c =>
            {
                IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache;
                if (this.authenticationMode == AuthenticationMode.CloudAndScope || this.authenticationMode == AuthenticationMode.Scope)
                {
                    var edgeHubTokenProvider = c.ResolveNamed <ITokenProvider>("EdgeHubServiceAuthTokenProvider");
                    var proxy = c.Resolve <Option <IWebProxy> >();
                    IDeviceScopeApiClient securityScopesApiClient = new DeviceScopeApiClient(this.iothubHostName, this.edgeDeviceId, this.edgeHubModuleId, 10, edgeHubTokenProvider, proxy);
                    IServiceProxy serviceProxy = new ServiceProxy(securityScopesApiClient);
                    IKeyValueStore <string, string> encryptedStore = await GetEncryptedStore(c, "DeviceScopeCache");
                    deviceScopeIdentitiesCache = await DeviceScopeIdentitiesCache.Create(serviceProxy, encryptedStore, this.scopeCacheRefreshRate);
                }
                else
                {
                    deviceScopeIdentitiesCache = new NullDeviceScopeIdentitiesCache();
                }

                return(deviceScopeIdentitiesCache);
            })
            .As <Task <IDeviceScopeIdentitiesCache> >()
            .AutoActivate()
            .SingleInstance();

            // Task<ICredentialsCache>
            builder.Register(
                async c =>
            {
                ICredentialsCache underlyingCredentialsCache;
                if (this.persistTokens)
                {
                    IKeyValueStore <string, string> encryptedStore = await GetEncryptedStore(c, "CredentialsCache");
                    return(new PersistedTokenCredentialsCache(encryptedStore));
                }
                else
                {
                    underlyingCredentialsCache = new NullCredentialsCache();
                }

                ICredentialsCache credentialsCache = new CredentialsCache(underlyingCredentialsCache);
                return(credentialsCache);
            })
            .As <Task <ICredentialsCache> >()
            .SingleInstance();

            // Task<IAuthenticator>
            builder.Register(
                async c =>
            {
                IAuthenticator tokenAuthenticator;
                IAuthenticator certificateAuthenticator;
                IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache;
                var credentialsCacheTask = c.Resolve <Task <ICredentialsCache> >();
                // by default regardless of how the authenticationMode, X.509 certificate validation will always be scoped
                deviceScopeIdentitiesCache = await c.Resolve <Task <IDeviceScopeIdentitiesCache> >();
                certificateAuthenticator   = new DeviceScopeCertificateAuthenticator(deviceScopeIdentitiesCache, new NullAuthenticator(), this.trustBundle, true);
                switch (this.authenticationMode)
                {
                case AuthenticationMode.Cloud:
                    tokenAuthenticator = await this.GetCloudTokenAuthenticator(c);
                    break;

                case AuthenticationMode.Scope:
                    tokenAuthenticator = new DeviceScopeTokenAuthenticator(deviceScopeIdentitiesCache, this.iothubHostName, this.edgeDeviceHostName, new NullAuthenticator(), true, true);
                    break;

                default:
                    IAuthenticator cloudTokenAuthenticator = await this.GetCloudTokenAuthenticator(c);
                    tokenAuthenticator = new DeviceScopeTokenAuthenticator(deviceScopeIdentitiesCache, this.iothubHostName, this.edgeDeviceHostName, cloudTokenAuthenticator, true, true);
                    break;
                }

                ICredentialsCache credentialsCache = await credentialsCacheTask;
                return(new Authenticator(tokenAuthenticator, certificateAuthenticator, credentialsCache) as IAuthenticator);
            })
            .As <Task <IAuthenticator> >()
            .SingleInstance();

            // IClientCredentialsFactory
            builder.Register(c => new ClientCredentialsFactory(c.Resolve <IIdentityProvider>(), this.productInfo))
            .As <IClientCredentialsFactory>()
            .SingleInstance();

            // ConnectionReauthenticator
            builder.Register(
                async c =>
            {
                var edgeHubCredentials               = c.ResolveNamed <IClientCredentials>("EdgeHubCredentials");
                var connectionManagerTask            = c.Resolve <Task <IConnectionManager> >();
                var authenticatorTask                = c.Resolve <Task <IAuthenticator> >();
                var credentialsCacheTask             = c.Resolve <Task <ICredentialsCache> >();
                var deviceScopeIdentitiesCacheTask   = c.Resolve <Task <IDeviceScopeIdentitiesCache> >();
                var deviceConnectivityManager        = c.Resolve <IDeviceConnectivityManager>();
                IConnectionManager connectionManager = await connectionManagerTask;
                IAuthenticator authenticator         = await authenticatorTask;
                ICredentialsCache credentialsCache   = await credentialsCacheTask;
                IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache = await deviceScopeIdentitiesCacheTask;
                var connectionReauthenticator = new ConnectionReauthenticator(
                    connectionManager,
                    authenticator,
                    credentialsCache,
                    deviceScopeIdentitiesCache,
                    TimeSpan.FromMinutes(5),
                    edgeHubCredentials.Identity,
                    deviceConnectivityManager);
                return(connectionReauthenticator);
            })
            .As <Task <ConnectionReauthenticator> >()
            .SingleInstance();

            base.Load(builder);
        }
 public PersistedTokenCredentialsCache(IKeyValueStore <string, string> encryptedStore)
 {
     this.encryptedStore = Preconditions.CheckNotNull(encryptedStore, nameof(encryptedStore));
 }
 public DebuggingKeyValueStore(IKeyValueStore real)
 {
     _real = real;
 }
Example #34
0
        public WorkerRole()
        {
            var container      = new WindsorContainer();
            var serviceLocator = new WindsorServiceLocator(container);

            _configurationValueProvider = new AzureConfigurationValueProvider();
            var storageConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.StorageConnectionString);
            var clusterLockContainer    = _configurationValueProvider.GetValue(ConfigurationKeys.ClusterLockContainer);
            var clusterLockRootPath     = _configurationValueProvider.GetValue(ConfigurationKeys.ClusterLockRootPath);
            var headersText             = _configurationValueProvider.GetValue(ConfigurationKeys.TabSeparatedCustomEsHttpHeaders);
            var headers = new List <KeyValuePair <string, string> >();

            if (headersText != null)
            {
                foreach (var header in headersText.Split('\t'))
                {
                    var strings = header.Split(new [] { ": " }, StringSplitOptions.RemoveEmptyEntries);
                    if (strings.Length == 2)
                    {
                        headers.Add(new KeyValuePair <string, string>(strings[0], strings[1]));
                    }
                }
            }

            int bulkBatchSize       = 100;
            var bulkBatchSizeString = _configurationValueProvider.GetValue(ConfigurationKeys.BulkBatchSize);

            int.TryParse(bulkBatchSizeString, out bulkBatchSize);

            var servicebusConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.ServiceBusConnectionString);

            container.Register(
                Component.For <IElasticsearchClient>()
                .ImplementedBy <ElasticsearchClient>()
                .LifestyleSingleton(),
                Component.For <Orchestrator>()
                .ImplementedBy <Orchestrator>()
                .LifestyleSingleton(),
                Component.For <MasterScheduler>()
                .ImplementedBy <MasterScheduler>()
                .LifestyleSingleton(),
                Component.For <IConfigurationValueProvider>()
                .Instance(_configurationValueProvider),
                Component.For <IServiceLocator>()
                .Instance(serviceLocator),
                Component.For <IActorConfiguration>()
                .Instance(
                    ActorDescriptors.FromAssemblyContaining <ShardRangeActor>()
                    .ToConfiguration().UpdateParallelism(_configurationValueProvider)),
                Component.For <ISourceConfiguration>()
                .ImplementedBy <TableStorageConfigurationSource>(),
                Component.For <IFactoryActor>()
                .ImplementedBy <FactoryActor>()
                .LifestyleTransient(),
                Component.For <ShardKeyActor>()
                .ImplementedBy <ShardKeyActor>()
                .LifestyleTransient(),
                Component.For <ShardRangeActor>()
                .ImplementedBy <ShardRangeActor>()
                .LifestyleTransient(),
                Component.For <BlobFileActor>()
                .ImplementedBy <BlobFileActor>()
                .LifestyleTransient(),
                Component.For <BlobFileConventionActor>()
                .ImplementedBy <BlobFileConventionActor>()
                .LifestyleTransient(),
                Component.For <IisBlobScheduler>()
                .ImplementedBy <IisBlobScheduler>()
                .LifestyleTransient(),
                Component.For <IisBlobConventionScheduler>()
                .ImplementedBy <IisBlobConventionScheduler>()
                .LifestyleTransient(),
                Component.For <RangeShardKeyScheduler>()
                .ImplementedBy <RangeShardKeyScheduler>()
                .LifestyleTransient(),
                Component.For <SimpleBlobScheduler>()
                .ImplementedBy <SimpleBlobScheduler>()
                .LifestyleTransient(),
                Component.For <MinuteTableShardScheduler>()
                .ImplementedBy <MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <D18MinuteTableShardScheduler>()
                .ImplementedBy <D18MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <Modulo10MinuteTableShardScheduler>()
                .ImplementedBy <Modulo10MinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <ReverseTimestampMinuteTableShardScheduler>()
                .ImplementedBy <ReverseTimestampMinuteTableShardScheduler>()
                .LifestyleTransient(),
                Component.For <IisLogParser>()
                .ImplementedBy <IisLogParser>()
                .LifestyleTransient(),
                Component.For <AkamaiLogParser>()
                .ImplementedBy <AkamaiLogParser>()
                .LifestyleTransient(),
                Component.For <IIndexNamer>()
                .ImplementedBy <IndexNamer>()
                .LifestyleSingleton(),
                Component.For <IHttpClient>()
                .ImplementedBy <DefaultHttpClient>()
                .LifestyleSingleton()
                .DependsOn(Dependency.OnValue("defaultHeaders", headers)),
                Component.For <ITempDownloadLocationProvider>()
                .ImplementedBy <AzureTempDownloadLocationProvider>()
                .LifestyleSingleton(),
                Component.For <IElasticsearchBatchPusher>()
                .ImplementedBy <ElasticsearchBatchPusher>()
                .LifestyleTransient()
                .DependsOn(Dependency.OnValue("esUrl", _configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl)))
                .DependsOn(Dependency.OnValue("batchSize", bulkBatchSize)),
                Component.For <ILockStore>()
                .Instance(new AzureLockStore(new BlobSource()
            {
                ConnectionString = storageConnectionString,
                ContainerName    = clusterLockContainer,
                Path             = clusterLockRootPath
            })),
                Component.For <IKeyValueStore>()
                .Instance(new AzureKeyValueStore(storageConnectionString, clusterLockContainer)),
                Component.For <IEventQueueOperator>()
                .Instance(new ServiceBusOperator(servicebusConnectionString)),
                Component.For <ITelemetryProvider>()
                .ImplementedBy <TelemetryProvider>()
                .LifestyleSingleton()
                );

            _orchestrator  = container.Resolve <Orchestrator>();
            _scheduler     = container.Resolve <MasterScheduler>();
            _keyValueStore = container.Resolve <IKeyValueStore>();
            ServicePointHelper.ApplyStandardSettings(_configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl));
        }
 public static void Enable(IPipelines pipelines, IKeyValueStore store)
 {
     pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx => LoadSession(ctx, store));
     pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => SaveSession(ctx, store));
 }
Example #36
0
 public NewsPulseActor(IKeyValueStore keyValueStore)
 {
     _keyValueStore = keyValueStore;
 }
Example #37
0
 public RocksDbWriter(IConfigurationProvider config, IKeyValueStore store)
 {
     _config = config;
     _store  = store;
 }
Example #38
0
        public WebServiceClientRequest CreateRequest(RequestVerb verb, string relativeUri, IKeyValueStore <object> queryParameters = null)
        {
            var innerRequest = WebRequest.CreateHttp(CreateRequestUri(verb, relativeUri, queryParameters));

            innerRequest.Method      = verb.ToString().ToUpper();
            innerRequest.Accept      = CommunicationStrategy.ContentType;
            innerRequest.ContentType = $"{CommunicationStrategy.ContentType}; charset={(mConfiguration.Encoding ?? Encoding.UTF8).WebName}";

            var request = new WebServiceClientRequest(mConfiguration, CommunicationStrategy, innerRequest);

            return(request);
        }
Example #39
0
 public NestedJsonKeyValueReader(IKeyValueStore keyValueStore)
 {
     _keyValueStore = keyValueStore;
 }
Example #40
0
 /// <summary>
 /// 初始化一个<see cref="SettingsController"/>类型的新实例
 /// </summary>
 public SettingsController(IKeyValueStore keyValueStore)
 {
     _keyValueStore = keyValueStore;
 }
Example #41
0
 public TrieStateStore(
     IKeyValueStore stateKeyValueStore, IKeyValueStore stateHashKeyValueStore)
 {
     _stateKeyValueStore     = stateKeyValueStore;
     _stateHashKeyValueStore = stateHashKeyValueStore;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="InMemoryConnectionTracker{T}"/> class
 /// </summary>
 /// <param name="store">The in-memory store</param>
 public InMemoryConnectionTracker(IKeyValueStore <T> store)
 {
     Store = store;
 }
Example #43
0
 public PersistedRegression(IKeyValueStore regressionStore)
 {
     this.regressionStore = regressionStore;
 }
Example #44
0
        public static void Put <T>(this IKeyValueStore keyValueStore, string bucketName, string key, T value)
        {
            var bucket = keyValueStore.GetBucket(bucketName);

            bucket.Put(key, value);
        }
Example #45
0
 public TrieStatsCollector(IKeyValueStore codeKeyValueStore, ILogManager logManager)
 {
     _codeKeyValueStore = codeKeyValueStore ?? throw new ArgumentNullException(nameof(codeKeyValueStore));
     _logger            = logManager.GetClassLogger();
 }
 public BlockGroupHead_operations(IKeyValueStore cache)
 {
     _cache = cache;
 }
Example #47
0
 public DefaultFeatureFlagStore(IKeyValueStore localStore, IKeyValueStore remoteStore) : base(remoteStore)
 {
     this.localStore = localStore;
 }
Example #48
0
 public BlockStore(IKeyValueStore cache, int blockSize)
 {
     _groupOps = new BlockGroup_operations(cache, blockSize);
     _headOps = new BlockGroupHead_operations(cache);
     _blockSize = blockSize;
 }
        static async Task <IDictionary <string, StoredServiceIdentity> > ReadCacheFromStore(IKeyValueStore <string, string> encryptedStore)
        {
            IDictionary <string, StoredServiceIdentity> cache = new Dictionary <string, StoredServiceIdentity>();
            await encryptedStore.IterateBatch(
                int.MaxValue,
                (key, value) =>
            {
                cache.Add(key, JsonConvert.DeserializeObject <StoredServiceIdentity>(value));
                return(Task.CompletedTask);
            });

            return(cache);
        }
Example #50
0
 public GetSettings(IKeyValueStore data)
 {
     _data = data;
 }
Example #51
0
        static void SetCountKey(IKeyValueStore settings, int value)
        {
            var key = $"{typeof(FullService).FullName}.{nameof(FullService.Count)}";

            settings.Set(key, value);
        }
Example #52
0
 private static void write <T>(this IKeyValueStore instance, string key, T value) =>
 instance.Write(key, JsonConvert.SerializeObject(value));
Example #53
0
 public BlockStore(IKeyValueStore cache)
     : this(cache, DEFAULT_BLOCK_SIZE)
 {
 }
Example #54
0
 public static ServerCountSamples ServerCountSamples(this IKeyValueStore instance) =>
 instance.read("ServerCountSamples", () => new ServerCountSamples());
Example #55
0
 public KeyValueStoreMapper(IKeyValueStore <TK1, TV1> underlyingStore, ITypeMapper <TK, TK1> keyMapper, ITypeMapper <TV, TV1> valueMapper)
 {
     this.underlyingStore = Preconditions.CheckNotNull(underlyingStore, nameof(underlyingStore));
     this.keyMapper       = Preconditions.CheckNotNull(keyMapper, nameof(keyMapper));
     this.valueMapper     = Preconditions.CheckNotNull(valueMapper, nameof(valueMapper));
 }
Example #56
0
 public TodoService(IKeyValueStore keyValueStore, IServerSideAuthService auth)
 {
     _keyValueStore = keyValueStore;
     _auth          = auth;
 }
Example #57
0
 public FileStore(IKeyValueStore keyValueStore)
     : this(keyValueStore, Environment.MachineName)
 {
 }
Example #58
0
        protected override void Load(ContainerBuilder builder)
        {
            // IMessageConverter<IRoutingMessage>
            builder.Register(c => new RoutingMessageConverter())
            .As <Core.IMessageConverter <IRoutingMessage> >()
            .SingleInstance();

            // IRoutingPerfCounter
            builder.Register(
                c =>
            {
                Routing.PerfCounter = NullRoutingPerfCounter.Instance;
                return(Routing.PerfCounter);
            })
            .As <IRoutingPerfCounter>()
            .AutoActivate()
            .SingleInstance();

            // IRoutingUserAnalyticsLogger
            builder.Register(
                c =>
            {
                Routing.UserAnalyticsLogger = NullUserAnalyticsLogger.Instance;
                return(Routing.UserAnalyticsLogger);
            })
            .As <IRoutingUserAnalyticsLogger>()
            .AutoActivate()
            .SingleInstance();

            // IRoutingUserMetricLogger
            builder.Register(
                c =>
            {
                Routing.UserMetricLogger = NullRoutingUserMetricLogger.Instance;
                return(Routing.UserMetricLogger);
            })
            .As <IRoutingUserMetricLogger>()
            .AutoActivate()
            .SingleInstance();

            // IMessageConverter<Message>
            builder.Register(c => new DeviceClientMessageConverter())
            .As <Core.IMessageConverter <Message> >()
            .SingleInstance();

            // IMessageConverter<Twin>
            builder.Register(c => new TwinMessageConverter())
            .As <Core.IMessageConverter <Twin> >()
            .SingleInstance();

            // IMessageConverter<TwinCollection>
            builder.Register(c => new TwinCollectionMessageConverter())
            .As <Core.IMessageConverter <TwinCollection> >()
            .SingleInstance();

            // IMessageConverterProvider
            builder.Register(
                c => new MessageConverterProvider(new Dictionary <Type, IMessageConverter>()
            {
                { typeof(Message), c.Resolve <Core.IMessageConverter <Message> >() },
                { typeof(Twin), c.Resolve <Core.IMessageConverter <Twin> >() },
                { typeof(TwinCollection), c.Resolve <Core.IMessageConverter <TwinCollection> >() }
            }))
            .As <IMessageConverterProvider>()
            .SingleInstance();

            // IDeviceConnectivityManager
            builder.Register(
                c =>
            {
                IDeviceConnectivityManager deviceConnectivityManager = new DeviceConnectivityManager(this.connectivityCheckFrequency, TimeSpan.FromMinutes(2));
                return(deviceConnectivityManager);
            })
            .As <IDeviceConnectivityManager>()
            .SingleInstance();

            // IDeviceClientProvider
            builder.Register(c =>
            {
                IClientProvider underlyingClientProvider        = new ClientProvider();
                IClientProvider connectivityAwareClientProvider = new ConnectivityAwareClientProvider(underlyingClientProvider, c.Resolve <IDeviceConnectivityManager>());
                return(connectivityAwareClientProvider);
            })
            .As <IClientProvider>()
            .SingleInstance();

            // Task<ICloudConnectionProvider>
            builder.Register(
                async c =>
            {
                var messageConverterProvider = c.Resolve <IMessageConverterProvider>();
                var clientProvider           = c.Resolve <IClientProvider>();
                var tokenProvider            = c.ResolveNamed <ITokenProvider>("EdgeHubClientAuthTokenProvider");
                IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache = await c.Resolve <Task <IDeviceScopeIdentitiesCache> >();
                ICloudConnectionProvider cloudConnectionProvider       = new CloudConnectionProvider(
                    messageConverterProvider,
                    this.connectionPoolSize,
                    clientProvider,
                    this.upstreamProtocol,
                    tokenProvider,
                    deviceScopeIdentitiesCache,
                    TimeSpan.FromMinutes(60));
                return(cloudConnectionProvider);
            })
            .As <Task <ICloudConnectionProvider> >()
            .SingleInstance();

            // Task<ICredentialsStore>
            builder.Register(async c =>
            {
                if (this.cacheTokens)
                {
                    IKeyValueStore <string, string> encryptedStore = await c.ResolveNamed <Task <IKeyValueStore <string, string> > >("EncryptedStore");
                    return(new TokenCredentialsStore(encryptedStore));
                }
                else
                {
                    return(new NullCredentialsStore() as ICredentialsStore);
                }
            })
            .As <Task <ICredentialsStore> >()
            .SingleInstance();

            // Task<IConnectionManager>
            builder.Register(
                async c =>
            {
                ICloudConnectionProvider cloudConnectionProvider = await c.Resolve <Task <ICloudConnectionProvider> >();
                IConnectionManager connectionManager             = new ConnectionManager(cloudConnectionProvider, this.maxConnectedClients);
                return(connectionManager);
            })
            .As <Task <IConnectionManager> >()
            .SingleInstance();

            // Task<IEndpointFactory>
            builder.Register(async c =>
            {
                var messageConverter = c.Resolve <Core.IMessageConverter <IRoutingMessage> >();
                IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                return(new EndpointFactory(connectionManager, messageConverter, this.edgeDeviceId) as IEndpointFactory);
            })
            .As <Task <IEndpointFactory> >()
            .SingleInstance();

            // Task<RouteFactory>
            builder.Register(async c => new EdgeRouteFactory(await c.Resolve <Task <IEndpointFactory> >()) as RouteFactory)
            .As <Task <RouteFactory> >()
            .SingleInstance();

            // RouterConfig
            builder.Register(c => new RouterConfig(Enumerable.Empty <Route>()))
            .As <RouterConfig>()
            .SingleInstance();

            if (!this.isStoreAndForwardEnabled)
            {
                // EndpointExecutorConfig
                builder.Register(
                    c =>
                {
                    RetryStrategy defaultRetryStrategy = new FixedInterval(0, TimeSpan.FromSeconds(1));
                    TimeSpan defaultRevivePeriod       = TimeSpan.FromHours(1);
                    TimeSpan defaultTimeout            = TimeSpan.FromSeconds(60);
                    return(new EndpointExecutorConfig(defaultTimeout, defaultRetryStrategy, defaultRevivePeriod, true));
                })
                .As <EndpointExecutorConfig>()
                .SingleInstance();

                // IEndpointExecutorFactory
                builder.Register(c => new SyncEndpointExecutorFactory(c.Resolve <EndpointExecutorConfig>()))
                .As <IEndpointExecutorFactory>()
                .SingleInstance();

                // Task<Router>
                builder.Register(
                    async c =>
                {
                    var endpointExecutorFactory = c.Resolve <IEndpointExecutorFactory>();
                    var routerConfig            = c.Resolve <RouterConfig>();
                    Router router = await Router.CreateAsync(Guid.NewGuid().ToString(), this.iotHubName, routerConfig, endpointExecutorFactory);
                    return(router);
                })
                .As <Task <Router> >()
                .SingleInstance();

                // Task<ITwinManager>
                builder.Register(async c =>
                {
                    var messageConverterProvider         = c.Resolve <IMessageConverterProvider>();
                    IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                    return(TwinManager.CreateTwinManager(connectionManager, messageConverterProvider, Option.None <IStoreProvider>()));
                })
                .As <Task <ITwinManager> >()
                .SingleInstance();
            }
            else
            {
                // EndpointExecutorConfig
                builder.Register(
                    c =>
                {
                    // Endpoint executor config values -
                    // ExponentialBackoff - minBackoff = 1s, maxBackoff = 60s, delta (used to add randomness to backoff) - 1s (default)
                    // Num of retries = int.MaxValue(we want to keep retrying till the message is sent)
                    // Revive period - period for which the endpoint should be considered dead if it doesn't respond - 1 min (we want to try continuously till the message expires)
                    // Timeout - time for which we want for the ack from the endpoint = 30s
                    // TODO - Should the number of retries be tied to the Store and Forward ttl? Not
                    // doing that right now as that value can be changed at runtime, but these settings
                    // cannot. Need to make the number of retries dynamically configurable for that.

                    TimeSpan minWait            = TimeSpan.FromSeconds(1);
                    TimeSpan maxWait            = TimeSpan.FromSeconds(60);
                    TimeSpan delta              = TimeSpan.FromSeconds(1);
                    int retries                 = int.MaxValue;
                    RetryStrategy retryStrategy = new ExponentialBackoff(retries, minWait, maxWait, delta);
                    TimeSpan timeout            = TimeSpan.FromSeconds(30);
                    TimeSpan revivePeriod       = TimeSpan.FromSeconds(30);
                    return(new EndpointExecutorConfig(timeout, retryStrategy, revivePeriod));
                })
                .As <EndpointExecutorConfig>()
                .SingleInstance();

                // ICheckpointStore
                builder.Register(c => CheckpointStore.Create(c.Resolve <IDbStoreProvider>()))
                .As <ICheckpointStore>()
                .SingleInstance();

                // IMessageStore
                builder.Register(
                    c =>
                {
                    var checkpointStore          = c.Resolve <ICheckpointStore>();
                    var dbStoreProvider          = c.Resolve <IDbStoreProvider>();
                    IStoreProvider storeProvider = new StoreProvider(dbStoreProvider);
                    IMessageStore messageStore   = new MessageStore(storeProvider, checkpointStore, TimeSpan.MaxValue);
                    return(messageStore);
                })
                .As <IMessageStore>()
                .SingleInstance();

                // IEndpointExecutorFactory
                builder.Register(
                    c =>
                {
                    var endpointExecutorConfig = c.Resolve <EndpointExecutorConfig>();
                    var messageStore           = c.Resolve <IMessageStore>();
                    IEndpointExecutorFactory endpointExecutorFactory = new StoringAsyncEndpointExecutorFactory(endpointExecutorConfig, new AsyncEndpointExecutorOptions(10, TimeSpan.FromSeconds(10)), messageStore);
                    return(endpointExecutorFactory);
                })
                .As <IEndpointExecutorFactory>()
                .SingleInstance();

                // Task<Router>
                builder.Register(
                    async c =>
                {
                    var checkpointStore         = c.Resolve <ICheckpointStore>();
                    var routerConfig            = c.Resolve <RouterConfig>();
                    var endpointExecutorFactory = c.Resolve <IEndpointExecutorFactory>();
                    return(await Router.CreateAsync(Guid.NewGuid().ToString(), this.iotHubName, routerConfig, endpointExecutorFactory, checkpointStore));
                })
                .As <Task <Router> >()
                .SingleInstance();

                // Task<ITwinManager>
                builder.Register(async c =>
                {
                    var dbStoreProvider                  = c.Resolve <IDbStoreProvider>();
                    var messageConverterProvider         = c.Resolve <IMessageConverterProvider>();
                    IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                    return(TwinManager.CreateTwinManager(connectionManager, messageConverterProvider, Option.Some <IStoreProvider>(new StoreProvider(dbStoreProvider))));
                })
                .As <Task <ITwinManager> >()
                .SingleInstance();
            }

            // IClientCredentials "EdgeHubCredentials"
            builder.Register(
                c =>
            {
                var identityFactory = c.Resolve <IClientCredentialsFactory>();
                IClientCredentials edgeHubCredentials = this.connectionString.Map(cs => identityFactory.GetWithConnectionString(cs)).GetOrElse(
                    () => identityFactory.GetWithIotEdged(this.edgeDeviceId, this.edgeModuleId));
                return(edgeHubCredentials);
            })
            .Named <IClientCredentials>("EdgeHubCredentials")
            .SingleInstance();

            // Task<ICloudProxy> "EdgeHubCloudProxy"
            builder.Register(
                async c =>
            {
                var edgeHubCredentials = c.ResolveNamed <IClientCredentials>("EdgeHubCredentials");
                IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                Try <ICloudProxy> cloudProxyTry      = await connectionManager.CreateCloudConnectionAsync(edgeHubCredentials);
                if (!cloudProxyTry.Success)
                {
                    throw new EdgeHubConnectionException("Edge hub is unable to connect to IoT Hub", cloudProxyTry.Exception);
                }

                ICloudProxy cloudProxy = cloudProxyTry.Value;
                return(cloudProxy);
            })
            .Named <Task <ICloudProxy> >("EdgeHubCloudProxy")
            .SingleInstance();

            // Task<IInvokeMethodHandler>
            builder.Register(async c =>
            {
                IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                return(new InvokeMethodHandler(connectionManager) as IInvokeMethodHandler);
            })
            .As <Task <IInvokeMethodHandler> >()
            .SingleInstance();

            // Task<IEdgeHub>
            builder.Register(
                async c =>
            {
                var routingMessageConverter = c.Resolve <Core.IMessageConverter <IRoutingMessage> >();
                var routerTask              = c.Resolve <Task <Router> >();
                var twinManagerTask         = c.Resolve <Task <ITwinManager> >();
                var invokeMethodHandlerTask = c.Resolve <Task <IInvokeMethodHandler> >();
                var connectionManagerTask   = c.Resolve <Task <IConnectionManager> >();
                Router router                            = await routerTask;
                ITwinManager twinManager                 = await twinManagerTask;
                IConnectionManager connectionManager     = await connectionManagerTask;
                IInvokeMethodHandler invokeMethodHandler = await invokeMethodHandlerTask;
                IEdgeHub hub = new RoutingEdgeHub(router, routingMessageConverter,
                                                  connectionManager, twinManager, this.edgeDeviceId, invokeMethodHandler);
                return(hub);
            })
            .As <Task <IEdgeHub> >()
            .SingleInstance();

            // Task<ConfigUpdater>
            builder.Register(
                async c =>
            {
                IMessageStore messageStore = this.isStoreAndForwardEnabled ? c.Resolve <IMessageStore>() : null;
                Router router     = await c.Resolve <Task <Router> >();
                var configUpdater = new ConfigUpdater(router, messageStore);
                return(configUpdater);
            })
            .As <Task <ConfigUpdater> >()
            .SingleInstance();

            // Task<IConfigSource>
            builder.Register(
                async c =>
            {
                RouteFactory routeFactory = await c.Resolve <Task <RouteFactory> >();
                if (this.useTwinConfig)
                {
                    var edgeHubCredentials             = c.ResolveNamed <IClientCredentials>("EdgeHubCredentials");
                    var twinCollectionMessageConverter = c.Resolve <Core.IMessageConverter <TwinCollection> >();
                    var twinMessageConverter           = c.Resolve <Core.IMessageConverter <Twin> >();
                    ITwinManager twinManager           = await c.Resolve <Task <ITwinManager> >();
                    ICloudProxy cloudProxy             = await c.ResolveNamed <Task <ICloudProxy> >("EdgeHubCloudProxy");
                    IEdgeHub edgeHub = await c.Resolve <Task <IEdgeHub> >();
                    IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                    IDeviceScopeIdentitiesCache deviceScopeIdentitiesCache = await c.Resolve <Task <IDeviceScopeIdentitiesCache> >();
                    IConfigSource edgeHubConnection = await EdgeHubConnection.Create(
                        edgeHubCredentials,
                        edgeHub,
                        twinManager,
                        connectionManager,
                        cloudProxy,
                        routeFactory,
                        twinCollectionMessageConverter,
                        twinMessageConverter,
                        this.versionInfo,
                        deviceScopeIdentitiesCache
                        );
                    return(edgeHubConnection);
                }
                else
                {
                    return(new LocalConfigSource(routeFactory, this.routes, this.storeAndForwardConfiguration));
                }
            })
            .As <Task <IConfigSource> >()
            .SingleInstance();

            // Task<IConnectionProvider>
            builder.Register(
                async c =>
            {
                IConnectionManager connectionManager = await c.Resolve <Task <IConnectionManager> >();
                IEdgeHub edgeHub = await c.Resolve <Task <IEdgeHub> >();
                IConnectionProvider connectionProvider = new ConnectionProvider(connectionManager, edgeHub);
                return(connectionProvider);
            })
            .As <Task <IConnectionProvider> >()
            .SingleInstance();

            base.Load(builder);
        }
Example #59
0
 public static void ServerCountSamples(this IKeyValueStore instance, ServerCountSamples samples) =>
 instance.write("ServerCountSamples", samples);
Example #60
0
        public void SaveGenericCell(IKeyValueStore storage, long cellId, ICell cell)
        {
            int seg = CompositeStorage.GetIntervalIndexByCellTypeID(cell.CellType);

            CompositeStorage.s_GenericCellOperations[seg].SaveGenericCell(storage, cellId, cell);
        }