Ejemplo n.º 1
0
        public async Task <ScopeCreepActivityResponse> ScopeCreepOrchestrator([OrchestrationTrigger] DurableOrchestrationContext context)
        {
            var request = context.GetInput <ScopeCreepActivityRequest>();

            var response = await context.CallActivityAsync <ScopeCreepActivityResponse>("ScopeCreepActivity", request);

            if (response.Depth < request.DepthRequested)
            {
                request = new ScopeCreepActivityRequest()
                {
                    Depth          = request.Depth + 1,
                    DepthRequested = request.DepthRequested
                };

                response = await context.CallSubOrchestratorAsync <ScopeCreepActivityResponse>("ScopeCreepOrchestrator", request);

                if (response.Depth < request.DepthRequested)
                {
                    context.ContinueAsNew(request, true);
                }
            }

            await context.CreateTimer(context.CurrentUtcDateTime.AddSeconds(5), CancellationToken.None);

            return(response);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DependencyExplode(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "DependencyExplode")] HttpRequest req,
            [OrchestrationClient] DurableOrchestrationClient starter
            )
        {
            // Just use a simple command to kick off a couple of orchestrators ..
            var requestOne = new ScopeCreepActivityRequest()
            {
                DepthRequested = 2
            };
            var requestTwo = new ScopeCreepActivityRequest()
            {
                DepthRequested = 2
            };

            var instanceOne = await starter.StartNewAsync("ScopeCreepOrchestrator", requestOne);

            var instanceTwo = await starter.StartNewAsync("ScopeCreepOrchestrator", requestTwo);

            Log.LogTrace("orchestration one: {0}", instanceOne);
            Log.LogTrace("orchestration two: {0}", instanceTwo);

            // var payload = await starter.GetStatusAsync(instanceId);
            return(new OkResult());
        }
        public async Task <ScopeCreepActivityResponse> ScopeCreepActivity(
            [ActivityTrigger] ScopeCreepActivityRequest request)
        {
            // Create a command that should demonstrate this weird "scope creep"
            var command = new ScopeCreepCommand()
            {
                Depth = request.Depth
            };

            // Await Mediatr to execute it
            var result = await _mediator.Send(command);

            // Return result
            return(new ScopeCreepActivityResponse()
            {
                Depth = request.Depth
            });
        }