From f33b435c95cb02a33402e88e02dcc99f7c6d68f3 Mon Sep 17 00:00:00 2001 From: nthmost-orkes Date: Sat, 4 Apr 2026 20:29:35 -0700 Subject: [PATCH] docs: add Hello World section to README (#26) Add a working end-to-end example covering: - Starting a local OSS Conductor server via Docker - Defining a worker with [WorkerTask] attribute - Connecting to http://localhost:8080/api (no auth required for OSS) - Registering a workflow and starting it via WorkflowExecutor Also update 'Next' link from conductor-sdk to conductor-oss org. --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25455334..b428a9c3 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,80 @@ Show support for the Conductor OSS. Please help spread the awareness by starrin dotnet add package conductor-csharp ``` +## Hello World + +This example creates a worker, connects it to a local Conductor server, and runs it end-to-end. + +### Step 1: Start a local Conductor server + +```shell +docker run --init -p 8080:8080 conductoross/conductor-standalone:latest +``` + +### Step 2: Define and run a worker + +```csharp +using Conductor.Client; +using Conductor.Client.Extensions; +using Conductor.Client.Worker; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +// Define a worker using the [WorkerTask] attribute +[WorkerTask] +public class GreetWorker +{ + [WorkerTask(taskType: "greet", batchSize: 1, pollIntervalMs: 200, workerId: "greeter")] + public string Greet([InputParam("name")] string name) + { + return $"Hello, {name}!"; + } +} + +// Connect to local OSS Conductor and start polling +var configuration = new Configuration +{ + BasePath = "http://localhost:8080/api" +}; + +var host = WorkflowTaskHost.CreateWorkerHost(configuration, LogLevel.Information, new GreetWorker()); +await host.StartAsync(); +Console.WriteLine("Worker started. Press Ctrl+C to stop."); +await Task.Delay(Timeout.Infinite); +``` + +### Step 3: Register a workflow and run it + +```csharp +using Conductor.Api; +using Conductor.Client; +using Conductor.Definition; +using Conductor.Definition.TaskType; +using Conductor.Executor; + +var configuration = new Configuration { BasePath = "http://localhost:8080/api" }; + +// Build and register the workflow +var workflow = new ConductorWorkflow() + .WithName("greetings") + .WithVersion(1) + .WithTask(new SimpleTask("greet", "greet_ref").WithInput("name", "${workflow.input.name}")); + +var executor = new WorkflowExecutor(configuration); +executor.RegisterWorkflow(workflow, overwrite: true); + +// Start the workflow +var workflowClient = configuration.GetClient(); +var workflowId = workflowClient.StartWorkflow( + name: "greetings", + body: new Dictionary { ["name"] = "World" }, + version: 1 +); + +Console.WriteLine($"Started workflow: {workflowId}"); +// Open http://localhost:8080 to see the execution in the UI +``` + ## Configurations ### Authentication Settings (Optional) @@ -60,4 +134,4 @@ workflowClient.StartWorkflow( ) ``` -### Next: [Create and run task workers](https://github.com/conductor-sdk/conductor-csharp/blob/main/docs/readme/workers.md) +### Next: [Create and run task workers](https://github.com/conductor-oss/csharp-sdk/blob/main/docs/readme/workers.md)