public async Task CreateTenantToThisNode(CreateTenantDetails createTenantDetails) { _logger.LogInformation($"Request to create tenant '{createTenantDetails.Name}' from other nodes"); if (_tenantRepository.GetTenant(createTenantDetails.Name) == null) { _tenantApiService.CreateTenant(createTenantDetails.Name, createTenantDetails.TenantSettings); _logger.LogInformation($"Tenant' {createTenantDetails.Name}' has been created and linked, informing other nodes"); } else { _logger.LogInformation($"Tenant' {createTenantDetails.Name}' already exists, ignoring the request"); } // send to other nodes.... await _storageHubService.SendCreateTenantStorage(createTenantDetails); }
public async Task SendCreateTenantStorage(CreateTenantDetails createTenantDetails) { foreach (var storage in _storageHubRepository.GetStorages()) { if (createTenantDetails.StoragesAlreadySent.Contains(storage.Key) != true) { createTenantDetails.StoragesAlreadySent.Add(storage.Key); // send to this storage await _hub.Clients.Client(storage.Value.Agents.First().Key).TenantCreated(new Model.Storages.Events.Tenants.TenantCreatedDetails() { Id = Guid.NewGuid(), Name = createTenantDetails.Name, Settings = createTenantDetails.TenantSettings, StoragesAlreadySent = createTenantDetails.StoragesAlreadySent, }); } } }
public async Task CreateTenant(CreateTenantDetails createTenantDetails) { await consumerHubService.CreateTenantToThisNode(createTenantDetails); }