elsa-workflows / elsa-workflows/elsa-core
Proto.Actor Activities
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
### Description
An activity type provider that uses a given (set of) protobuf file(s) containing service definitions would allow users to orchestrate actors by using these activities in a workflow.
### Example
For example, take the following virtual actor definitions:
```proto
syntax = "proto3";
service ThermostatGrain {
rpc Read () returns (Temperature);
rpc Update (Temperature) returns (Empty);
}
service FireplaceGrain {
rpc Start () returns (Empty);
rpc Stop () returns (Empty);
}
```
The activity type provider would automatically yield the following activities using appropriate conventions:
- Read Thermostat
- Update Thermostat
- Start Fireplace
- Stop Fireplace
Using these activities, one could write the following workflow that keeps the room at a comfortable temperature:
```csharp
class ComfyRoomWorkflow : IWorkflow
{
public void Build(IWorkflowDefinitionBuilder workflow)
{
var temperatureVariable = new Variable();
const desiredTemperature = new Temperature(21);
workflow.WithRoot(new Sequence
{
Variables = { temperatureVariable }
Activities =
{
// Every 5 minutes.
Timer.FromMinutes(5),
// Read the current temperature into a variable.
new ReadThermostat(temperatureVariable ),
// If the current temprerature drops below a certain threshold:
new If(context => temperatureVariable.Get(context) < desiredTemperature)
{
// Then heat things up a little.
Then = new StartFireplace(),
// Else, stop the fire place. May want to check its current state first, but leaving that out for simplicity.
Else = new StopFireplace()
}
}
})
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.