From 557ff4512f6bd87b4df92498dcf322b15033e59a Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Tue, 7 May 2024 12:27:57 -0400 Subject: [PATCH 1/3] add port flag Signed-off-by: Hannah Hunter --- .../supported-state-stores/setup-mongodb.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md index db3fec2ed..85b64cc51 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md @@ -85,7 +85,7 @@ If you wish to use MongoDB as an actor store, add this metadata option to your C You can run a single MongoDB instance locally using Docker: ```sh -docker run --name some-mongo -d mongo +docker run --name some-mongo -d -p 27017:27017 mongo ``` You can then interact with the server at `localhost:27017`. If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`. From 9ba08df562eba8ecb5219db9b47e9ba858227b11 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Tue, 7 May 2024 17:38:19 -0400 Subject: [PATCH 2/3] link to relevant code example for transational methods (#4135) Signed-off-by: Hannah Hunter --- .../building-blocks/state-management/howto-outbox.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-outbox.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-outbox.md index 283180272..59dcf3c37 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-outbox.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/howto-outbox.md @@ -28,8 +28,10 @@ The diagram below is an overview of how the outbox feature works: The outbox feature can be used with using any [transactional state store]({{< ref supported-state-stores >}}) supported by Dapr. All [pub/sub brokers]({{< ref supported-pubsub >}}) are supported with the outbox feature. +[Learn more about the transactional methods you can use.]({{< ref "howto-get-save-state.md#perform-state-transactions" >}}) + {{% alert title="Note" color="primary" %}} -Message brokers that work with the competing consumer pattern (for example, [Apache Kafka]({{< ref setup-apache-kafka>}}) are encouraged to reduce the chances of duplicate events. +Message brokers that work with the competing consumer pattern (for example, [Apache Kafka]({{< ref setup-apache-kafka>}})) are encouraged to reduce the chances of duplicate events. {{% /alert %}} ## Usage From 9055407d9981d24e617e082bc31ea82daf3325d4 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Thu, 9 May 2024 13:40:32 -0500 Subject: [PATCH 3/3] Added example for limiting workflow concurrency in .NET fan-in/out example (#4132) * Added workflow concurrency example for .NET Signed-off-by: Whit Waldo * Removed extension method that was doubling up calls and shortened to simpler inline example Signed-off-by: Whit Waldo * Removed unused extension method Signed-off-by: Whit Waldo * Neglected to include the Task.WhenAll line persisting the remaining result values Signed-off-by: Whit Waldo * Fixed parallism limit Signed-off-by: Whit Waldo * Adding proposed concluding thoughts Co-authored-by: Chris Gillum Signed-off-by: Whit Waldo * Approved proposed language Co-authored-by: Chris Gillum Signed-off-by: Whit Waldo --------- Signed-off-by: Whit Waldo Co-authored-by: Chris Gillum Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> --- .../workflow/workflow-patterns.md | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-patterns.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-patterns.md index f7865f55e..fe6f69b63 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-patterns.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-patterns.md @@ -586,7 +586,45 @@ The key takeaways from this example are: - The number of parallel tasks can be static or dynamic - The workflow itself is capable of aggregating the results of parallel executions -While not shown in the example, it's possible to go further and limit the degree of concurrency using simple, language-specific constructs. Furthermore, the execution of the workflow is durable. If a workflow starts 100 parallel task executions and only 40 complete before the process crashes, the workflow restarts itself automatically and only schedules the remaining 60 tasks. +Furthermore, the execution of the workflow is durable. If a workflow starts 100 parallel task executions and only 40 complete before the process crashes, the workflow restarts itself automatically and only schedules the remaining 60 tasks. + +It's possible to go further and limit the degree of concurrency using simple, language-specific constructs. The sample code below illustrates how to restrict the degree of fan-out to just 5 concurrent activity executions: + +{{< tabs ".NET" >}} + +{{% codetab %}} + +```csharp + +//Revisiting the earlier example... +// Get a list of N work items to process in parallel. +object[] workBatch = await context.CallActivityAsync("GetWorkBatch", null); + +const int MaxParallelism = 5; +var results = new List(); +var inFlightTasks = new HashSet>(); +foreach(var workItem in workBatch) +{ + if (inFlightTasks.Count >= MaxParallelism) + { + var finishedTask = await Task.WhenAny(inFlightTasks); + results.Add(finishedTask.Result); + inFlightTasks.Remove(finishedTask); + } + + inFlightTasks.Add(context.CallActivityAsync("ProcessWorkItem", workItem)); +} +results.AddRange(await Task.WhenAll(inFlightTasks)); + +var sum = results.Sum(t => t); +await context.CallActivityAsync("PostResults", sum); +``` + +{{% /codetab %}} + +{{< /tabs >}} + +Limiting the degree of concurrency in this way can be useful for limiting contention against shared resources. For example, if the activities need to call into external resources that have their own concurrency limits, like a databases or external APIs, it can be useful to ensure that no more than a specified number of activities call that resource concurrently. ## Async HTTP APIs