public ActionResult <string> UpdateGeneralKeyValue([FromRoute] string key, [FromRoute] string value, [FromServices] IMemoryGeneralConfigurationClientRepository clientRepo, [FromServices] IPublishClientsService clientPublishService)
        {
            var tenantId       = this.GetTenantIdFromRouteData();
            var clientHostname = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            clientRepo.Add(new DiscoveryClient(clientHostname));
            clientPublishService.PublishClientConfigurationActivity(tenantId, clientHostname);

            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(tenantId);

            var keyValue = new StoreKeyValue()
            {
                TenantId = tenantId,
                Key      = key,
                Value    = value
            };

            var res = repo.Update(keyValue);

            if (res)
            {
                this.HttpContext.Response.StatusCode = 200;
            }
            else
            {
                this.HttpContext.Response.StatusCode = 404;
            }

            return(string.Empty);
        }
Beispiel #2
0
        public ActionResult <string> UpdateApplicationKeyValue([FromRoute] string appName, [FromRoute] string key, [FromRoute] string value)
        {
            string tenantId = this.GetTenantIdFromRouteData();

            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(tenantId);

            var keyValue = new StoreKeyValue()
            {
                TenantId = tenantId,
                AppName  = appName,
                Key      = key,
                Value    = value
            };

            var res = repo.UpdateForApplication(appName, keyValue);

            if (res)
            {
                this.HttpContext.Response.StatusCode = 200;
            }
            else
            {
                this.HttpContext.Response.StatusCode = 404;
            }

            return(string.Empty);
        }
        public ActionResult <List <StoreKeyValue> > GetGeneralKeys([FromServices] IMemoryGeneralConfigurationClientRepository clientRepo, [FromServices] IPublishClientsService clientPublishService)
        {
            var tenantId       = this.GetTenantIdFromRouteData();
            var clientHostname = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            clientRepo.Add(new DiscoveryClient(clientHostname));
            clientPublishService.PublishClientConfigurationActivity(tenantId, clientHostname);

            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(tenantId);

            return(repo.GetAll());
        }
Beispiel #4
0
        public ActionResult <StoreKeyValue> GetApplicationKeyValue([FromRoute] string appName, [FromRoute] string key)
        {
            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(this.GetTenantIdFromRouteData());

            var res = repo.GetForApplication(appName, key);

            if (res == null)
            {
                this.HttpContext.Response.StatusCode = 404;
            }

            return(res);
        }
Beispiel #5
0
        public ActionResult <string> DeleteApplicationKeyValue([FromRoute] string appName, [FromRoute] List <string> keys)
        {
            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(this.GetTenantIdFromRouteData());

            var res = repo.DeleteKeysForApplication(appName, keys);

            if (res > 0)
            {
                this.HttpContext.Response.StatusCode = 200;
            }
            else
            {
                this.HttpContext.Response.StatusCode = 404;
            }

            return(string.Empty);
        }
Beispiel #6
0
        public ActionResult <string> AddApplicationKeyValues([FromRoute] string appName, [FromBody] List <StoreKeyValue> keyValues)
        {
            string tenantId = this.GetTenantIdFromRouteData();
            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(tenantId);

            var res = repo.AddKeysForApplication(appName, keyValues);

            if (res)
            {
                this.HttpContext.Response.StatusCode = 204;
            }
            else
            {
                this.HttpContext.Response.StatusCode = 500;
            }

            return(string.Empty);
        }
        public ActionResult <StoreKeyValue> GetGeneralKeyValue([FromRoute] string key, [FromServices] IMemoryGeneralConfigurationClientRepository clientRepo, [FromServices] IPublishClientsService clientPublishService)
        {
            var tenantId       = this.GetTenantIdFromRouteData();
            var clientHostname = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            clientRepo.Add(new DiscoveryClient(clientHostname));
            clientPublishService.PublishClientConfigurationActivity(tenantId, clientHostname);

            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(tenantId);
            var res = repo.Get(key);

            if (res == null)
            {
                this.HttpContext.Response.StatusCode = 404;
            }

            return(res);
        }
        public ActionResult <string> AddGeneralKeyValues([FromBody] List <StoreKeyValue> keyValues, [FromServices] IMemoryGeneralConfigurationClientRepository clientRepo, [FromServices] IPublishClientsService clientPublishService)
        {
            var tenantId       = this.GetTenantIdFromRouteData();
            var clientHostname = Request.HttpContext.Connection.RemoteIpAddress.ToString();

            clientRepo.Add(new DiscoveryClient(clientHostname));
            clientPublishService.PublishClientConfigurationActivity(tenantId, clientHostname);

            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(tenantId);

            var res = repo.AddKeys(keyValues);

            if (res)
            {
                this.HttpContext.Response.StatusCode = 204;
            }
            else
            {
                this.HttpContext.Response.StatusCode = 500;
            }

            return(string.Empty);
        }
        private void OnStartPersistencySync(Object source, ElapsedEventArgs e)
        {
            Console.WriteLine("START PERSYSTENCY SYNC : " + DateTime.Now.ToString());

            var peerRepo = new MemoryDiscoveryPeerRepository();
            var peers    = peerRepo.GetAll();

            foreach (var tenant in Program.Tenants)
            {
                var memoryRepo      = new MemoryServicesRepository(tenant.TenantId, Program.InstanceConfig.EvictionInSecs);
                var tenantSynchInfo = memoryRepo.GetTenantSyncInfo();

                if (tenantSynchInfo != null)
                {
                    var keyValueRepo = new MemoryConfigurationStoreRepository(tenant.TenantId);
                    var keysSyncInfo = keyValueRepo.GetAllKeysSyncInfo();

                    if (keysSyncInfo != null)
                    {
                        StartSyncProcess(tenant, peers, tenantSynchInfo, keysSyncInfo, Program.InstanceConfig.PersistencySyncWaitSeconds);
                    }
                }
            }
        }
Beispiel #10
0
        public ActionResult <List <StoreKeyValue> > GetApplicationKeys([FromRoute] string appName)
        {
            MemoryConfigurationStoreRepository repo = new MemoryConfigurationStoreRepository(this.GetTenantIdFromRouteData());

            return(repo.GetAllForApplication(appName));
        }