Example #1
0
 private ISagaBuilder CreateSaga(Guid id)
 {
     return(GrainFactory
            .CreateSaga(id)
            .AddActivity <WaitActivity>(x => x.Add("WaitTimeSeconds", 2))
            .AddActivity <WaitActivity>(x => x.Add("WaitTimeSeconds", 4)));
 }
Example #2
0
        private async Task <ISagaGrain> ExecuteNormally()
        {
            var sagaBuilder = GrainFactory.CreateSaga();

            AddActivities(sagaBuilder);

            return(await sagaBuilder.ExecuteSaga());
        }
Example #3
0
 private async Task <ISagaGrain> CreateAndExecuteSagaAsync()
 {
     return(await GrainFactory
            .CreateSaga()
            .AddActivity <WaitActivity>(x => x.Add("WaitTimeSeconds", 2))
            .AddActivity <WaitActivity>(x => x.Add("WaitTimeSeconds", 4))
            .ExecuteSagaAsync());
 }
 public override async Task Execute()
 {
     await GrainFactory
     .CreateSaga()
     .AddActivity <RequestActivity, RequestConfig>(x => x.Url = "https://dotnet.github.io/orleans/")
     .AddActivity <RequestActivity, RequestConfig>(x => x.Url = "https://dot.net")
     .AddActivity <RequestActivity, RequestConfig>(x => x.Url = "https://yahoo.com")
     .ExecuteSagaAsync();
 }
Example #5
0
        public async Task <ISagaGrain> AbortWithoutExecution()
        {
            var sagaBuilder = GrainFactory.CreateSaga();

            var saga = GrainFactory.GetSaga(sagaBuilder.Id);

            await saga.RequestAbort();

            return(saga);
        }
Example #6
0
        private async Task <ISagaGrain> ExecuteNormally()
        {
            var sagaBuilder = GrainFactory.CreateSaga();

            sagaBuilder
            .AddActivity <KickAssActivity, KickAssConfig>(x => x.KickAssCount = 7)
            .AddActivity <ChewBubblegumActivity>();

            return(await sagaBuilder.ExecuteSagaAsync());
        }
Example #7
0
        public override async Task Execute()
        {
            var saga = await GrainFactory.CreateSaga()
                       .AddActivity <BookHireCarActivity>()
                       .AddActivity <BookHotelActivity>()
                       .AddActivity <BookPlaneActivity>()
                       .ExecuteSagaAsync(x => x.Add("HireCarModel", 1));

            await saga.Wait();
        }
        public override async Task Execute()
        {
            var saga = await GrainFactory
                       .CreateSaga()
                       .AddActivity <RequestActivity>(x => x.Add("Url", "https://dotnet.github.io/orleans/"))
                       .AddActivity <RequestActivity>(x => x.Add("Url", "https://dot.net"))
                       .AddActivity <RequestActivity>(x => x.Add("Url", "https://yahoo.com"))
                       .ExecuteSagaAsync();

            await saga.Wait();
        }
Example #9
0
        public async Task <ISagaGrain> ExecuteAndAbort()
        {
            var sagaBuilder = GrainFactory.CreateSaga();

            AddActivities(sagaBuilder);

            var saga = await sagaBuilder.ExecuteSaga();

            await saga.RequestAbort();

            return(saga);
        }
Example #10
0
        public override async Task Execute()
        {
            var saga = await GrainFactory.CreateSaga()
                       .AddActivity(new BookHireCarActivity {
                Config = new BookHireCarConfig()
            })
                       .AddActivity(new BookHotelActivity())
                       .AddActivity(new BookPlaneActivity())
                       .ExecuteSaga();

            await saga.Wait();
        }
Example #11
0
        private async Task <ISagaGrain> ExecuteNormally()
        {
            var sagaBuilder = GrainFactory.CreateSaga();

            sagaBuilder
            .AddActivity(new KickAssActivity {
                Config = new KickAssConfig {
                    KickAssCount = 7
                }
            })
            .AddActivity(new ChewBubblegumActivity());

            return(await sagaBuilder.ExecuteSaga());
        }
Example #12
0
        public async Task <ISagaGrain> AbortThenExecute()
        {
            var sagaBuilder = GrainFactory.CreateSaga();

            var saga = GrainFactory.GetSaga(sagaBuilder.Id);

            await saga.RequestAbort();

            AddActivities(sagaBuilder);

            await sagaBuilder.ExecuteSagaAsync();

            return(saga);
        }
Example #13
0
 private async Task <ISagaGrain> Transfer(int from, int to, int amount)
 {
     return(await GrainFactory.CreateSaga()
            .AddActivity <BalanceModificationActivity>
            (
                x =>
     {
         x.Add("Account", from);
         x.Add("Amount", -amount);
     }
            )
            .AddActivity <BalanceModificationActivity>
            (
                x =>
     {
         x.Add("Account", to);
         x.Add("Amount", amount);
     }
            )
            .ExecuteSagaAsync());
 }
Example #14
0
 private async Task <ISagaGrain> Transfer(int from, int to, int amount)
 {
     return(await GrainFactory.CreateSaga()
            .AddActivity(new BalanceModificationActivity
     {
         Config = new BalanceModificationConfig
         {
             Account = from,
             Amount = -amount
         }
     })
            .AddActivity(new BalanceModificationActivity
     {
         Config = new BalanceModificationConfig
         {
             Account = to,
             Amount = amount
         }
     })
            .ExecuteSaga());
 }
 private async Task <ISagaGrain> Transfer(int from, int to, int amount)
 {
     return(await GrainFactory.CreateSaga()
            .AddActivity <BalanceModificationActivity, BalanceModificationConfig>
            (
                x =>
     {
         x.Account = from;
         x.Amount = -amount;
     }
            )
            .AddActivity <BalanceModificationActivity, BalanceModificationConfig>
            (
                x =>
     {
         x.Account = to;
         x.Amount = amount;
     }
            )
            .ExecuteSagaAsync());
 }
        public override async Task Execute()
        {
            Describe("Activity that throws exception while executing, while using custom error translator");
            var sagaWithFailingExecutionActivityWithDefinedErrorTranslator =
                await GrainFactory.CreateSaga()
                .AddActivity <FailingExecutionActivity>()
                .AddErrorTranslator(_errorTranslator)
                .ExecuteSagaAsync();

            await sagaWithFailingExecutionActivityWithDefinedErrorTranslator.Wait();

            await ValidateSagaErrorAsync(sagaWithFailingExecutionActivityWithDefinedErrorTranslator, _errorTranslator, typeof(CustomException));


            Describe("Activity that throws exception while executing, without using custom error translator");
            var sagaWithFailingExecutionActivityWithNoErrorTranslator =
                await GrainFactory.CreateSaga()
                .AddActivity <FailingExecutionActivity>()
                .ExecuteSagaAsync();

            await sagaWithFailingExecutionActivityWithNoErrorTranslator.Wait();

            await ValidateSagaErrorAsync(sagaWithFailingExecutionActivityWithNoErrorTranslator, errorTranslator : null);
        }