protected override async Task <Response> OnExecute(ExecutionContext context, Request request) { var branch = await context.Branch().ConfigureAwait(false); using var transaction = branch.BeginTransaction(); var serviceNode = new ServiceNode() { Id = NodeId.Create <ServiceNode>(request.Id), ServiceId = request.Id, Metadata = NodeMetadata.Create(context.TimeProvider()) }; if (await branch.Services.PutIfAbsentAsync(serviceNode.Id, serviceNode) .ConfigureAwait(false)) { await transaction.CommitAsync().ConfigureAwait(false); return(new Response() { Service = serviceNode.ToOutput() }); } throw new ExecutionException(ExecutionErrorType.Conflict, $"Service {request.Id} already exist"); }