public Task <RegisterContentLocationsResponse> RegisterContentLocationsAsync(RegisterContentLocationsRequest request)
 {
     return(ExecuteAsync(request, async context =>
     {
         var result = await _store.RegisterLocationAsync(context, request.MachineId, request.Hashes, touch: false);
         if (result.Succeeded)
         {
             return Result.Success(new RegisterContentLocationsResponse());
         }
         else
         {
             return Result.FromError <RegisterContentLocationsResponse>(result);
         }
     }));
 }
示例#2
0
        /// <summary>
        /// An optimized low allocation version of <see cref="RegisterContentLocationsAsync"/>.
        /// </summary>
        // TODO: instead of manually doing all of that we should make our helpers more efficient and as allocation free as possible. Work Item: 1883860
        protected async ValueTask <ValueUnit> RegisterContentLocationsFastAsync(RegisterContentLocationsRequest request)
        {
            // This method is called extremely frequently in some cases so to avoid any unnecessary performance penalties
            // it does not use any helper methods.

            // Intentionally not tracking the shutdown here to avoid extra allocations and extra work that is rarely needed.
            // Plus this method should not be very long and we can just allow it to fail if the shutdown will cause some errors.
            // (consider adding a flag if we think it will be needed in the future).

            var tracingContext = new Context(request.ContextId, StartupLogger);
            var context        = new OperationContext(tracingContext);

            try
            {
                await _store.RegisterLocationAsync(context, request.MachineId, request.Hashes, touch : false).ThrowIfFailure();
            }
            catch (Exception e)
            {
                // Checking the errors for the synchronous case.
                Tracer.Info(context, $"Content location registration failed {e}");
            }

            return(ValueUnit.Void);
        }