Ejemplo n.º 1
0
        public async Task <ReportActivityResult> ExecuteAsync(ReportActivity command, CancellationToken cancellationToken)
        {
            await repository.SetServiceLastActiveAsync(command.LastActiveUtc, cancellationToken);

            TimeSpan expirationQuanta = await repository.GetExpirationQuantaAsync(cancellationToken);

            return(new ReportActivityResult(TimeSpan.FromMilliseconds(expirationQuanta.TotalMilliseconds / 3)));
        }
Ejemplo n.º 2
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));
        }