workflow_control.proto 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. syntax = "proto3";
  2. package smartbotic.proto;
  3. // Lets a running workflow switch another workflow on or off, and read its
  4. // state, without going through the REST API.
  5. //
  6. // It lives on the webserver rather than in the runner because the webserver
  7. // owns the scheduler. Writing "active" straight into the workflows collection
  8. // would set a flag nothing acts on: registering and unregistering triggers
  9. // happens here, and a workflow switched on by a database write would sit there
  10. // looking enabled and never run.
  11. //
  12. // Served on the same port as CredentialService, and for the same reason - the
  13. // runner already holds a channel to it, and a request says which workflow is
  14. // asking so the webserver can decide whether to allow it.
  15. service WorkflowControlService {
  16. // Switch a workflow on or off. Registers or unregisters its triggers as
  17. // part of the same call.
  18. rpc SetWorkflowActive(SetWorkflowActiveRequest) returns (SetWorkflowActiveResponse);
  19. // What a workflow's state is: whether it is on, and how close it is to
  20. // being switched off by consecutive failures.
  21. rpc GetWorkflowState(GetWorkflowStateRequest) returns (GetWorkflowStateResponse);
  22. }
  23. message SetWorkflowActiveRequest {
  24. string workflow_id = 1; // the workflow to switch
  25. bool active = 2;
  26. string requesting_workflow_id = 3; // who is asking, for access control
  27. }
  28. message SetWorkflowActiveResponse {
  29. bool success = 1;
  30. bool active = 2; // the state afterwards
  31. bool changed = 3; // false when it was already in that state
  32. string error = 4;
  33. }
  34. message GetWorkflowStateRequest {
  35. string workflow_id = 1;
  36. string requesting_workflow_id = 2;
  37. }
  38. message GetWorkflowStateResponse {
  39. bool success = 1;
  40. string name = 2;
  41. bool active = 3;
  42. int32 consecutive_failures = 4;
  43. int32 deactivate_after_failures = 5; // 0 when the workflow never switches itself off
  44. string deactivated_reason = 6; // why it switched itself off, when it did
  45. int64 published_version = 7;
  46. string error = 8;
  47. }