示例#1
0
        public async Task <OccupyInstanceResult> OccupyAsync(OccupyInstance command, CancellationToken cancellationToken)
        {
            _currentState = await _currentState.OccupyAsync(this, command, cancellationToken);

            await repository.SetInstanceStateAsync(_currentState.State, cancellationToken);

            var serviceName = await repository.GetServiceUriAsync(cancellationToken);

            return(new OccupyInstanceResult(serviceName));
        }
示例#2
0
        public async Task ExecuteAsync(VacateInstance command, CancellationToken cancellationToken)
        {
            var serviceUri = await repository.GetServiceUriAsync(cancellationToken);

            await serviceInstance.VacateAsync(serviceUri);

            await repository.UnsetServiceInstanceName(cancellationToken);

            await deleteService.ExecuteAsync(new DeleteService(serviceUri), cancellationToken);
        }
示例#3
0
        public async Task <OccupyInstanceResult> ExecuteAsync(OccupyInstance command, CancellationToken cancellationToken)
        {
            Uri serviceUri = await repository.GetServiceUriAsync(cancellationToken);

            await instanceProxy.OccupyAsync(serviceUri, command.InstanceId, command.InstanceName);

            await Task.WhenAll(
                repository.SetServiceInstanceName(command.InstanceName, cancellationToken),
                repository.SetPartitionIdAsync(command.PartitionId, cancellationToken),
                repository.SetServiceLastActiveAsync(DateTime.UtcNow, cancellationToken)
                );

            return(new OccupyInstanceResult(serviceUri));
        }
示例#4
0
        public async Task ExecuteAsync(RemoveInstance command, CancellationToken cancellationToken)
        {
            var serviceUri = await repository.GetServiceUriAsync(cancellationToken);

            await serviceInstance.DeleteAsync(serviceUri, cancellationToken);
        }