コード例 #1
0
        public async Task <UnitType> Execute(IOrchestrationContext context)
        {
            var nearbyArea = AvailableDriver.CurrentAvailability.Value.GetNearbyAreas();

            RiderEvent candidate = null;

            foreach (var location in nearbyArea)
            {
                candidate = await context.PerformRead(new GetAvailableRider()
                {
                    Location = location
                });

                if (candidate != null)
                {
                    break;
                }
            }

            if (candidate == null)
            {
                // there are no matches. So we just wait until someone joins and gets matched to us.
                return(UnitType.Value);
            }

            try
            {
                var result = await context.PerformOrchestration(new TryFinalizeMatch()
                {
                    AvailableDriver = AvailableDriver,
                    AvailableRider  = candidate
                });

                if (result == TryFinalizeMatch.Response.DriverRemainsUnmatched)
                {
                    // retry in order to find another match
                    context.ForkOrchestration(this);
                }
            }
            catch (TransactionException)
            {
                // transaction ran into trouble for some reason... retry this orchestration
                context.ForkOrchestration(this);
            }

            return(UnitType.Value);
        }
コード例 #2
0
        public async Task <UnitType> Execute(IOrchestrationContext context)
        {
            await context.DelayBy(Delay);

            context.ForkOrchestration(Orchestration);

            return(UnitType.Value);
        }
コード例 #3
0
        public async Task <UnitType> Execute(IOrchestrationContext context)
        {
            for (int i = 0; i < 100000; i++)
            {
                context.ForkOrchestration(new CopyBlob()
                {
                    From = $"A{i}", To = $"B{i}"
                });
            }

            await context.Finish();

            return(UnitType.Value);
        }