@@ -500,6 +500,56 @@ start().catch((e) => {
500
500
501
501
> For a full guide on distributed locks visit [ How-To: Use Distributed Locks] ({{< ref howto-use-distributed-lock.md >}}).
502
502
503
+ ### Workflow API
504
+
505
+ #### Workflow management
506
+
507
+ ``` typescript
508
+ import { DaprClient } from " @dapr/dapr" ;
509
+
510
+ async function start() {
511
+ const client = new DaprClient ();
512
+
513
+ // Start a new workflow instance
514
+ const instanceId = await client .workflow .start (" OrderProcessingWorkflow" , {
515
+ Name: " Paperclips" ,
516
+ TotalCost: 99.95 ,
517
+ Quantity: 4 ,
518
+ });
519
+ console .log (` Started workflow instance ${instanceId } ` );
520
+
521
+ // Get a workflow instance
522
+ const workflow = await client .workflow .get (instanceId );
523
+ console .log (
524
+ ` Workflow ${workflow .workflowName }, created at ${workflow .createdAt .toUTCString ()}, has status ${
525
+ workflow .runtimeStatus
526
+ } ` ,
527
+ );
528
+ console .log (` Additional properties: ${JSON .stringify (workflow .properties )} ` );
529
+
530
+ // Pause a workflow instance
531
+ await client .workflow .pause (instanceId );
532
+ console .log (` Paused workflow instance ${instanceId } ` );
533
+
534
+ // Resume a workflow instance
535
+ await client .workflow .resume (instanceId );
536
+ console .log (` Resumed workflow instance ${instanceId } ` );
537
+
538
+ // Terminate a workflow instance
539
+ await client .workflow .terminate (instanceId );
540
+ console .log (` Terminated workflow instance ${instanceId } ` );
541
+
542
+ // Purge a workflow instance
543
+ await client .workflow .purge (instanceId );
544
+ console .log (` Purged workflow instance ${instanceId } ` );
545
+ }
546
+
547
+ start ().catch ((e ) => {
548
+ console .error (e );
549
+ process .exit (1 );
550
+ });
551
+ ```
552
+
503
553
## Related links
504
554
505
555
- [ JavaScript SDK examples] ( https://github.com/dapr/js-sdk/tree/master/examples )
0 commit comments