Skip to content

Proto.Actor Activities #2960

@sfmskywalker

Description

@sfmskywalker

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:

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:

class ComfyRoomWorkflow : IWorkflow
{
   public void Build(IWorkflowDefinitionBuilder workflow)
   {
      var temperatureVariable = new Variable<Temperature>();
      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()
             }
          }
      })
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    activityThis issue relates to a workflows activitycoreThis issue relates to the core library

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions