Esempio n. 1
0
 public static Step BeginReadBackward(
     this IODispatcher ioDispatcher,
     CancellationScope cancellationScope,
     string streamId,
     int fromEventNumber,
     int maxCount,
     bool resolveLinks,
     IPrincipal principal,
     Action <ClientMessage.ReadStreamEventsBackwardCompleted> handler)
 {
     return
         (steps =>
          cancellationScope.Register(
              ioDispatcher.ReadBackward(
                  streamId,
                  fromEventNumber,
                  maxCount,
                  resolveLinks,
                  principal,
                  response =>
     {
         if (cancellationScope.Cancelled(response.CorrelationId))
         {
             return;
         }
         handler(response);
         Run(steps);
     })));
 }
Esempio n. 2
0
 private static void DeleteStreamWithRetry(
     this IODispatcher ioDispatcher,
     CancellationScope cancellationScope,
     string streamId,
     int expectedVersion,
     bool hardDelete,
     IPrincipal principal,
     Action <ClientMessage.DeleteStreamCompleted> handler,
     IEnumerator <Step> steps)
 {
     PerformWithRetry(
         ioDispatcher,
         handler,
         steps,
         expectedVersion == ExpectedVersion.Any,
         TimeSpan.FromMilliseconds(100),
         action =>
         cancellationScope.Register(
             ioDispatcher.DeleteStream(
                 streamId,
                 expectedVersion,
                 hardDelete,
                 principal,
                 response =>
     {
         if (cancellationScope.Cancelled(response.CorrelationId))
         {
             return;
         }
         action(response, response.Result);
     })));
 }
Esempio n. 3
0
 private static void UpdateStreamAclWithRetry(
     this IODispatcher ioDispatcher,
     CancellationScope cancellationScope,
     string streamId,
     long expectedVersion,
     ClaimsPrincipal principal,
     StreamMetadata metadata,
     Action <ClientMessage.WriteEventsCompleted> handler,
     IEnumerator <Step> steps)
 {
     PerformWithRetry(
         ioDispatcher,
         handler,
         steps,
         expectedVersion == ExpectedVersion.Any,
         TimeSpan.FromMilliseconds(100),
         action =>
         cancellationScope.Register(
             ioDispatcher.WriteEvents(
                 SystemStreams.MetastreamOf(streamId),
                 expectedVersion,
                 new[] {
         new Event(Guid.NewGuid(), SystemEventTypes.StreamMetadata, true, metadata.ToJsonBytes(),
                   null)
     },
                 principal,
                 response => {
         if (cancellationScope.Cancelled(response.CorrelationId))
         {
             return;
         }
         action(response, response.Result);
     })));
 }
Esempio n. 4
0
 private static void WriteEventsWithRetry(
     this IODispatcher ioDispatcher,
     CancellationScope cancellationScope,
     string streamId,
     long expectedVersion,
     ClaimsPrincipal principal,
     Event[] events,
     Action <ClientMessage.WriteEventsCompleted> handler,
     IEnumerator <Step> steps)
 {
     PerformWithRetry(
         ioDispatcher,
         handler,
         steps,
         expectedVersion == ExpectedVersion.Any,
         TimeSpan.FromMilliseconds(100),
         action =>
         cancellationScope.Register(
             ioDispatcher.WriteEvents(
                 streamId,
                 expectedVersion,
                 events,
                 principal,
                 response => {
         if (cancellationScope.Cancelled(response.CorrelationId))
         {
             return;
         }
         action(response, response.Result);
     })));
 }
Esempio n. 5
0
 public static Step BeginReadForward(
     this IODispatcher ioDispatcher,
     CancellationScope cancellationScope,
     string streamId,
     long fromEventNumber,
     int maxCount,
     bool resolveLinks,
     IPrincipal principal,
     Action <ClientMessage.ReadStreamEventsForwardCompleted> handler,
     Action timeoutHandler)
 {
     return
         (steps =>
     {
         var corrId = Guid.NewGuid();
         cancellationScope.Register(corrId);
         ioDispatcher.ReadForward(
             streamId,
             fromEventNumber,
             maxCount,
             resolveLinks,
             principal,
             response =>
         {
             if (cancellationScope.Cancelled(response.CorrelationId))
             {
                 return;
             }
             handler(response);
             Run(steps);
         },
             () =>
         {
             if (cancellationScope.Cancelled(corrId))
             {
                 return;
             }
             timeoutHandler();
             Run(steps);
         },
             corrId);
     });
 }