Exemplo n.º 1
0
        private async Task ProcessSourceAsync(ICounterSmugglerSource source, CounterSmugglerOperationState state, CancellationToken cancellationToken)
        {
            while (true)
            {
                var type = await source
                           .GetNextSmuggleTypeAsync(cancellationToken)
                           .ConfigureAwait(false);

                switch (type)
                {
                case CounterSmuggleType.None:
                    return;

                case CounterSmuggleType.Delta:
                    await new DeltaSmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                case CounterSmuggleType.Snapshots:
                    await new SnapshotSmuggler(_options, _notifications, source, _destination)
                    .SmuggleAsync(state, cancellationToken)
                    .ConfigureAwait(false);
                    continue;

                default:
                    throw new NotSupportedException(type.ToString());
                }
            }
        }
Exemplo n.º 2
0
 public CounterSmuggler(CounterSmugglerOptions options, ICounterSmugglerSource source, ICounterSmugglerDestination destination)
 {
     _options       = options;
     _source        = source;
     _destination   = destination;
     _notifications = new CounterSmugglerNotifications();
 }
Exemplo n.º 3
0
 protected CounterSmugglerBase(CounterSmugglerOptions options, CounterSmugglerNotifications notifications, ICounterSmugglerSource source, ICounterSmugglerDestination destination)
 {
     Notifications = notifications;
     Options       = options;
     Source        = source;
     Destination   = destination;
 }
Exemplo n.º 4
0
 public DeltaSmuggler(CounterSmugglerOptions options, CounterSmugglerNotifications notifications, ICounterSmugglerSource source, ICounterSmugglerDestination destination)
     : base(options, notifications, source, destination)
 {
 }
Exemplo n.º 5
0
        private static async Task <CounterSmugglerOperationState> GetOperationStateAsync(CounterSmugglerOptions options, ICounterSmugglerSource source, ICounterSmugglerDestination destination, CancellationToken cancellationToken)
        {
            CounterSmugglerOperationState state = null;

            if (destination.SupportsOperationState)
            {
                state = await destination
                        .LoadOperationStateAsync(options, cancellationToken)
                        .ConfigureAwait(false);
            }

            if (state == null)
            {
                state = new CounterSmugglerOperationState
                {
                    LastEtag = options.StartEtag
                };
            }

            Debug.Assert(state.LastEtag != null);

            return(state);
        }