Skip to content

Commit 757c869

Browse files
Merge pull request #144 from conductor-oss/fix/readme-hello-world-and-links
Add Hello World quickstart and fix old org links in README
2 parents b1c1d5e + 12731eb commit 757c869

2 files changed

Lines changed: 118 additions & 5 deletions

File tree

README.md

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,126 @@ Show support for the Conductor OSS. Please help spread the awareness by starrin
1616

1717
[![GitHub stars](https://img.shields.io/github/stars/conductor-oss/conductor.svg?style=social&label=Star&maxAge=)](https://GitHub.com/conductor-oss/conductor/)
1818

19-
20-
### Setup Conductor C# Package​
19+
## Start Conductor Server
20+
21+
If you don't already have a Conductor server running, start one with Docker:
22+
23+
```shell
24+
docker run --init -p 8080:8080 conductoross/conductor:latest
25+
```
26+
27+
The UI will be available at `http://localhost:8080` and the API at `http://localhost:8080/api`.
28+
29+
## Setup Conductor C# Package
30+
31+
```shell
32+
dotnet add package conductor-csharp
33+
```
34+
35+
## Hello World
36+
37+
This quickstart shows the full flow: define a worker, define a workflow, register it, run it.
38+
39+
**Step 1: Create a new console project**
2140

2241
```shell
42+
dotnet new console -n conductor-hello
43+
cd conductor-hello
2344
dotnet add package conductor-csharp
2445
```
2546

47+
**Step 2: Replace `Program.cs` with the following**
48+
49+
```csharp
50+
using Conductor.Client;
51+
using Conductor.Client.Extensions;
52+
using Conductor.Client.Worker;
53+
using Conductor.Definition;
54+
using Conductor.Definition.TaskType;
55+
using Conductor.Executor;
56+
57+
// Configure the SDK — reads CONDUCTOR_SERVER_URL from the environment,
58+
// or falls back to a local server.
59+
var configuration = new Configuration
60+
{
61+
BasePath = Environment.GetEnvironmentVariable("CONDUCTOR_SERVER_URL")
62+
?? "http://localhost:8080/api"
63+
};
64+
65+
// Define the workflow: one SIMPLE task called "greet".
66+
var workflow = new ConductorWorkflow()
67+
.WithName("greetings")
68+
.WithVersion(1);
69+
70+
var greetTask = new SimpleTask("greet", "greet_ref")
71+
.WithInput("name", workflow.Input("name"));
72+
workflow.WithTask(greetTask);
73+
74+
// Register the workflow definition on the server.
75+
var executor = new WorkflowExecutor(configuration);
76+
executor.RegisterWorkflow(workflow, overwrite: true);
77+
78+
// Start the worker host — it discovers GreetWorker automatically.
79+
var host = WorkflowTaskHost.CreateWorkerHost(
80+
Microsoft.Extensions.Logging.LogLevel.Information,
81+
new GreetWorker());
82+
await host.StartAsync();
83+
84+
// Run the workflow and print the execution ID.
85+
var workflowId = executor.StartWorkflow(new StartWorkflowRequest
86+
{
87+
Name = "greetings",
88+
Version = 1,
89+
Input = new Dictionary<string, object> { ["name"] = "Conductor" }
90+
});
91+
Console.WriteLine($"Started workflow: {workflowId}");
92+
Console.WriteLine($"View execution: http://localhost:8080/execution/{workflowId}");
93+
94+
// Keep the worker running until Ctrl-C.
95+
await host.WaitForShutdownAsync();
96+
```
97+
98+
**Step 3: Add the worker class — create `GreetWorker.cs`**
99+
100+
```csharp
101+
using Conductor.Client.Extensions;
102+
using Conductor.Client.Interfaces;
103+
using Conductor.Client.Models;
104+
using Conductor.Client.Worker;
105+
using Task = Conductor.Client.Models.Task;
106+
107+
public class GreetWorker : IWorkflowTask
108+
{
109+
public string TaskType => "greet";
110+
public WorkflowTaskExecutorConfiguration WorkerSettings { get; } = new();
111+
112+
public TaskResult Execute(Task task)
113+
{
114+
var name = task.InputData.GetValueOrDefault("name")?.ToString() ?? "World";
115+
var result = task.Completed();
116+
result.OutputData = new Dictionary<string, object>
117+
{
118+
["greeting"] = $"Hello, {name}!"
119+
};
120+
return result;
121+
}
122+
}
123+
```
124+
125+
**Step 4: Run it**
126+
127+
```shell
128+
dotnet run
129+
```
130+
131+
Expected output:
132+
```
133+
Started workflow: <workflow-id>
134+
View execution: http://localhost:8080/execution/<workflow-id>
135+
```
136+
137+
Open the UI link to see the completed execution and its output.
138+
26139
## Configurations
27140

28141
### Authentication Settings (Optional)
@@ -60,4 +173,4 @@ workflowClient.StartWorkflow(
60173
)
61174
```
62175

63-
### Next: [Create and run task workers](https://github.com/conductor-sdk/conductor-csharp/blob/main/docs/readme/workers.md)
176+
### Next: [Create and run task workers](https://github.com/conductor-oss/csharp-sdk/blob/main/docs/readme/workers.md)

docs/readme/workers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ await host.startAsync();
4848
Thread.Sleep(TimeSpan.FromSeconds(100));
4949
```
5050

51-
Check out our [integration tests](https://github.com/conductor-sdk/conductor-csharp/blob/92c7580156a89322717c94aeaea9e5201fe577eb/Tests/Worker/WorkerTests.cs#L37) for more examples
51+
Check out our [integration tests](https://github.com/conductor-oss/csharp-sdk/blob/main/Tests/Worker/WorkerTests.cs) for more examples
5252

5353
Worker SDK collects the following metrics:
5454

@@ -65,4 +65,4 @@ Worker SDK collects the following metrics:
6565

6666
Metrics on client side supplements the one collected from server in identifying the network as well as client side issues.
6767

68-
### Next: [Create and Execute Workflows](https://github.com/conductor-sdk/conductor-csharp/blob/main/docs/readme/workflow.md)
68+
### Next: [Create and Execute Workflows](https://github.com/conductor-oss/csharp-sdk/blob/main/docs/readme/workflow.md)

0 commit comments

Comments
 (0)