diff --git a/config/config.go b/config/config.go index db8ece554..ca30597c6 100644 --- a/config/config.go +++ b/config/config.go @@ -22,7 +22,7 @@ const ( serviceDBVersion = "v3" executionDBVersion = "v2" instanceDBVersion = "v1" - workflowDBVersion = "v1" + processDBVersion = "v1" ) var ( @@ -49,7 +49,7 @@ type Config struct { ServiceRelativePath string InstanceRelativePath string ExecutionRelativePath string - WorkflowRelativePath string + ProcessRelativePath string } Tendermint struct { @@ -95,7 +95,7 @@ func New() (*Config, error) { c.Database.ServiceRelativePath = filepath.Join("database", "services", serviceDBVersion) c.Database.InstanceRelativePath = filepath.Join("database", "instance", instanceDBVersion) c.Database.ExecutionRelativePath = filepath.Join("database", "executions", executionDBVersion) - c.Database.WorkflowRelativePath = filepath.Join("database", "workflows", workflowDBVersion) + c.Database.ProcessRelativePath = filepath.Join("database", "processes", processDBVersion) c.Tendermint.Config = tmconfig.DefaultConfig() c.Tendermint.Config.P2P.AddrBookStrict = false diff --git a/core/main.go b/core/main.go index 7f74a5333..ea6ac750f 100644 --- a/core/main.go +++ b/core/main.go @@ -13,7 +13,7 @@ import ( "github.com/mesg-foundation/engine/database/store" "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/logger" - "github.com/mesg-foundation/engine/scheduler" + "github.com/mesg-foundation/engine/orchestrator" enginesdk "github.com/mesg-foundation/engine/sdk" instancesdk "github.com/mesg-foundation/engine/sdk/instance" servicesdk "github.com/mesg-foundation/engine/sdk/service" @@ -29,7 +29,7 @@ import ( var network = flag.Bool("experimental-network", false, "start the engine with the network") -func initDatabases(cfg *config.Config) (*database.ServiceDB, *database.LevelDBInstanceDB, *database.LevelDBExecutionDB, *database.LevelDBWorkflowDB, error) { +func initDatabases(cfg *config.Config) (*database.ServiceDB, *database.LevelDBInstanceDB, *database.LevelDBExecutionDB, *database.LevelDBProcessDB, error) { // init services db. serviceStore, err := store.NewLevelDBStore(filepath.Join(cfg.Path, cfg.Database.ServiceRelativePath)) if err != nil { @@ -49,13 +49,13 @@ func initDatabases(cfg *config.Config) (*database.ServiceDB, *database.LevelDBIn return nil, nil, nil, nil, err } - // init workflow db. - workflowDB, err := database.NewWorkflowDB(filepath.Join(cfg.Path, cfg.Database.WorkflowRelativePath)) + // init process db. + processDB, err := database.NewProcessDB(filepath.Join(cfg.Path, cfg.Database.ProcessRelativePath)) if err != nil { return nil, nil, nil, nil, err } - return serviceDB, instanceDB, executionDB, workflowDB, nil + return serviceDB, instanceDB, executionDB, processDB, nil } func deployCoreServices(cfg *config.Config, sdk *enginesdk.SDK) error { @@ -132,7 +132,7 @@ func main() { logger.Init(cfg.Log.Format, cfg.Log.Level, cfg.Log.ForceColors) // init databases - serviceDB, instanceDB, executionDB, workflowDB, err := initDatabases(cfg) + serviceDB, instanceDB, executionDB, processDB, err := initDatabases(cfg) if err != nil { logrus.WithField("module", "main").Fatalln(err) } @@ -155,7 +155,7 @@ func main() { app := cosmos.NewApp(logger.TendermintLogger(), db) // init sdk. - sdk, err = enginesdk.New(app, c, instanceDB, executionDB, workflowDB, cfg.Name, strconv.Itoa(port)) + sdk, err = enginesdk.New(app, c, instanceDB, executionDB, processDB, cfg.Name, strconv.Itoa(port)) if err != nil { logrus.WithField("module", "main").Fatalln(err) } @@ -172,7 +172,7 @@ func main() { logrus.WithField("module", "main").Fatalln(err) } } else { - sdk = enginesdk.NewDeprecated(c, serviceDB, instanceDB, executionDB, workflowDB, cfg.Name, strconv.Itoa(port)) + sdk = enginesdk.NewDeprecated(c, serviceDB, instanceDB, executionDB, processDB, cfg.Name, strconv.Itoa(port)) // init system services. if err := deployCoreServices(cfg, sdk); err != nil { @@ -191,8 +191,8 @@ func main() { } }() - logrus.WithField("module", "main").Info("starting workflow engine") - s := scheduler.New(sdk.Event, sdk.Execution, sdk.Workflow) + logrus.WithField("module", "main").Info("starting process engine") + s := orchestrator.New(sdk.Event, sdk.Execution, sdk.Process) go func() { if err := s.Start(); err != nil { logrus.WithField("module", "main").Fatalln(err) diff --git a/database/process_db.go b/database/process_db.go new file mode 100644 index 000000000..b45f7a821 --- /dev/null +++ b/database/process_db.go @@ -0,0 +1,124 @@ +package database + +import ( + "encoding/json" + "fmt" + + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/process" + "github.com/sirupsen/logrus" + "github.com/syndtr/goleveldb/leveldb" +) + +// ProcessDB describes the API of database package. +type ProcessDB interface { + // Save saves a process to database. + Save(s *process.Process) error + + // Get gets a process from database by its unique hash. + Get(hash hash.Hash) (*process.Process, error) + + // Delete deletes a process from database by its unique hash. + Delete(hash hash.Hash) error + + // All returns all processes from database. + All() ([]*process.Process, error) + + // Close closes underlying database connection. + Close() error +} + +// LevelDBProcessDB is a database for storing processes definition. +type LevelDBProcessDB struct { + db *leveldb.DB +} + +// NewProcessDB returns the database which is located under given path. +func NewProcessDB(path string) (*LevelDBProcessDB, error) { + db, err := leveldb.OpenFile(path, nil) + if err != nil { + return nil, err + } + return &LevelDBProcessDB{db: db}, nil +} + +// marshal returns the byte slice from process. +func (d *LevelDBProcessDB) marshal(s *process.Process) ([]byte, error) { + return json.Marshal(s) +} + +// unmarshal returns the process from byte slice. +func (d *LevelDBProcessDB) unmarshal(hash hash.Hash, value []byte) (*process.Process, error) { + var s process.Process + if err := json.Unmarshal(value, &s); err != nil { + return nil, fmt.Errorf("database: could not decode process %q: %s", hash, err) + } + return &s, nil +} + +// All returns every process in database. +func (d *LevelDBProcessDB) All() ([]*process.Process, error) { + var ( + processes []*process.Process + iter = d.db.NewIterator(nil, nil) + ) + for iter.Next() { + hash := hash.Hash(iter.Key()) + s, err := d.unmarshal(hash, iter.Value()) + if err != nil { + // NOTE: Ignore all decode errors (possibly due to a process + // structure change or database corruption) + logrus.WithField("process", hash.String()).Warning(err.Error()) + continue + } + processes = append(processes, s) + } + iter.Release() + return processes, iter.Error() +} + +// Delete deletes process from database. +func (d *LevelDBProcessDB) Delete(hash hash.Hash) error { + tx, err := d.db.OpenTransaction() + if err != nil { + return err + } + if _, err := tx.Get(hash, nil); err != nil { + tx.Discard() + return err + } + if err := tx.Delete(hash, nil); err != nil { + tx.Discard() + return err + } + return tx.Commit() + +} + +// Get retrives process from database. +func (d *LevelDBProcessDB) Get(hash hash.Hash) (*process.Process, error) { + b, err := d.db.Get(hash, nil) + if err != nil { + return nil, err + } + return d.unmarshal(hash, b) +} + +// Save stores process in database. +// If there is an another process that uses the same sid, it'll be deleted. +func (d *LevelDBProcessDB) Save(s *process.Process) error { + if s.Hash.IsZero() { + return errCannotSaveWithoutHash + } + + b, err := d.marshal(s) + if err != nil { + return err + } + return d.db.Put(s.Hash, b, nil) +} + +// Close closes database. +func (d *LevelDBProcessDB) Close() error { + return d.db.Close() +} diff --git a/database/workflow_db.go b/database/workflow_db.go deleted file mode 100644 index c0a861b92..000000000 --- a/database/workflow_db.go +++ /dev/null @@ -1,124 +0,0 @@ -package database - -import ( - "encoding/json" - "fmt" - - "github.com/mesg-foundation/engine/hash" - "github.com/mesg-foundation/engine/workflow" - "github.com/sirupsen/logrus" - "github.com/syndtr/goleveldb/leveldb" -) - -// WorkflowDB describes the API of database package. -type WorkflowDB interface { - // Save saves a workflow to database. - Save(s *workflow.Workflow) error - - // Get gets a workflow from database by its unique hash. - Get(hash hash.Hash) (*workflow.Workflow, error) - - // Delete deletes a workflow from database by its unique hash. - Delete(hash hash.Hash) error - - // All returns all workflows from database. - All() ([]*workflow.Workflow, error) - - // Close closes underlying database connection. - Close() error -} - -// LevelDBWorkflowDB is a database for storing workflows definition. -type LevelDBWorkflowDB struct { - db *leveldb.DB -} - -// NewWorkflowDB returns the database which is located under given path. -func NewWorkflowDB(path string) (*LevelDBWorkflowDB, error) { - db, err := leveldb.OpenFile(path, nil) - if err != nil { - return nil, err - } - return &LevelDBWorkflowDB{db: db}, nil -} - -// marshal returns the byte slice from workflow. -func (d *LevelDBWorkflowDB) marshal(s *workflow.Workflow) ([]byte, error) { - return json.Marshal(s) -} - -// unmarshal returns the workflow from byte slice. -func (d *LevelDBWorkflowDB) unmarshal(hash hash.Hash, value []byte) (*workflow.Workflow, error) { - var s workflow.Workflow - if err := json.Unmarshal(value, &s); err != nil { - return nil, fmt.Errorf("database: could not decode workflow %q: %s", hash, err) - } - return &s, nil -} - -// All returns every workflow in database. -func (d *LevelDBWorkflowDB) All() ([]*workflow.Workflow, error) { - var ( - workflows []*workflow.Workflow - iter = d.db.NewIterator(nil, nil) - ) - for iter.Next() { - hash := hash.Hash(iter.Key()) - s, err := d.unmarshal(hash, iter.Value()) - if err != nil { - // NOTE: Ignore all decode errors (possibly due to a workflow - // structure change or database corruption) - logrus.WithField("workflow", hash.String()).Warning(err.Error()) - continue - } - workflows = append(workflows, s) - } - iter.Release() - return workflows, iter.Error() -} - -// Delete deletes workflow from database. -func (d *LevelDBWorkflowDB) Delete(hash hash.Hash) error { - tx, err := d.db.OpenTransaction() - if err != nil { - return err - } - if _, err := tx.Get(hash, nil); err != nil { - tx.Discard() - return err - } - if err := tx.Delete(hash, nil); err != nil { - tx.Discard() - return err - } - return tx.Commit() - -} - -// Get retrives workflow from database. -func (d *LevelDBWorkflowDB) Get(hash hash.Hash) (*workflow.Workflow, error) { - b, err := d.db.Get(hash, nil) - if err != nil { - return nil, err - } - return d.unmarshal(hash, b) -} - -// Save stores workflow in database. -// If there is an another workflow that uses the same sid, it'll be deleted. -func (d *LevelDBWorkflowDB) Save(s *workflow.Workflow) error { - if s.Hash.IsZero() { - return errCannotSaveWithoutHash - } - - b, err := d.marshal(s) - if err != nil { - return err - } - return d.db.Put(s.Hash, b, nil) -} - -// Close closes database. -func (d *LevelDBWorkflowDB) Close() error { - return d.db.Close() -} diff --git a/execution/execution.go b/execution/execution.go index 26952af75..cb9a5f9f6 100644 --- a/execution/execution.go +++ b/execution/execution.go @@ -35,7 +35,7 @@ func (s Status) String() (r string) { // Execution stores all information about executions. type Execution struct { Hash hash.Hash `hash:"-"` - WorkflowHash hash.Hash `hash:"name:workflowHash"` + ProcessHash hash.Hash `hash:"name:processHash"` ParentHash hash.Hash `hash:"name:parentHash"` EventHash hash.Hash `hash:"name:eventHash"` Status Status `hash:"-"` @@ -49,9 +49,9 @@ type Execution struct { } // New returns a new execution. It returns an error if inputs are invalid. -func New(workflowHash, instanceHash, parentHash, eventHash hash.Hash, stepID string, taskKey string, inputs map[string]interface{}, tags []string) *Execution { +func New(processHash, instanceHash, parentHash, eventHash hash.Hash, stepID string, taskKey string, inputs map[string]interface{}, tags []string) *Execution { exec := &Execution{ - WorkflowHash: workflowHash, + ProcessHash: processHash, EventHash: eventHash, InstanceHash: instanceHash, ParentHash: parentHash, diff --git a/filter/filter.go b/filter/filter.go index dadb4c9bf..09b4696e7 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -1,9 +1,9 @@ package filter -// Predicate is the type of conditions that can be applied in a filter of a workflow trigger +// Predicate is the type of conditions that can be applied in a filter of a process trigger type Predicate uint -// List of possible conditions for workflow's filter +// List of possible conditions for process's filter const ( EQ Predicate = iota + 1 ) diff --git a/scheduler/scheduler.go b/orchestrator/orchestrator.go similarity index 57% rename from scheduler/scheduler.go rename to orchestrator/orchestrator.go index dcd1066ca..e446a12ab 100644 --- a/scheduler/scheduler.go +++ b/orchestrator/orchestrator.go @@ -1,4 +1,4 @@ -package scheduler +package orchestrator import ( "fmt" @@ -6,40 +6,40 @@ import ( "github.com/mesg-foundation/engine/event" "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/process" eventsdk "github.com/mesg-foundation/engine/sdk/event" executionsdk "github.com/mesg-foundation/engine/sdk/execution" - workflowsdk "github.com/mesg-foundation/engine/sdk/workflow" - "github.com/mesg-foundation/engine/workflow" + processesdk "github.com/mesg-foundation/engine/sdk/process" "github.com/sirupsen/logrus" ) -// Scheduler manages the executions based on the definition of the workflows -type Scheduler struct { +// Orchestrator manages the executions based on the definition of the processes +type Orchestrator struct { event *eventsdk.Event eventStream *eventsdk.Listener execution *executionsdk.Execution executionStream *executionsdk.Listener - workflow *workflowsdk.Workflow + process *processesdk.Process ErrC chan error } -// New creates a new Workflow instance -func New(event *eventsdk.Event, execution *executionsdk.Execution, workflow *workflowsdk.Workflow) *Scheduler { - return &Scheduler{ +// New creates a new Process instance +func New(event *eventsdk.Event, execution *executionsdk.Execution, process *processesdk.Process) *Orchestrator { + return &Orchestrator{ event: event, execution: execution, - workflow: workflow, + process: process, ErrC: make(chan error), } } -// Start the workflow engine -func (s *Scheduler) Start() error { +// Start the process engine +func (s *Orchestrator) Start() error { if s.eventStream != nil || s.executionStream != nil { - return fmt.Errorf("workflow scheduler already running") + return fmt.Errorf("process orchestrator already running") } s.eventStream = s.event.GetStream(nil) s.executionStream = s.execution.GetStream(&executionsdk.Filter{ @@ -48,18 +48,18 @@ func (s *Scheduler) Start() error { for { select { case event := <-s.eventStream.C: - go s.process(s.eventFilter(event), nil, event, event.Data) + go s.execute(s.eventFilter(event), nil, event, event.Data) case execution := <-s.executionStream.C: - go s.process(s.resultFilter(execution), execution, nil, execution.Outputs) - go s.process(s.dependencyFilter(execution), execution, nil, execution.Outputs) + go s.execute(s.resultFilter(execution), execution, nil, execution.Outputs) + go s.execute(s.dependencyFilter(execution), execution, nil, execution.Outputs) } } } -func (s *Scheduler) eventFilter(event *event.Event) func(wf *workflow.Workflow, node workflow.Node) (bool, error) { - return func(wf *workflow.Workflow, node workflow.Node) (bool, error) { +func (s *Orchestrator) eventFilter(event *event.Event) func(wf *process.Process, node process.Node) (bool, error) { + return func(wf *process.Process, node process.Node) (bool, error) { switch n := node.(type) { - case *workflow.Event: + case *process.Event: return n.InstanceHash.Equal(event.InstanceHash) && n.EventKey == event.Key, nil default: return false, nil @@ -67,10 +67,10 @@ func (s *Scheduler) eventFilter(event *event.Event) func(wf *workflow.Workflow, } } -func (s *Scheduler) resultFilter(exec *execution.Execution) func(wf *workflow.Workflow, node workflow.Node) (bool, error) { - return func(wf *workflow.Workflow, node workflow.Node) (bool, error) { +func (s *Orchestrator) resultFilter(exec *execution.Execution) func(wf *process.Process, node process.Node) (bool, error) { + return func(wf *process.Process, node process.Node) (bool, error) { switch n := node.(type) { - case *workflow.Result: + case *process.Result: return n.InstanceHash.Equal(exec.InstanceHash) && n.TaskKey == exec.TaskKey, nil default: return false, nil @@ -78,9 +78,9 @@ func (s *Scheduler) resultFilter(exec *execution.Execution) func(wf *workflow.Wo } } -func (s *Scheduler) dependencyFilter(exec *execution.Execution) func(wf *workflow.Workflow, node workflow.Node) (bool, error) { - return func(wf *workflow.Workflow, node workflow.Node) (bool, error) { - if !exec.WorkflowHash.Equal(wf.Hash) { +func (s *Orchestrator) dependencyFilter(exec *execution.Execution) func(wf *process.Process, node process.Node) (bool, error) { + return func(wf *process.Process, node process.Node) (bool, error) { + if !exec.ProcessHash.Equal(wf.Hash) { return false, nil } parents := wf.ParentIDs(node.ID()) @@ -94,8 +94,8 @@ func (s *Scheduler) dependencyFilter(exec *execution.Execution) func(wf *workflo } } -func (s *Scheduler) findNodes(wf *workflow.Workflow, filter func(wf *workflow.Workflow, n workflow.Node) (bool, error)) []workflow.Node { - return wf.FindNodes(func(n workflow.Node) bool { +func (s *Orchestrator) findNodes(wf *process.Process, filter func(wf *process.Process, n process.Node) (bool, error)) []process.Node { + return wf.FindNodes(func(n process.Node) bool { res, err := filter(wf, n) if err != nil { s.ErrC <- err @@ -104,36 +104,36 @@ func (s *Scheduler) findNodes(wf *workflow.Workflow, filter func(wf *workflow.Wo }) } -func (s *Scheduler) process(filter func(wf *workflow.Workflow, node workflow.Node) (bool, error), exec *execution.Execution, event *event.Event, data map[string]interface{}) { - workflows, err := s.workflow.List() +func (s *Orchestrator) execute(filter func(wf *process.Process, node process.Node) (bool, error), exec *execution.Execution, event *event.Event, data map[string]interface{}) { + processes, err := s.process.List() if err != nil { s.ErrC <- err return } - for _, wf := range workflows { + for _, wf := range processes { for _, node := range s.findNodes(wf, filter) { - if err := s.processNode(wf, node, exec, event, data); err != nil { + if err := s.executeNode(wf, node, exec, event, data); err != nil { s.ErrC <- err } } } } -func (s *Scheduler) processNode(wf *workflow.Workflow, n workflow.Node, exec *execution.Execution, event *event.Event, data map[string]interface{}) error { - logrus.WithField("module", "orchestrator").WithField("nodeID", n.ID()).WithField("type", fmt.Sprintf("%T", n)).Debug("process workflow") - if node, ok := n.(*workflow.Task); ok { +func (s *Orchestrator) executeNode(wf *process.Process, n process.Node, exec *execution.Execution, event *event.Event, data map[string]interface{}) error { + logrus.WithField("module", "orchestrator").WithField("nodeID", n.ID()).WithField("type", fmt.Sprintf("%T", n)).Debug("process process") + if node, ok := n.(*process.Task); ok { // This returns directly because a task cannot process its children. // Children will be processed only when the execution is done and the dependencies are resolved return s.processTask(node, wf, exec, event, data) } - if node, ok := n.(*workflow.Map); ok { + if node, ok := n.(*process.Map); ok { var err error data, err = s.processMap(node, wf, exec, data) if err != nil { return err } } - if node, ok := n.(*workflow.Filter); ok { + if node, ok := n.(*process.Filter); ok { if !node.Filter.Match(data) { return nil } @@ -145,7 +145,7 @@ func (s *Scheduler) processNode(wf *workflow.Workflow, n workflow.Node, exec *ex s.ErrC <- err continue } - if err := s.processNode(wf, children, exec, event, data); err != nil { + if err := s.executeNode(wf, children, exec, event, data); err != nil { // does not return an error to continue to process other tasks if needed s.ErrC <- err } @@ -153,14 +153,14 @@ func (s *Scheduler) processNode(wf *workflow.Workflow, n workflow.Node, exec *ex return nil } -func (s *Scheduler) processMap(mapping *workflow.Map, wf *workflow.Workflow, exec *execution.Execution, data map[string]interface{}) (map[string]interface{}, error) { +func (s *Orchestrator) processMap(mapping *process.Map, wf *process.Process, exec *execution.Execution, data map[string]interface{}) (map[string]interface{}, error) { result := make(map[string]interface{}) for _, output := range mapping.Outputs { node, err := wf.FindNode(output.Ref.NodeKey) if err != nil { return nil, err } - _, isTask := node.(*workflow.Task) + _, isTask := node.(*process.Task) if isTask { value, err := s.resolveInput(wf.Hash, exec, output.Ref.NodeKey, output.Ref.Key) if err != nil { @@ -174,8 +174,8 @@ func (s *Scheduler) processMap(mapping *workflow.Map, wf *workflow.Workflow, exe return result, nil } -func (s *Scheduler) resolveInput(wfHash hash.Hash, exec *execution.Execution, nodeKey string, outputKey string) (interface{}, error) { - if !wfHash.Equal(exec.WorkflowHash) { +func (s *Orchestrator) resolveInput(wfHash hash.Hash, exec *execution.Execution, nodeKey string, outputKey string) (interface{}, error) { + if !wfHash.Equal(exec.ProcessHash) { return nil, fmt.Errorf("reference's nodeKey not found") } if exec.StepID != nodeKey { @@ -188,7 +188,7 @@ func (s *Scheduler) resolveInput(wfHash hash.Hash, exec *execution.Execution, no return exec.Outputs[outputKey], nil } -func (s *Scheduler) processTask(task *workflow.Task, wf *workflow.Workflow, exec *execution.Execution, event *event.Event, data map[string]interface{}) error { +func (s *Orchestrator) processTask(task *process.Task, wf *process.Process, exec *execution.Execution, event *event.Event, data map[string]interface{}) error { var eventHash, execHash hash.Hash if event != nil { eventHash = event.Hash diff --git a/workflow/graph.go b/process/graph.go similarity index 93% rename from workflow/graph.go rename to process/graph.go index b61949fe1..549b327cb 100644 --- a/workflow/graph.go +++ b/process/graph.go @@ -1,4 +1,4 @@ -package workflow +package process import "fmt" @@ -152,16 +152,16 @@ func (g Graph) maximumParents() int { func (g Graph) shouldBeDirectedTree() error { if !g.hasNodes() { - return fmt.Errorf("workflow needs to have at least one node") + return fmt.Errorf("process needs to have at least one node") } if !g.isAcyclic() { - return fmt.Errorf("workflow should not contain any cycles") + return fmt.Errorf("process should not contain any cycles") } if !g.isConnected() { - return fmt.Errorf("workflow should be a connected graph") + return fmt.Errorf("process should be a connected graph") } if g.maximumParents() > 1 { - return fmt.Errorf("workflow should contain nodes with one parent maximum") + return fmt.Errorf("process should contain nodes with one parent maximum") } return nil } diff --git a/workflow/graph_test.go b/process/graph_test.go similarity index 99% rename from workflow/graph_test.go rename to process/graph_test.go index 7598a9f70..ce13411e5 100644 --- a/workflow/graph_test.go +++ b/process/graph_test.go @@ -1,4 +1,4 @@ -package workflow +package process import ( "testing" diff --git a/workflow/marshal.go b/process/marshal.go similarity index 93% rename from workflow/marshal.go rename to process/marshal.go index 39b909e94..76a4f8090 100644 --- a/workflow/marshal.go +++ b/process/marshal.go @@ -1,4 +1,4 @@ -package workflow +package process import ( "encoding/json" @@ -50,8 +50,8 @@ func (m Map) MarshalJSON() ([]byte, error) { }) } -// UnmarshalJSON unmashals a workflow -func (w *Workflow) UnmarshalJSON(b []byte) error { +// UnmarshalJSON unmashals a process +func (w *Process) UnmarshalJSON(b []byte) error { var objMap map[string]*json.RawMessage err := json.Unmarshal(b, &objMap) if err != nil { @@ -127,7 +127,7 @@ func (w *Workflow) UnmarshalJSON(b []byte) error { return nil } -func (w *Workflow) preprocessUnmashalNode(nodeInfo map[string]interface{}) (map[string]interface{}, error) { +func (w *Process) preprocessUnmashalNode(nodeInfo map[string]interface{}) (map[string]interface{}, error) { data := make(map[string]interface{}) for key, value := range nodeInfo { if key == "type" { diff --git a/workflow/marshal_test.go b/process/marshal_test.go similarity index 97% rename from workflow/marshal_test.go rename to process/marshal_test.go index 61d860e85..40941a59d 100644 --- a/workflow/marshal_test.go +++ b/process/marshal_test.go @@ -1,4 +1,4 @@ -package workflow +package process import ( "encoding/json" @@ -10,7 +10,7 @@ import ( ) func TestMarshal(t *testing.T) { - w := Workflow{ + w := Process{ Hash: hash.Int(0), Key: "test", Graph: Graph{ @@ -30,7 +30,7 @@ func TestMarshal(t *testing.T) { val, err := json.Marshal(w) assert.NoError(t, err) assert.Equal(t, "{\"Nodes\":[{\"instanceHash\":\"4uQeVj5tqViQh7yWWGStvkEG1Zmhx6uasJtWCJziofM\",\"key\":\"1\",\"taskKey\":\"1\",\"type\":\"task\"},{\"instanceHash\":\"8opHzTAnfzRpPEx21XtnrVTX28YQuCpAjcn1PczScKh\",\"key\":\"2\",\"taskKey\":\"2\",\"type\":\"result\"},{\"eventKey\":\"3\",\"instanceHash\":\"CiDwVBFgWV9E5MvXWoLgnEgn2hK7rJikbvfWavzAQz3\",\"key\":\"3\",\"type\":\"event\"},{\"key\":\"4\",\"outputs\":[{\"Key\":\"5\",\"Ref\":{\"NodeKey\":\"5\",\"Key\":\"5\"}}],\"type\":\"map\"}],\"Edges\":[{\"Src\":\"1\",\"Dst\":\"2\"}],\"Hash\":\"11111111111111111111111111111111\",\"Key\":\"test\"}", string(val)) - var w2 Workflow + var w2 Process err = json.Unmarshal(val, &w2) assert.NoError(t, err) assert.Equal(t, w2.Hash, hash.Int(0)) diff --git a/workflow/workflow.go b/process/process.go similarity index 84% rename from workflow/workflow.go rename to process/process.go index 7f37f7490..ef667bc79 100644 --- a/workflow/workflow.go +++ b/process/process.go @@ -1,4 +1,4 @@ -package workflow +package process import ( "fmt" @@ -31,8 +31,8 @@ func (f Filter) ID() string { return f.Key } -// Validate returns an error if the workflow is invalid for whatever reason -func (w *Workflow) Validate() error { +// Validate returns an error if the process is invalid for whatever reason +func (w *Process) Validate() error { if err := validator.New().Struct(w); err != nil { return err } @@ -58,8 +58,8 @@ func (w *Workflow) Validate() error { return nil } -// Trigger returns the trigger of the workflow -func (w *Workflow) Trigger() (Node, error) { +// Trigger returns the trigger of the process +func (w *Process) Trigger() (Node, error) { triggers := w.Graph.FindNodes(func(n Node) bool { _, isResult := n.(Result) _, isEvent := n.(Event) diff --git a/workflow/workflow_test.go b/process/process_test.go similarity index 90% rename from workflow/workflow_test.go rename to process/process_test.go index 1d2d53191..791fabaa7 100644 --- a/workflow/workflow_test.go +++ b/process/process_test.go @@ -1,4 +1,4 @@ -package workflow +package process import ( "testing" @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestValidateWorkflow(t *testing.T) { +func TestValidateProcess(t *testing.T) { trigger := Result{ Key: "trigger:result", @@ -34,22 +34,22 @@ func TestValidateWorkflow(t *testing.T) { } var tests = []struct { - w *Workflow + w *Process valid bool err string }{ - {w: &Workflow{ + {w: &Process{ Hash: hash.Int(1), Key: "invalid-struct", }, err: "should contain exactly one trigger"}, - {w: &Workflow{ + {w: &Process{ Graph: Graph{ Nodes: []Node{Result{InstanceHash: hash.Int(1)}}, }, Hash: hash.Int(1), Key: "missing-key", }, err: "Error:Field validation for 'TaskKey' failed on the 'required' tag"}, - {w: &Workflow{ + {w: &Process{ Hash: hash.Int(1), Key: "edge-src-missing-node", Graph: Graph{ @@ -59,7 +59,7 @@ func TestValidateWorkflow(t *testing.T) { ), }, }, err: "node \"-\" not found"}, - {w: &Workflow{ + {w: &Process{ Hash: hash.Int(1), Key: "edge-dst-missing-node", Graph: Graph{ @@ -69,7 +69,7 @@ func TestValidateWorkflow(t *testing.T) { ), }, }, err: "node \"-\" not found"}, - {w: &Workflow{ + {w: &Process{ Hash: hash.Int(1), Key: "cyclic-graph", Graph: Graph{ @@ -79,8 +79,8 @@ func TestValidateWorkflow(t *testing.T) { Edge{Src: "nodeKey2", Dst: "nodeKey1"}, ), }, - }, err: "workflow should not contain any cycles"}, - {w: &Workflow{ + }, err: "process should not contain any cycles"}, + {w: &Process{ Hash: hash.Int(1), Key: "non-connected-graph", Graph: Graph{ @@ -98,8 +98,8 @@ func TestValidateWorkflow(t *testing.T) { Edge{Src: "nodeKey3", Dst: "nodeKey4"}, ), }, - }, err: "workflow should be a connected graph"}, - {w: &Workflow{ + }, err: "process should be a connected graph"}, + {w: &Process{ Hash: hash.Int(1), Key: "multiple-parent-graph", Graph: Graph{ @@ -119,8 +119,8 @@ func TestValidateWorkflow(t *testing.T) { Edge{Src: "nodeKey3", Dst: "nodeKey4"}, ), }, - }, err: "workflow should contain nodes with one parent maximum"}, - {w: &Workflow{ + }, err: "process should contain nodes with one parent maximum"}, + {w: &Process{ Hash: hash.Int(1), Key: "multiple-parent-graph", Graph: Graph{ @@ -155,7 +155,7 @@ func TestValidateWorkflow(t *testing.T) { ), }, }, valid: true}, - {w: &Workflow{ + {w: &Process{ Hash: hash.Int(1), Key: "inputs-with-invalid-node", Graph: Graph{ @@ -167,7 +167,7 @@ func TestValidateWorkflow(t *testing.T) { }), }, }, err: "node \"invalid\" not found"}, - {w: &Workflow{ + {w: &Process{ Hash: hash.Int(1), Key: "inputs-with-valid-ref", Graph: Graph{ diff --git a/workflow/type.go b/process/type.go similarity index 95% rename from workflow/type.go rename to process/type.go index b7311de4d..0c35a7990 100644 --- a/workflow/type.go +++ b/process/type.go @@ -1,12 +1,12 @@ -package workflow +package process import ( "github.com/mesg-foundation/engine/filter" "github.com/mesg-foundation/engine/hash" ) -// Workflow describes a workflow of a service -type Workflow struct { +// Process describes a process of a service +type Process struct { Graph Hash hash.Hash `hash:"-" validate:"required"` Key string `hash:"name:1" validate:"required"` diff --git a/protobuf/api/process.pb.go b/protobuf/api/process.pb.go new file mode 100644 index 000000000..ac1bef210 --- /dev/null +++ b/protobuf/api/process.pb.go @@ -0,0 +1,546 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protobuf/api/process.proto + +package api + +import ( + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" + types "github.com/mesg-foundation/engine/protobuf/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// The request's data for the `Create` API. +type CreateProcessRequest struct { + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Nodes []*types.Process_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty"` + Edges []*types.Process_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateProcessRequest) Reset() { *m = CreateProcessRequest{} } +func (m *CreateProcessRequest) String() string { return proto.CompactTextString(m) } +func (*CreateProcessRequest) ProtoMessage() {} +func (*CreateProcessRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{0} +} + +func (m *CreateProcessRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CreateProcessRequest.Unmarshal(m, b) +} +func (m *CreateProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CreateProcessRequest.Marshal(b, m, deterministic) +} +func (m *CreateProcessRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateProcessRequest.Merge(m, src) +} +func (m *CreateProcessRequest) XXX_Size() int { + return xxx_messageInfo_CreateProcessRequest.Size(m) +} +func (m *CreateProcessRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CreateProcessRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateProcessRequest proto.InternalMessageInfo + +func (m *CreateProcessRequest) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *CreateProcessRequest) GetNodes() []*types.Process_Node { + if m != nil { + return m.Nodes + } + return nil +} + +func (m *CreateProcessRequest) GetEdges() []*types.Process_Edge { + if m != nil { + return m.Edges + } + return nil +} + +// The response's data for the `Create` API. +type CreateProcessResponse struct { + // The process's hash created. + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CreateProcessResponse) Reset() { *m = CreateProcessResponse{} } +func (m *CreateProcessResponse) String() string { return proto.CompactTextString(m) } +func (*CreateProcessResponse) ProtoMessage() {} +func (*CreateProcessResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{1} +} + +func (m *CreateProcessResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CreateProcessResponse.Unmarshal(m, b) +} +func (m *CreateProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CreateProcessResponse.Marshal(b, m, deterministic) +} +func (m *CreateProcessResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateProcessResponse.Merge(m, src) +} +func (m *CreateProcessResponse) XXX_Size() int { + return xxx_messageInfo_CreateProcessResponse.Size(m) +} +func (m *CreateProcessResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CreateProcessResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateProcessResponse proto.InternalMessageInfo + +func (m *CreateProcessResponse) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +// The request's data for the `Delete` API. +type DeleteProcessRequest struct { + // The process's hash to delete. + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteProcessRequest) Reset() { *m = DeleteProcessRequest{} } +func (m *DeleteProcessRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteProcessRequest) ProtoMessage() {} +func (*DeleteProcessRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{2} +} + +func (m *DeleteProcessRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeleteProcessRequest.Unmarshal(m, b) +} +func (m *DeleteProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeleteProcessRequest.Marshal(b, m, deterministic) +} +func (m *DeleteProcessRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteProcessRequest.Merge(m, src) +} +func (m *DeleteProcessRequest) XXX_Size() int { + return xxx_messageInfo_DeleteProcessRequest.Size(m) +} +func (m *DeleteProcessRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteProcessRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteProcessRequest proto.InternalMessageInfo + +func (m *DeleteProcessRequest) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +// The response's data for the `Delete` API, doesn't contain anything. +type DeleteProcessResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DeleteProcessResponse) Reset() { *m = DeleteProcessResponse{} } +func (m *DeleteProcessResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteProcessResponse) ProtoMessage() {} +func (*DeleteProcessResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{3} +} + +func (m *DeleteProcessResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DeleteProcessResponse.Unmarshal(m, b) +} +func (m *DeleteProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DeleteProcessResponse.Marshal(b, m, deterministic) +} +func (m *DeleteProcessResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteProcessResponse.Merge(m, src) +} +func (m *DeleteProcessResponse) XXX_Size() int { + return xxx_messageInfo_DeleteProcessResponse.Size(m) +} +func (m *DeleteProcessResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteProcessResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteProcessResponse proto.InternalMessageInfo + +// The request's data for the `Get` API. +type GetProcessRequest struct { + // The process's hash to fetch. + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetProcessRequest) Reset() { *m = GetProcessRequest{} } +func (m *GetProcessRequest) String() string { return proto.CompactTextString(m) } +func (*GetProcessRequest) ProtoMessage() {} +func (*GetProcessRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{4} +} + +func (m *GetProcessRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetProcessRequest.Unmarshal(m, b) +} +func (m *GetProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetProcessRequest.Marshal(b, m, deterministic) +} +func (m *GetProcessRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetProcessRequest.Merge(m, src) +} +func (m *GetProcessRequest) XXX_Size() int { + return xxx_messageInfo_GetProcessRequest.Size(m) +} +func (m *GetProcessRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetProcessRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetProcessRequest proto.InternalMessageInfo + +func (m *GetProcessRequest) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +// The request's data for the `List` API. +type ListProcessRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListProcessRequest) Reset() { *m = ListProcessRequest{} } +func (m *ListProcessRequest) String() string { return proto.CompactTextString(m) } +func (*ListProcessRequest) ProtoMessage() {} +func (*ListProcessRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{5} +} + +func (m *ListProcessRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListProcessRequest.Unmarshal(m, b) +} +func (m *ListProcessRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListProcessRequest.Marshal(b, m, deterministic) +} +func (m *ListProcessRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListProcessRequest.Merge(m, src) +} +func (m *ListProcessRequest) XXX_Size() int { + return xxx_messageInfo_ListProcessRequest.Size(m) +} +func (m *ListProcessRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListProcessRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListProcessRequest proto.InternalMessageInfo + +// The response's data for the `List` API. +type ListProcessResponse struct { + // List of processes that match the request's filters. + Processes []*types.Process `protobuf:"bytes,1,rep,name=processes,proto3" json:"processes,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ListProcessResponse) Reset() { *m = ListProcessResponse{} } +func (m *ListProcessResponse) String() string { return proto.CompactTextString(m) } +func (*ListProcessResponse) ProtoMessage() {} +func (*ListProcessResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e79ddb1ea8859998, []int{6} +} + +func (m *ListProcessResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ListProcessResponse.Unmarshal(m, b) +} +func (m *ListProcessResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ListProcessResponse.Marshal(b, m, deterministic) +} +func (m *ListProcessResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListProcessResponse.Merge(m, src) +} +func (m *ListProcessResponse) XXX_Size() int { + return xxx_messageInfo_ListProcessResponse.Size(m) +} +func (m *ListProcessResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListProcessResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListProcessResponse proto.InternalMessageInfo + +func (m *ListProcessResponse) GetProcesses() []*types.Process { + if m != nil { + return m.Processes + } + return nil +} + +func init() { + proto.RegisterType((*CreateProcessRequest)(nil), "api.CreateProcessRequest") + proto.RegisterType((*CreateProcessResponse)(nil), "api.CreateProcessResponse") + proto.RegisterType((*DeleteProcessRequest)(nil), "api.DeleteProcessRequest") + proto.RegisterType((*DeleteProcessResponse)(nil), "api.DeleteProcessResponse") + proto.RegisterType((*GetProcessRequest)(nil), "api.GetProcessRequest") + proto.RegisterType((*ListProcessRequest)(nil), "api.ListProcessRequest") + proto.RegisterType((*ListProcessResponse)(nil), "api.ListProcessResponse") +} + +func init() { proto.RegisterFile("protobuf/api/process.proto", fileDescriptor_e79ddb1ea8859998) } + +var fileDescriptor_e79ddb1ea8859998 = []byte{ + // 318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4e, 0x32, 0x31, + 0x14, 0x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xd9, 0x19, 0x1c, 0xcd, 0xc8, 0xfc, 0xc1, 0xa1, + 0x07, 0xf8, 0x50, 0xe8, 0x0a, 0xc9, 0xa6, 0xd0, 0xdd, 0x51, 0xfd, 0xba, 0x57, 0xd0, 0xf1, 0xc5, + 0x92, 0x4e, 0x22, 0x1b, 0xfb, 0x60, 0x37, 0xb6, 0xf8, 0x05, 0x26, 0x9f, 0x11, 0xfc, 0xf7, 0x32, + 0xde, 0x42, 0xdb, 0x35, 0x80, 0x27, 0x3c, 0x53, 0x05, 0x0f, 0x7d, 0x8e, 0x34, 0x0d, 0x5d, 0xf9, + 0x40, 0x8d, 0xd2, 0xc2, 0x65, 0xf5, 0x16, 0xa1, 0x92, 0xbc, 0x45, 0xb8, 0x93, 0x06, 0x8e, 0x21, + 0x9e, 0x91, 0xc1, 0x63, 0x0b, 0xd5, 0xfa, 0x49, 0x2b, 0x59, 0x58, 0x03, 0x6f, 0xa0, 0x59, 0xf6, + 0x80, 0x03, 0xfb, 0xa2, 0x5e, 0x54, 0x9a, 0xd4, 0x2f, 0xbe, 0xa7, 0xcd, 0xdb, 0xf6, 0xe7, 0xbb, + 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x94, 0x2b, 0x82, 0x98, 0xbd, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ProcessClient is the client API for Process service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ProcessClient interface { + // Create a Process from a Process Definition. + // It will return an unique identifier which is used to interact with the Process. + Create(ctx context.Context, in *CreateProcessRequest, opts ...grpc.CallOption) (*CreateProcessResponse, error) + // Delete a process. + // An error is returned if one or more Instances of the process are running. + Delete(ctx context.Context, in *DeleteProcessRequest, opts ...grpc.CallOption) (*DeleteProcessResponse, error) + // Get returns a process matching the criteria of the request. + Get(ctx context.Context, in *GetProcessRequest, opts ...grpc.CallOption) (*types.Process, error) + // List returns processes specified in a request. + List(ctx context.Context, in *ListProcessRequest, opts ...grpc.CallOption) (*ListProcessResponse, error) +} + +type processClient struct { + cc *grpc.ClientConn +} + +func NewProcessClient(cc *grpc.ClientConn) ProcessClient { + return &processClient{cc} +} + +func (c *processClient) Create(ctx context.Context, in *CreateProcessRequest, opts ...grpc.CallOption) (*CreateProcessResponse, error) { + out := new(CreateProcessResponse) + err := c.cc.Invoke(ctx, "/api.Process/Create", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *processClient) Delete(ctx context.Context, in *DeleteProcessRequest, opts ...grpc.CallOption) (*DeleteProcessResponse, error) { + out := new(DeleteProcessResponse) + err := c.cc.Invoke(ctx, "/api.Process/Delete", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *processClient) Get(ctx context.Context, in *GetProcessRequest, opts ...grpc.CallOption) (*types.Process, error) { + out := new(types.Process) + err := c.cc.Invoke(ctx, "/api.Process/Get", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *processClient) List(ctx context.Context, in *ListProcessRequest, opts ...grpc.CallOption) (*ListProcessResponse, error) { + out := new(ListProcessResponse) + err := c.cc.Invoke(ctx, "/api.Process/List", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ProcessServer is the server API for Process service. +type ProcessServer interface { + // Create a Process from a Process Definition. + // It will return an unique identifier which is used to interact with the Process. + Create(context.Context, *CreateProcessRequest) (*CreateProcessResponse, error) + // Delete a process. + // An error is returned if one or more Instances of the process are running. + Delete(context.Context, *DeleteProcessRequest) (*DeleteProcessResponse, error) + // Get returns a process matching the criteria of the request. + Get(context.Context, *GetProcessRequest) (*types.Process, error) + // List returns processes specified in a request. + List(context.Context, *ListProcessRequest) (*ListProcessResponse, error) +} + +// UnimplementedProcessServer can be embedded to have forward compatible implementations. +type UnimplementedProcessServer struct { +} + +func (*UnimplementedProcessServer) Create(ctx context.Context, req *CreateProcessRequest) (*CreateProcessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") +} +func (*UnimplementedProcessServer) Delete(ctx context.Context, req *DeleteProcessRequest) (*DeleteProcessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} +func (*UnimplementedProcessServer) Get(ctx context.Context, req *GetProcessRequest) (*types.Process, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (*UnimplementedProcessServer) List(ctx context.Context, req *ListProcessRequest) (*ListProcessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method List not implemented") +} + +func RegisterProcessServer(s *grpc.Server, srv ProcessServer) { + s.RegisterService(&_Process_serviceDesc, srv) +} + +func _Process_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateProcessRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProcessServer).Create(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.Process/Create", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProcessServer).Create(ctx, req.(*CreateProcessRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Process_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteProcessRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProcessServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.Process/Delete", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProcessServer).Delete(ctx, req.(*DeleteProcessRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Process_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProcessRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProcessServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.Process/Get", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProcessServer).Get(ctx, req.(*GetProcessRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Process_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListProcessRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProcessServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.Process/List", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProcessServer).List(ctx, req.(*ListProcessRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Process_serviceDesc = grpc.ServiceDesc{ + ServiceName: "api.Process", + HandlerType: (*ProcessServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Create", + Handler: _Process_Create_Handler, + }, + { + MethodName: "Delete", + Handler: _Process_Delete_Handler, + }, + { + MethodName: "Get", + Handler: _Process_Get_Handler, + }, + { + MethodName: "List", + Handler: _Process_List_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "protobuf/api/process.proto", +} diff --git a/protobuf/api/process.proto b/protobuf/api/process.proto new file mode 100644 index 000000000..244e9d228 --- /dev/null +++ b/protobuf/api/process.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; + +import "protobuf/types/process.proto"; + +package api; + +// This is the API to interact with the Processes. +// +// This API is a [gRPC](https://grpc.io/) API. +// +// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/process.proto). +service Process { + + // Create a Process from a Process Definition. + // It will return an unique identifier which is used to interact with the Process. + rpc Create (CreateProcessRequest) returns (CreateProcessResponse) {} + + // Delete a process. + // An error is returned if one or more Instances of the process are running. + rpc Delete (DeleteProcessRequest) returns (DeleteProcessResponse) {} + + // Get returns a process matching the criteria of the request. + rpc Get(GetProcessRequest) returns (types.Process) {} + + // List returns processes specified in a request. + rpc List(ListProcessRequest) returns (ListProcessResponse) {} +} + +// The request's data for the `Create` API. +message CreateProcessRequest { + string key = 2; // Process's key + repeated types.Process.Node nodes = 4; // List of nodes of the process. + repeated types.Process.Edge edges = 5; // List of edges of the process. +} + +// The response's data for the `Create` API. +message CreateProcessResponse { + // The process's hash created. + bytes hash = 1; +} + +// The request's data for the `Delete` API. +message DeleteProcessRequest { + // The process's hash to delete. + bytes hash = 1; +} + +// The response's data for the `Delete` API, doesn't contain anything. +message DeleteProcessResponse { +} + +// The request's data for the `Get` API. +message GetProcessRequest { + // The process's hash to fetch. + bytes hash = 1; +} + +// The request's data for the `List` API. +message ListProcessRequest {} + +// The response's data for the `List` API. +message ListProcessResponse { + // List of processes that match the request's filters. + repeated types.Process processes = 1; +} diff --git a/protobuf/api/workflow.pb.go b/protobuf/api/workflow.pb.go deleted file mode 100644 index f782fab77..000000000 --- a/protobuf/api/workflow.pb.go +++ /dev/null @@ -1,547 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: protobuf/api/workflow.proto - -package api - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - types "github.com/mesg-foundation/engine/protobuf/types" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// The request's data for the `Create` API. -type CreateWorkflowRequest struct { - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Nodes []*types.Workflow_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty"` - Edges []*types.Workflow_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateWorkflowRequest) Reset() { *m = CreateWorkflowRequest{} } -func (m *CreateWorkflowRequest) String() string { return proto.CompactTextString(m) } -func (*CreateWorkflowRequest) ProtoMessage() {} -func (*CreateWorkflowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{0} -} - -func (m *CreateWorkflowRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateWorkflowRequest.Unmarshal(m, b) -} -func (m *CreateWorkflowRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateWorkflowRequest.Marshal(b, m, deterministic) -} -func (m *CreateWorkflowRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateWorkflowRequest.Merge(m, src) -} -func (m *CreateWorkflowRequest) XXX_Size() int { - return xxx_messageInfo_CreateWorkflowRequest.Size(m) -} -func (m *CreateWorkflowRequest) XXX_DiscardUnknown() { - xxx_messageInfo_CreateWorkflowRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateWorkflowRequest proto.InternalMessageInfo - -func (m *CreateWorkflowRequest) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *CreateWorkflowRequest) GetNodes() []*types.Workflow_Node { - if m != nil { - return m.Nodes - } - return nil -} - -func (m *CreateWorkflowRequest) GetEdges() []*types.Workflow_Edge { - if m != nil { - return m.Edges - } - return nil -} - -// The response's data for the `Create` API. -type CreateWorkflowResponse struct { - // The workflow's hash created. - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CreateWorkflowResponse) Reset() { *m = CreateWorkflowResponse{} } -func (m *CreateWorkflowResponse) String() string { return proto.CompactTextString(m) } -func (*CreateWorkflowResponse) ProtoMessage() {} -func (*CreateWorkflowResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{1} -} - -func (m *CreateWorkflowResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_CreateWorkflowResponse.Unmarshal(m, b) -} -func (m *CreateWorkflowResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_CreateWorkflowResponse.Marshal(b, m, deterministic) -} -func (m *CreateWorkflowResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_CreateWorkflowResponse.Merge(m, src) -} -func (m *CreateWorkflowResponse) XXX_Size() int { - return xxx_messageInfo_CreateWorkflowResponse.Size(m) -} -func (m *CreateWorkflowResponse) XXX_DiscardUnknown() { - xxx_messageInfo_CreateWorkflowResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_CreateWorkflowResponse proto.InternalMessageInfo - -func (m *CreateWorkflowResponse) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -// The request's data for the `Delete` API. -type DeleteWorkflowRequest struct { - // The workflow's hash to delete. - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteWorkflowRequest) Reset() { *m = DeleteWorkflowRequest{} } -func (m *DeleteWorkflowRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteWorkflowRequest) ProtoMessage() {} -func (*DeleteWorkflowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{2} -} - -func (m *DeleteWorkflowRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteWorkflowRequest.Unmarshal(m, b) -} -func (m *DeleteWorkflowRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteWorkflowRequest.Marshal(b, m, deterministic) -} -func (m *DeleteWorkflowRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteWorkflowRequest.Merge(m, src) -} -func (m *DeleteWorkflowRequest) XXX_Size() int { - return xxx_messageInfo_DeleteWorkflowRequest.Size(m) -} -func (m *DeleteWorkflowRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteWorkflowRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteWorkflowRequest proto.InternalMessageInfo - -func (m *DeleteWorkflowRequest) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -// The response's data for the `Delete` API, doesn't contain anything. -type DeleteWorkflowResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteWorkflowResponse) Reset() { *m = DeleteWorkflowResponse{} } -func (m *DeleteWorkflowResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteWorkflowResponse) ProtoMessage() {} -func (*DeleteWorkflowResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{3} -} - -func (m *DeleteWorkflowResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteWorkflowResponse.Unmarshal(m, b) -} -func (m *DeleteWorkflowResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteWorkflowResponse.Marshal(b, m, deterministic) -} -func (m *DeleteWorkflowResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteWorkflowResponse.Merge(m, src) -} -func (m *DeleteWorkflowResponse) XXX_Size() int { - return xxx_messageInfo_DeleteWorkflowResponse.Size(m) -} -func (m *DeleteWorkflowResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteWorkflowResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteWorkflowResponse proto.InternalMessageInfo - -// The request's data for the `Get` API. -type GetWorkflowRequest struct { - // The workflow's hash to fetch. - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *GetWorkflowRequest) Reset() { *m = GetWorkflowRequest{} } -func (m *GetWorkflowRequest) String() string { return proto.CompactTextString(m) } -func (*GetWorkflowRequest) ProtoMessage() {} -func (*GetWorkflowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{4} -} - -func (m *GetWorkflowRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_GetWorkflowRequest.Unmarshal(m, b) -} -func (m *GetWorkflowRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_GetWorkflowRequest.Marshal(b, m, deterministic) -} -func (m *GetWorkflowRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetWorkflowRequest.Merge(m, src) -} -func (m *GetWorkflowRequest) XXX_Size() int { - return xxx_messageInfo_GetWorkflowRequest.Size(m) -} -func (m *GetWorkflowRequest) XXX_DiscardUnknown() { - xxx_messageInfo_GetWorkflowRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_GetWorkflowRequest proto.InternalMessageInfo - -func (m *GetWorkflowRequest) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -// The request's data for the `List` API. -type ListWorkflowRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListWorkflowRequest) Reset() { *m = ListWorkflowRequest{} } -func (m *ListWorkflowRequest) String() string { return proto.CompactTextString(m) } -func (*ListWorkflowRequest) ProtoMessage() {} -func (*ListWorkflowRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{5} -} - -func (m *ListWorkflowRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListWorkflowRequest.Unmarshal(m, b) -} -func (m *ListWorkflowRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListWorkflowRequest.Marshal(b, m, deterministic) -} -func (m *ListWorkflowRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListWorkflowRequest.Merge(m, src) -} -func (m *ListWorkflowRequest) XXX_Size() int { - return xxx_messageInfo_ListWorkflowRequest.Size(m) -} -func (m *ListWorkflowRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListWorkflowRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListWorkflowRequest proto.InternalMessageInfo - -// The response's data for the `List` API. -type ListWorkflowResponse struct { - // List of workflows that match the request's filters. - Workflows []*types.Workflow `protobuf:"bytes,1,rep,name=workflows,proto3" json:"workflows,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListWorkflowResponse) Reset() { *m = ListWorkflowResponse{} } -func (m *ListWorkflowResponse) String() string { return proto.CompactTextString(m) } -func (*ListWorkflowResponse) ProtoMessage() {} -func (*ListWorkflowResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_2568c098005b7b27, []int{6} -} - -func (m *ListWorkflowResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListWorkflowResponse.Unmarshal(m, b) -} -func (m *ListWorkflowResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListWorkflowResponse.Marshal(b, m, deterministic) -} -func (m *ListWorkflowResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListWorkflowResponse.Merge(m, src) -} -func (m *ListWorkflowResponse) XXX_Size() int { - return xxx_messageInfo_ListWorkflowResponse.Size(m) -} -func (m *ListWorkflowResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListWorkflowResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListWorkflowResponse proto.InternalMessageInfo - -func (m *ListWorkflowResponse) GetWorkflows() []*types.Workflow { - if m != nil { - return m.Workflows - } - return nil -} - -func init() { - proto.RegisterType((*CreateWorkflowRequest)(nil), "api.CreateWorkflowRequest") - proto.RegisterType((*CreateWorkflowResponse)(nil), "api.CreateWorkflowResponse") - proto.RegisterType((*DeleteWorkflowRequest)(nil), "api.DeleteWorkflowRequest") - proto.RegisterType((*DeleteWorkflowResponse)(nil), "api.DeleteWorkflowResponse") - proto.RegisterType((*GetWorkflowRequest)(nil), "api.GetWorkflowRequest") - proto.RegisterType((*ListWorkflowRequest)(nil), "api.ListWorkflowRequest") - proto.RegisterType((*ListWorkflowResponse)(nil), "api.ListWorkflowResponse") -} - -func init() { proto.RegisterFile("protobuf/api/workflow.proto", fileDescriptor_2568c098005b7b27) } - -var fileDescriptor_2568c098005b7b27 = []byte{ - // 321 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4f, 0xfa, 0x40, - 0x10, 0xc5, 0x29, 0x05, 0xf2, 0x65, 0xbe, 0x26, 0x9a, 0x11, 0x70, 0x2d, 0x31, 0x21, 0x3d, 0x35, - 0xfe, 0x28, 0x11, 0xcf, 0x9e, 0x90, 0x70, 0x31, 0x1e, 0xf6, 0xe2, 0xb9, 0xa4, 0x03, 0x34, 0x10, - 0x76, 0x65, 0x97, 0x10, 0x8e, 0x5e, 0xfc, 0xbb, 0x4d, 0xb7, 0xad, 0xc6, 0x65, 0x4d, 0xbc, 0x4d, - 0x66, 0x3e, 0xf3, 0x3a, 0xef, 0x75, 0xa1, 0x2f, 0xb7, 0x42, 0x8b, 0xd9, 0x6e, 0x3e, 0x4c, 0x64, - 0x36, 0xdc, 0x8b, 0xed, 0x6a, 0xbe, 0x16, 0xfb, 0xd8, 0x74, 0xd1, 0x4f, 0x64, 0x16, 0x5c, 0x7d, - 0x11, 0xfa, 0x20, 0x49, 0x59, 0x4c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0xa5, 0xb0, 0x86, 0x8f, - 0xd0, 0xc8, 0x03, 0x41, 0x66, 0x76, 0x1c, 0x91, 0x05, 0x97, 0x8e, 0x49, 0xf5, 0xc5, 0x59, 0xcb, - 0x3c, 0xc8, 0x87, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, 0x08, 0xa6, 0x19, 0xd3, 0x02, 0x00, - 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// WorkflowClient is the client API for Workflow service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type WorkflowClient interface { - // Create a Workflow from a Workflow Definition. - // It will return an unique identifier which is used to interact with the Workflow. - Create(ctx context.Context, in *CreateWorkflowRequest, opts ...grpc.CallOption) (*CreateWorkflowResponse, error) - // Delete a workflow. - // An error is returned if one or more Instances of the workflow are running. - Delete(ctx context.Context, in *DeleteWorkflowRequest, opts ...grpc.CallOption) (*DeleteWorkflowResponse, error) - // Get returns a workflow matching the criteria of the request. - Get(ctx context.Context, in *GetWorkflowRequest, opts ...grpc.CallOption) (*types.Workflow, error) - // List returns workflows specified in a request. - List(ctx context.Context, in *ListWorkflowRequest, opts ...grpc.CallOption) (*ListWorkflowResponse, error) -} - -type workflowClient struct { - cc *grpc.ClientConn -} - -func NewWorkflowClient(cc *grpc.ClientConn) WorkflowClient { - return &workflowClient{cc} -} - -func (c *workflowClient) Create(ctx context.Context, in *CreateWorkflowRequest, opts ...grpc.CallOption) (*CreateWorkflowResponse, error) { - out := new(CreateWorkflowResponse) - err := c.cc.Invoke(ctx, "/api.Workflow/Create", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *workflowClient) Delete(ctx context.Context, in *DeleteWorkflowRequest, opts ...grpc.CallOption) (*DeleteWorkflowResponse, error) { - out := new(DeleteWorkflowResponse) - err := c.cc.Invoke(ctx, "/api.Workflow/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *workflowClient) Get(ctx context.Context, in *GetWorkflowRequest, opts ...grpc.CallOption) (*types.Workflow, error) { - out := new(types.Workflow) - err := c.cc.Invoke(ctx, "/api.Workflow/Get", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *workflowClient) List(ctx context.Context, in *ListWorkflowRequest, opts ...grpc.CallOption) (*ListWorkflowResponse, error) { - out := new(ListWorkflowResponse) - err := c.cc.Invoke(ctx, "/api.Workflow/List", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// WorkflowServer is the server API for Workflow service. -type WorkflowServer interface { - // Create a Workflow from a Workflow Definition. - // It will return an unique identifier which is used to interact with the Workflow. - Create(context.Context, *CreateWorkflowRequest) (*CreateWorkflowResponse, error) - // Delete a workflow. - // An error is returned if one or more Instances of the workflow are running. - Delete(context.Context, *DeleteWorkflowRequest) (*DeleteWorkflowResponse, error) - // Get returns a workflow matching the criteria of the request. - Get(context.Context, *GetWorkflowRequest) (*types.Workflow, error) - // List returns workflows specified in a request. - List(context.Context, *ListWorkflowRequest) (*ListWorkflowResponse, error) -} - -// UnimplementedWorkflowServer can be embedded to have forward compatible implementations. -type UnimplementedWorkflowServer struct { -} - -func (*UnimplementedWorkflowServer) Create(ctx context.Context, req *CreateWorkflowRequest) (*CreateWorkflowResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Create not implemented") -} -func (*UnimplementedWorkflowServer) Delete(ctx context.Context, req *DeleteWorkflowRequest) (*DeleteWorkflowResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (*UnimplementedWorkflowServer) Get(ctx context.Context, req *GetWorkflowRequest) (*types.Workflow, error) { - return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") -} -func (*UnimplementedWorkflowServer) List(ctx context.Context, req *ListWorkflowRequest) (*ListWorkflowResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method List not implemented") -} - -func RegisterWorkflowServer(s *grpc.Server, srv WorkflowServer) { - s.RegisterService(&_Workflow_serviceDesc, srv) -} - -func _Workflow_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateWorkflowRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WorkflowServer).Create(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.Workflow/Create", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServer).Create(ctx, req.(*CreateWorkflowRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Workflow_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteWorkflowRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WorkflowServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.Workflow/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServer).Delete(ctx, req.(*DeleteWorkflowRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Workflow_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetWorkflowRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WorkflowServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.Workflow/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServer).Get(ctx, req.(*GetWorkflowRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Workflow_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListWorkflowRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(WorkflowServer).List(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.Workflow/List", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(WorkflowServer).List(ctx, req.(*ListWorkflowRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Workflow_serviceDesc = grpc.ServiceDesc{ - ServiceName: "api.Workflow", - HandlerType: (*WorkflowServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Create", - Handler: _Workflow_Create_Handler, - }, - { - MethodName: "Delete", - Handler: _Workflow_Delete_Handler, - }, - { - MethodName: "Get", - Handler: _Workflow_Get_Handler, - }, - { - MethodName: "List", - Handler: _Workflow_List_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "protobuf/api/workflow.proto", -} diff --git a/protobuf/api/workflow.proto b/protobuf/api/workflow.proto deleted file mode 100644 index b947f9713..000000000 --- a/protobuf/api/workflow.proto +++ /dev/null @@ -1,65 +0,0 @@ -syntax = "proto3"; - -import "protobuf/types/workflow.proto"; - -package api; - -// This is the API to interact with the Workflows. -// -// This API is a [gRPC](https://grpc.io/) API. -// -// The source file of this API is hosted on [GitHub](https://github.com/mesg-foundation/engine/blob/master/protobuf/api/workflow.proto). -service Workflow { - - // Create a Workflow from a Workflow Definition. - // It will return an unique identifier which is used to interact with the Workflow. - rpc Create (CreateWorkflowRequest) returns (CreateWorkflowResponse) {} - - // Delete a workflow. - // An error is returned if one or more Instances of the workflow are running. - rpc Delete (DeleteWorkflowRequest) returns (DeleteWorkflowResponse) {} - - // Get returns a workflow matching the criteria of the request. - rpc Get(GetWorkflowRequest) returns (types.Workflow) {} - - // List returns workflows specified in a request. - rpc List(ListWorkflowRequest) returns (ListWorkflowResponse) {} -} - -// The request's data for the `Create` API. -message CreateWorkflowRequest { - string key = 2; // Workflow's key - repeated types.Workflow.Node nodes = 4; // List of nodes of the workflow. - repeated types.Workflow.Edge edges = 5; // List of edges of the workflow. -} - -// The response's data for the `Create` API. -message CreateWorkflowResponse { - // The workflow's hash created. - bytes hash = 1; -} - -// The request's data for the `Delete` API. -message DeleteWorkflowRequest { - // The workflow's hash to delete. - bytes hash = 1; -} - -// The response's data for the `Delete` API, doesn't contain anything. -message DeleteWorkflowResponse { -} - -// The request's data for the `Get` API. -message GetWorkflowRequest { - // The workflow's hash to fetch. - bytes hash = 1; -} - -// The request's data for the `List` API. -message ListWorkflowRequest {} - -// The response's data for the `List` API. -message ListWorkflowResponse { - // List of workflows that match the request's filters. - repeated types.Workflow workflows = 1; -} diff --git a/protobuf/types/execution.pb.go b/protobuf/types/execution.pb.go index c86172f28..fa5b27349 100644 --- a/protobuf/types/execution.pb.go +++ b/protobuf/types/execution.pb.go @@ -85,9 +85,9 @@ type Execution struct { Error string `protobuf:"bytes,9,opt,name=error,proto3" json:"error,omitempty"` // tags are optionally associated with execution by the user. Tags []string `protobuf:"bytes,10,rep,name=tags,proto3" json:"tags,omitempty"` - // workflowHash is the unique hash of the workflow associated to this execution. - WorkflowHash []byte `protobuf:"bytes,11,opt,name=workflowHash,proto3" json:"workflowHash,omitempty"` - // step of the workflow. + // processHash is the unique hash of the process associated to this execution. + ProcessHash []byte `protobuf:"bytes,11,opt,name=processHash,proto3" json:"processHash,omitempty"` + // step of the process. StepID string `protobuf:"bytes,12,opt,name=stepID,proto3" json:"stepID,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -189,9 +189,9 @@ func (m *Execution) GetTags() []string { return nil } -func (m *Execution) GetWorkflowHash() []byte { +func (m *Execution) GetProcessHash() []byte { if m != nil { - return m.WorkflowHash + return m.ProcessHash } return nil } @@ -211,29 +211,29 @@ func init() { func init() { proto.RegisterFile("protobuf/types/execution.proto", fileDescriptor_42e00237fcad5e7f) } var fileDescriptor_42e00237fcad5e7f = []byte{ - // 383 bytes of a gzipped FileDescriptorProto + // 382 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xdd, 0x8a, 0xd3, 0x50, - 0x10, 0x36, 0xdb, 0x36, 0x31, 0xd3, 0xee, 0x12, 0x06, 0xd1, 0x83, 0x2c, 0x4b, 0x58, 0x10, 0x82, - 0x60, 0xa2, 0xf5, 0x0d, 0x5c, 0x15, 0x17, 0x11, 0x24, 0x8b, 0x37, 0xde, 0x9d, 0xa6, 0xd3, 0x34, - 0x34, 0x3d, 0x27, 0x9c, 0x1f, 0x6b, 0xdf, 0xc1, 0x87, 0x96, 0x4c, 0x1a, 0xad, 0x37, 0xde, 0xcd, - 0xf7, 0x33, 0x93, 0x7c, 0x33, 0x07, 0x6e, 0x3a, 0xa3, 0x9d, 0x5e, 0xf9, 0x4d, 0xe1, 0x8e, 0x1d, - 0xd9, 0x82, 0x7e, 0x52, 0xe5, 0x5d, 0xa3, 0x55, 0xce, 0x02, 0xce, 0x98, 0x7e, 0x7e, 0x5d, 0x6b, - 0x5d, 0xb7, 0x54, 0xfc, 0x71, 0x5b, 0x67, 0x7c, 0xe5, 0x06, 0xd3, 0xed, 0xaf, 0x09, 0xc4, 0x1f, - 0xc6, 0x46, 0x44, 0x98, 0x6e, 0xa5, 0xdd, 0x8a, 0x20, 0x0d, 0xb2, 0x45, 0xc9, 0x35, 0xde, 0x00, - 0x74, 0xd2, 0x90, 0x72, 0x9f, 0x7a, 0xe5, 0x82, 0x95, 0x33, 0x06, 0xaf, 0x21, 0xa6, 0x1f, 0xa3, - 0x3c, 0x61, 0xf9, 0x2f, 0x81, 0x2f, 0x20, 0xb4, 0x4e, 0x3a, 0x6f, 0xc5, 0x34, 0x0d, 0xb2, 0xab, - 0xe5, 0x65, 0xce, 0x7f, 0x95, 0x3f, 0x30, 0x59, 0x9e, 0x44, 0xbc, 0x85, 0x45, 0xa3, 0xac, 0x93, - 0xaa, 0x22, 0x9e, 0x33, 0xe3, 0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 0x32, 0xab, 0x90, 0xf1, - 0xdb, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xee, 0x11, 0xb1, 0xcc, 0x5f, 0x02, 0x00, 0x00, + 0x10, 0x36, 0x9b, 0x36, 0x31, 0x93, 0xee, 0x12, 0x06, 0xd1, 0x83, 0x2c, 0x4b, 0x58, 0x10, 0x82, + 0x60, 0xa2, 0xf5, 0x0d, 0x5c, 0x15, 0x17, 0x11, 0x24, 0x8b, 0x37, 0xde, 0x9d, 0xa6, 0xb3, 0x69, + 0x68, 0x7b, 0x4e, 0x38, 0x3f, 0x6a, 0x5f, 0xc1, 0xa7, 0x96, 0x4c, 0x1a, 0xad, 0x37, 0x7b, 0x37, + 0xdf, 0xcf, 0x4c, 0xf2, 0xcd, 0x1c, 0xb8, 0xea, 0x8d, 0x76, 0x7a, 0xe5, 0xef, 0x2b, 0x77, 0xe8, + 0xc9, 0x56, 0xf4, 0x8b, 0x1a, 0xef, 0x3a, 0xad, 0x4a, 0x16, 0x70, 0xce, 0xf4, 0xf3, 0xcb, 0x56, + 0xeb, 0x76, 0x47, 0xd5, 0x5f, 0xb7, 0x75, 0xc6, 0x37, 0x6e, 0x34, 0x5d, 0xff, 0x0e, 0x21, 0xf9, + 0x30, 0x35, 0x22, 0xc2, 0x6c, 0x23, 0xed, 0x46, 0x04, 0x79, 0x50, 0x2c, 0x6a, 0xae, 0xf1, 0x0a, + 0xa0, 0x97, 0x86, 0x94, 0xfb, 0x34, 0x28, 0x67, 0xac, 0x9c, 0x30, 0x78, 0x09, 0x09, 0xfd, 0x98, + 0xe4, 0x90, 0xe5, 0x7f, 0x04, 0xbe, 0x80, 0xc8, 0x3a, 0xe9, 0xbc, 0x15, 0xb3, 0x3c, 0x28, 0x2e, + 0x96, 0xe7, 0x25, 0xff, 0x55, 0x79, 0xc7, 0x64, 0x7d, 0x14, 0xf1, 0x1a, 0x16, 0x9d, 0xb2, 0x4e, + 0xaa, 0x86, 0x78, 0xce, 0x9c, 0x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0x97, 0x55, 0xc4, 0xf8, 0xed, + 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x45, 0x40, 0x29, 0xf3, 0x5d, 0x02, 0x00, 0x00, } diff --git a/protobuf/types/execution.proto b/protobuf/types/execution.proto index 6da4f2452..f30509fc0 100644 --- a/protobuf/types/execution.proto +++ b/protobuf/types/execution.proto @@ -57,9 +57,9 @@ message Execution { // tags are optionally associated with execution by the user. repeated string tags = 10; - // workflowHash is the unique hash of the workflow associated to this execution. - bytes workflowHash = 11; + // processHash is the unique hash of the process associated to this execution. + bytes processHash = 11; - // step of the workflow. + // step of the process. string stepID = 12; } diff --git a/protobuf/types/process.pb.go b/protobuf/types/process.pb.go new file mode 100644 index 000000000..4d3463eab --- /dev/null +++ b/protobuf/types/process.pb.go @@ -0,0 +1,775 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protobuf/types/process.proto + +package types + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + +// Type of condition available to compare the values. +type Process_Node_Filter_Condition_Predicate int32 + +const ( + Process_Node_Filter_Condition_Unknown Process_Node_Filter_Condition_Predicate = 0 + Process_Node_Filter_Condition_EQ Process_Node_Filter_Condition_Predicate = 1 +) + +var Process_Node_Filter_Condition_Predicate_name = map[int32]string{ + 0: "Unknown", + 1: "EQ", +} + +var Process_Node_Filter_Condition_Predicate_value = map[string]int32{ + "Unknown": 0, + "EQ": 1, +} + +func (x Process_Node_Filter_Condition_Predicate) String() string { + return proto.EnumName(Process_Node_Filter_Condition_Predicate_name, int32(x)) +} + +func (Process_Node_Filter_Condition_Predicate) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 4, 0, 0} +} + +// A process is a configuration to trigger a specific task when certains conditions of a trigger are valid. +type Process struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Nodes []*Process_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty"` + Edges []*Process_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process) Reset() { *m = Process{} } +func (m *Process) String() string { return proto.CompactTextString(m) } +func (*Process) ProtoMessage() {} +func (*Process) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0} +} + +func (m *Process) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process.Unmarshal(m, b) +} +func (m *Process) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process.Marshal(b, m, deterministic) +} +func (m *Process) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process.Merge(m, src) +} +func (m *Process) XXX_Size() int { + return xxx_messageInfo_Process.Size(m) +} +func (m *Process) XXX_DiscardUnknown() { + xxx_messageInfo_Process.DiscardUnknown(m) +} + +var xxx_messageInfo_Process proto.InternalMessageInfo + +func (m *Process) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *Process) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process) GetNodes() []*Process_Node { + if m != nil { + return m.Nodes + } + return nil +} + +func (m *Process) GetEdges() []*Process_Edge { + if m != nil { + return m.Edges + } + return nil +} + +// Node of the process +type Process_Node struct { + // Types that are valid to be assigned to Type: + // *Process_Node_Result_ + // *Process_Node_Event_ + // *Process_Node_Task_ + // *Process_Node_Map_ + // *Process_Node_Filter_ + Type isProcess_Node_Type `protobuf_oneof:"type"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node) Reset() { *m = Process_Node{} } +func (m *Process_Node) String() string { return proto.CompactTextString(m) } +func (*Process_Node) ProtoMessage() {} +func (*Process_Node) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0} +} + +func (m *Process_Node) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node.Unmarshal(m, b) +} +func (m *Process_Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node.Marshal(b, m, deterministic) +} +func (m *Process_Node) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node.Merge(m, src) +} +func (m *Process_Node) XXX_Size() int { + return xxx_messageInfo_Process_Node.Size(m) +} +func (m *Process_Node) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node proto.InternalMessageInfo + +type isProcess_Node_Type interface { + isProcess_Node_Type() +} + +type Process_Node_Result_ struct { + Result *Process_Node_Result `protobuf:"bytes,1,opt,name=result,proto3,oneof"` +} + +type Process_Node_Event_ struct { + Event *Process_Node_Event `protobuf:"bytes,2,opt,name=event,proto3,oneof"` +} + +type Process_Node_Task_ struct { + Task *Process_Node_Task `protobuf:"bytes,3,opt,name=task,proto3,oneof"` +} + +type Process_Node_Map_ struct { + Map *Process_Node_Map `protobuf:"bytes,4,opt,name=map,proto3,oneof"` +} + +type Process_Node_Filter_ struct { + Filter *Process_Node_Filter `protobuf:"bytes,5,opt,name=filter,proto3,oneof"` +} + +func (*Process_Node_Result_) isProcess_Node_Type() {} + +func (*Process_Node_Event_) isProcess_Node_Type() {} + +func (*Process_Node_Task_) isProcess_Node_Type() {} + +func (*Process_Node_Map_) isProcess_Node_Type() {} + +func (*Process_Node_Filter_) isProcess_Node_Type() {} + +func (m *Process_Node) GetType() isProcess_Node_Type { + if m != nil { + return m.Type + } + return nil +} + +func (m *Process_Node) GetResult() *Process_Node_Result { + if x, ok := m.GetType().(*Process_Node_Result_); ok { + return x.Result + } + return nil +} + +func (m *Process_Node) GetEvent() *Process_Node_Event { + if x, ok := m.GetType().(*Process_Node_Event_); ok { + return x.Event + } + return nil +} + +func (m *Process_Node) GetTask() *Process_Node_Task { + if x, ok := m.GetType().(*Process_Node_Task_); ok { + return x.Task + } + return nil +} + +func (m *Process_Node) GetMap() *Process_Node_Map { + if x, ok := m.GetType().(*Process_Node_Map_); ok { + return x.Map + } + return nil +} + +func (m *Process_Node) GetFilter() *Process_Node_Filter { + if x, ok := m.GetType().(*Process_Node_Filter_); ok { + return x.Filter + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Process_Node) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Process_Node_Result_)(nil), + (*Process_Node_Event_)(nil), + (*Process_Node_Task_)(nil), + (*Process_Node_Map_)(nil), + (*Process_Node_Filter_)(nil), + } +} + +type Process_Node_Result struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + InstanceHash []byte `protobuf:"bytes,2,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` + TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Result) Reset() { *m = Process_Node_Result{} } +func (m *Process_Node_Result) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Result) ProtoMessage() {} +func (*Process_Node_Result) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 0} +} + +func (m *Process_Node_Result) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Result.Unmarshal(m, b) +} +func (m *Process_Node_Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Result.Marshal(b, m, deterministic) +} +func (m *Process_Node_Result) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Result.Merge(m, src) +} +func (m *Process_Node_Result) XXX_Size() int { + return xxx_messageInfo_Process_Node_Result.Size(m) +} +func (m *Process_Node_Result) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Result.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Result proto.InternalMessageInfo + +func (m *Process_Node_Result) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process_Node_Result) GetInstanceHash() []byte { + if m != nil { + return m.InstanceHash + } + return nil +} + +func (m *Process_Node_Result) GetTaskKey() string { + if m != nil { + return m.TaskKey + } + return "" +} + +type Process_Node_Event struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + InstanceHash []byte `protobuf:"bytes,2,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` + EventKey string `protobuf:"bytes,3,opt,name=eventKey,proto3" json:"eventKey,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Event) Reset() { *m = Process_Node_Event{} } +func (m *Process_Node_Event) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Event) ProtoMessage() {} +func (*Process_Node_Event) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 1} +} + +func (m *Process_Node_Event) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Event.Unmarshal(m, b) +} +func (m *Process_Node_Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Event.Marshal(b, m, deterministic) +} +func (m *Process_Node_Event) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Event.Merge(m, src) +} +func (m *Process_Node_Event) XXX_Size() int { + return xxx_messageInfo_Process_Node_Event.Size(m) +} +func (m *Process_Node_Event) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Event.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Event proto.InternalMessageInfo + +func (m *Process_Node_Event) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process_Node_Event) GetInstanceHash() []byte { + if m != nil { + return m.InstanceHash + } + return nil +} + +func (m *Process_Node_Event) GetEventKey() string { + if m != nil { + return m.EventKey + } + return "" +} + +type Process_Node_Task struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + InstanceHash []byte `protobuf:"bytes,2,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` + TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Task) Reset() { *m = Process_Node_Task{} } +func (m *Process_Node_Task) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Task) ProtoMessage() {} +func (*Process_Node_Task) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 2} +} + +func (m *Process_Node_Task) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Task.Unmarshal(m, b) +} +func (m *Process_Node_Task) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Task.Marshal(b, m, deterministic) +} +func (m *Process_Node_Task) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Task.Merge(m, src) +} +func (m *Process_Node_Task) XXX_Size() int { + return xxx_messageInfo_Process_Node_Task.Size(m) +} +func (m *Process_Node_Task) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Task.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Task proto.InternalMessageInfo + +func (m *Process_Node_Task) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process_Node_Task) GetInstanceHash() []byte { + if m != nil { + return m.InstanceHash + } + return nil +} + +func (m *Process_Node_Task) GetTaskKey() string { + if m != nil { + return m.TaskKey + } + return "" +} + +type Process_Node_Map struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Outputs []*Process_Node_Map_Output `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Map) Reset() { *m = Process_Node_Map{} } +func (m *Process_Node_Map) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Map) ProtoMessage() {} +func (*Process_Node_Map) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 3} +} + +func (m *Process_Node_Map) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Map.Unmarshal(m, b) +} +func (m *Process_Node_Map) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Map.Marshal(b, m, deterministic) +} +func (m *Process_Node_Map) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Map.Merge(m, src) +} +func (m *Process_Node_Map) XXX_Size() int { + return xxx_messageInfo_Process_Node_Map.Size(m) +} +func (m *Process_Node_Map) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Map.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Map proto.InternalMessageInfo + +func (m *Process_Node_Map) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process_Node_Map) GetOutputs() []*Process_Node_Map_Output { + if m != nil { + return m.Outputs + } + return nil +} + +type Process_Node_Map_Output struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + // Types that are valid to be assigned to Value: + // *Process_Node_Map_Output_Ref + Value isProcess_Node_Map_Output_Value `protobuf_oneof:"value"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Map_Output) Reset() { *m = Process_Node_Map_Output{} } +func (m *Process_Node_Map_Output) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Map_Output) ProtoMessage() {} +func (*Process_Node_Map_Output) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 3, 0} +} + +func (m *Process_Node_Map_Output) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Map_Output.Unmarshal(m, b) +} +func (m *Process_Node_Map_Output) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Map_Output.Marshal(b, m, deterministic) +} +func (m *Process_Node_Map_Output) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Map_Output.Merge(m, src) +} +func (m *Process_Node_Map_Output) XXX_Size() int { + return xxx_messageInfo_Process_Node_Map_Output.Size(m) +} +func (m *Process_Node_Map_Output) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Map_Output.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Map_Output proto.InternalMessageInfo + +func (m *Process_Node_Map_Output) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +type isProcess_Node_Map_Output_Value interface { + isProcess_Node_Map_Output_Value() +} + +type Process_Node_Map_Output_Ref struct { + Ref *Process_Node_Map_Output_Reference `protobuf:"bytes,2,opt,name=ref,proto3,oneof"` +} + +func (*Process_Node_Map_Output_Ref) isProcess_Node_Map_Output_Value() {} + +func (m *Process_Node_Map_Output) GetValue() isProcess_Node_Map_Output_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *Process_Node_Map_Output) GetRef() *Process_Node_Map_Output_Reference { + if x, ok := m.GetValue().(*Process_Node_Map_Output_Ref); ok { + return x.Ref + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*Process_Node_Map_Output) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*Process_Node_Map_Output_Ref)(nil), + } +} + +type Process_Node_Map_Output_Reference struct { + NodeKey string `protobuf:"bytes,1,opt,name=nodeKey,proto3" json:"nodeKey,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Map_Output_Reference) Reset() { *m = Process_Node_Map_Output_Reference{} } +func (m *Process_Node_Map_Output_Reference) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Map_Output_Reference) ProtoMessage() {} +func (*Process_Node_Map_Output_Reference) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 3, 0, 0} +} + +func (m *Process_Node_Map_Output_Reference) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Map_Output_Reference.Unmarshal(m, b) +} +func (m *Process_Node_Map_Output_Reference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Map_Output_Reference.Marshal(b, m, deterministic) +} +func (m *Process_Node_Map_Output_Reference) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Map_Output_Reference.Merge(m, src) +} +func (m *Process_Node_Map_Output_Reference) XXX_Size() int { + return xxx_messageInfo_Process_Node_Map_Output_Reference.Size(m) +} +func (m *Process_Node_Map_Output_Reference) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Map_Output_Reference.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Map_Output_Reference proto.InternalMessageInfo + +func (m *Process_Node_Map_Output_Reference) GetNodeKey() string { + if m != nil { + return m.NodeKey + } + return "" +} + +func (m *Process_Node_Map_Output_Reference) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +type Process_Node_Filter struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Conditions []*Process_Node_Filter_Condition `protobuf:"bytes,2,rep,name=conditions,proto3" json:"conditions,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Filter) Reset() { *m = Process_Node_Filter{} } +func (m *Process_Node_Filter) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Filter) ProtoMessage() {} +func (*Process_Node_Filter) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 4} +} + +func (m *Process_Node_Filter) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Filter.Unmarshal(m, b) +} +func (m *Process_Node_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Filter.Marshal(b, m, deterministic) +} +func (m *Process_Node_Filter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Filter.Merge(m, src) +} +func (m *Process_Node_Filter) XXX_Size() int { + return xxx_messageInfo_Process_Node_Filter.Size(m) +} +func (m *Process_Node_Filter) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Filter.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Filter proto.InternalMessageInfo + +func (m *Process_Node_Filter) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process_Node_Filter) GetConditions() []*Process_Node_Filter_Condition { + if m != nil { + return m.Conditions + } + return nil +} + +type Process_Node_Filter_Condition struct { + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Predicate Process_Node_Filter_Condition_Predicate `protobuf:"varint,2,opt,name=predicate,proto3,enum=types.Process_Node_Filter_Condition_Predicate" json:"predicate,omitempty"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Node_Filter_Condition) Reset() { *m = Process_Node_Filter_Condition{} } +func (m *Process_Node_Filter_Condition) String() string { return proto.CompactTextString(m) } +func (*Process_Node_Filter_Condition) ProtoMessage() {} +func (*Process_Node_Filter_Condition) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 0, 4, 0} +} + +func (m *Process_Node_Filter_Condition) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Node_Filter_Condition.Unmarshal(m, b) +} +func (m *Process_Node_Filter_Condition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Node_Filter_Condition.Marshal(b, m, deterministic) +} +func (m *Process_Node_Filter_Condition) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Node_Filter_Condition.Merge(m, src) +} +func (m *Process_Node_Filter_Condition) XXX_Size() int { + return xxx_messageInfo_Process_Node_Filter_Condition.Size(m) +} +func (m *Process_Node_Filter_Condition) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Node_Filter_Condition.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Node_Filter_Condition proto.InternalMessageInfo + +func (m *Process_Node_Filter_Condition) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *Process_Node_Filter_Condition) GetPredicate() Process_Node_Filter_Condition_Predicate { + if m != nil { + return m.Predicate + } + return Process_Node_Filter_Condition_Unknown +} + +func (m *Process_Node_Filter_Condition) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +type Process_Edge struct { + Src string `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"` + Dst string `protobuf:"bytes,2,opt,name=dst,proto3" json:"dst,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Process_Edge) Reset() { *m = Process_Edge{} } +func (m *Process_Edge) String() string { return proto.CompactTextString(m) } +func (*Process_Edge) ProtoMessage() {} +func (*Process_Edge) Descriptor() ([]byte, []int) { + return fileDescriptor_008a801f5f6ff4ac, []int{0, 1} +} + +func (m *Process_Edge) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Process_Edge.Unmarshal(m, b) +} +func (m *Process_Edge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Process_Edge.Marshal(b, m, deterministic) +} +func (m *Process_Edge) XXX_Merge(src proto.Message) { + xxx_messageInfo_Process_Edge.Merge(m, src) +} +func (m *Process_Edge) XXX_Size() int { + return xxx_messageInfo_Process_Edge.Size(m) +} +func (m *Process_Edge) XXX_DiscardUnknown() { + xxx_messageInfo_Process_Edge.DiscardUnknown(m) +} + +var xxx_messageInfo_Process_Edge proto.InternalMessageInfo + +func (m *Process_Edge) GetSrc() string { + if m != nil { + return m.Src + } + return "" +} + +func (m *Process_Edge) GetDst() string { + if m != nil { + return m.Dst + } + return "" +} + +func init() { + proto.RegisterEnum("types.Process_Node_Filter_Condition_Predicate", Process_Node_Filter_Condition_Predicate_name, Process_Node_Filter_Condition_Predicate_value) + proto.RegisterType((*Process)(nil), "types.Process") + proto.RegisterType((*Process_Node)(nil), "types.Process.Node") + proto.RegisterType((*Process_Node_Result)(nil), "types.Process.Node.Result") + proto.RegisterType((*Process_Node_Event)(nil), "types.Process.Node.Event") + proto.RegisterType((*Process_Node_Task)(nil), "types.Process.Node.Task") + proto.RegisterType((*Process_Node_Map)(nil), "types.Process.Node.Map") + proto.RegisterType((*Process_Node_Map_Output)(nil), "types.Process.Node.Map.Output") + proto.RegisterType((*Process_Node_Map_Output_Reference)(nil), "types.Process.Node.Map.Output.Reference") + proto.RegisterType((*Process_Node_Filter)(nil), "types.Process.Node.Filter") + proto.RegisterType((*Process_Node_Filter_Condition)(nil), "types.Process.Node.Filter.Condition") + proto.RegisterType((*Process_Edge)(nil), "types.Process.Edge") +} + +func init() { proto.RegisterFile("protobuf/types/process.proto", fileDescriptor_008a801f5f6ff4ac) } + +var fileDescriptor_008a801f5f6ff4ac = []byte{ + // 573 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x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bf, 0xf8, 0x43, 0x9c, 0xf8, 0x66, 0xfd, 0xe0, 0x67, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xdd, 0x2b, 0x59, 0x29, 0x05, 0x00, 0x00, +} diff --git a/protobuf/types/workflow.proto b/protobuf/types/process.proto similarity index 89% rename from protobuf/types/workflow.proto rename to protobuf/types/process.proto index 994ea706e..b9d111260 100644 --- a/protobuf/types/workflow.proto +++ b/protobuf/types/process.proto @@ -3,20 +3,20 @@ syntax = "proto3"; package types; option go_package = "github.com/mesg-foundation/engine/protobuf/types"; -// A workflow is a configuration to trigger a specific task when certains conditions of a trigger are valid. -message Workflow { - // Node of the workflow +// A process is a configuration to trigger a specific task when certains conditions of a trigger are valid. +message Process { + // Node of the process message Node { message Result { string key = 1; // Key that identifies the node. - bytes instanceHash = 2; // Hash of the instance that triggers the workflow. - string taskKey = 3; // Key of the task that triggers the workflow. + bytes instanceHash = 2; // Hash of the instance that triggers the process. + string taskKey = 3; // Key of the task that triggers the process. } message Event { string key = 1; // Key that identifies the node. - bytes instanceHash = 2; // Hash of the instance that triggers the workflow. - string eventKey = 3; // Key of the event that triggers the workflow. + bytes instanceHash = 2; // Hash of the instance that triggers the process. + string eventKey = 3; // Key of the event that triggers the process. } message Task { @@ -70,8 +70,8 @@ message Workflow { string dst = 2; // Destination of the edge. } - bytes hash = 1; // Workflow's hash - string key = 2; // Workflow's key + bytes hash = 1; // Process's hash + string key = 2; // Process's key repeated Node nodes = 4; // Nodes with information related to the execution to trigger. repeated Edge edges = 5; // Edges to create the link between the nodes. } diff --git a/protobuf/types/workflow.pb.go b/protobuf/types/workflow.pb.go deleted file mode 100644 index 79007566e..000000000 --- a/protobuf/types/workflow.pb.go +++ /dev/null @@ -1,775 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: protobuf/types/workflow.proto - -package types - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// Type of condition available to compare the values. -type Workflow_Node_Filter_Condition_Predicate int32 - -const ( - Workflow_Node_Filter_Condition_Unknown Workflow_Node_Filter_Condition_Predicate = 0 - Workflow_Node_Filter_Condition_EQ Workflow_Node_Filter_Condition_Predicate = 1 -) - -var Workflow_Node_Filter_Condition_Predicate_name = map[int32]string{ - 0: "Unknown", - 1: "EQ", -} - -var Workflow_Node_Filter_Condition_Predicate_value = map[string]int32{ - "Unknown": 0, - "EQ": 1, -} - -func (x Workflow_Node_Filter_Condition_Predicate) String() string { - return proto.EnumName(Workflow_Node_Filter_Condition_Predicate_name, int32(x)) -} - -func (Workflow_Node_Filter_Condition_Predicate) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 4, 0, 0} -} - -// A workflow is a configuration to trigger a specific task when certains conditions of a trigger are valid. -type Workflow struct { - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Nodes []*Workflow_Node `protobuf:"bytes,4,rep,name=nodes,proto3" json:"nodes,omitempty"` - Edges []*Workflow_Edge `protobuf:"bytes,5,rep,name=edges,proto3" json:"edges,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow) Reset() { *m = Workflow{} } -func (m *Workflow) String() string { return proto.CompactTextString(m) } -func (*Workflow) ProtoMessage() {} -func (*Workflow) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0} -} - -func (m *Workflow) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow.Unmarshal(m, b) -} -func (m *Workflow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow.Marshal(b, m, deterministic) -} -func (m *Workflow) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow.Merge(m, src) -} -func (m *Workflow) XXX_Size() int { - return xxx_messageInfo_Workflow.Size(m) -} -func (m *Workflow) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow proto.InternalMessageInfo - -func (m *Workflow) GetHash() []byte { - if m != nil { - return m.Hash - } - return nil -} - -func (m *Workflow) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow) GetNodes() []*Workflow_Node { - if m != nil { - return m.Nodes - } - return nil -} - -func (m *Workflow) GetEdges() []*Workflow_Edge { - if m != nil { - return m.Edges - } - return nil -} - -// Node of the workflow -type Workflow_Node struct { - // Types that are valid to be assigned to Type: - // *Workflow_Node_Result_ - // *Workflow_Node_Event_ - // *Workflow_Node_Task_ - // *Workflow_Node_Map_ - // *Workflow_Node_Filter_ - Type isWorkflow_Node_Type `protobuf_oneof:"type"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node) Reset() { *m = Workflow_Node{} } -func (m *Workflow_Node) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node) ProtoMessage() {} -func (*Workflow_Node) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0} -} - -func (m *Workflow_Node) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node.Unmarshal(m, b) -} -func (m *Workflow_Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node.Marshal(b, m, deterministic) -} -func (m *Workflow_Node) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node.Merge(m, src) -} -func (m *Workflow_Node) XXX_Size() int { - return xxx_messageInfo_Workflow_Node.Size(m) -} -func (m *Workflow_Node) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node proto.InternalMessageInfo - -type isWorkflow_Node_Type interface { - isWorkflow_Node_Type() -} - -type Workflow_Node_Result_ struct { - Result *Workflow_Node_Result `protobuf:"bytes,1,opt,name=result,proto3,oneof"` -} - -type Workflow_Node_Event_ struct { - Event *Workflow_Node_Event `protobuf:"bytes,2,opt,name=event,proto3,oneof"` -} - -type Workflow_Node_Task_ struct { - Task *Workflow_Node_Task `protobuf:"bytes,3,opt,name=task,proto3,oneof"` -} - -type Workflow_Node_Map_ struct { - Map *Workflow_Node_Map `protobuf:"bytes,4,opt,name=map,proto3,oneof"` -} - -type Workflow_Node_Filter_ struct { - Filter *Workflow_Node_Filter `protobuf:"bytes,5,opt,name=filter,proto3,oneof"` -} - -func (*Workflow_Node_Result_) isWorkflow_Node_Type() {} - -func (*Workflow_Node_Event_) isWorkflow_Node_Type() {} - -func (*Workflow_Node_Task_) isWorkflow_Node_Type() {} - -func (*Workflow_Node_Map_) isWorkflow_Node_Type() {} - -func (*Workflow_Node_Filter_) isWorkflow_Node_Type() {} - -func (m *Workflow_Node) GetType() isWorkflow_Node_Type { - if m != nil { - return m.Type - } - return nil -} - -func (m *Workflow_Node) GetResult() *Workflow_Node_Result { - if x, ok := m.GetType().(*Workflow_Node_Result_); ok { - return x.Result - } - return nil -} - -func (m *Workflow_Node) GetEvent() *Workflow_Node_Event { - if x, ok := m.GetType().(*Workflow_Node_Event_); ok { - return x.Event - } - return nil -} - -func (m *Workflow_Node) GetTask() *Workflow_Node_Task { - if x, ok := m.GetType().(*Workflow_Node_Task_); ok { - return x.Task - } - return nil -} - -func (m *Workflow_Node) GetMap() *Workflow_Node_Map { - if x, ok := m.GetType().(*Workflow_Node_Map_); ok { - return x.Map - } - return nil -} - -func (m *Workflow_Node) GetFilter() *Workflow_Node_Filter { - if x, ok := m.GetType().(*Workflow_Node_Filter_); ok { - return x.Filter - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Workflow_Node) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Workflow_Node_Result_)(nil), - (*Workflow_Node_Event_)(nil), - (*Workflow_Node_Task_)(nil), - (*Workflow_Node_Map_)(nil), - (*Workflow_Node_Filter_)(nil), - } -} - -type Workflow_Node_Result struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - InstanceHash []byte `protobuf:"bytes,2,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` - TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Result) Reset() { *m = Workflow_Node_Result{} } -func (m *Workflow_Node_Result) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Result) ProtoMessage() {} -func (*Workflow_Node_Result) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 0} -} - -func (m *Workflow_Node_Result) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Result.Unmarshal(m, b) -} -func (m *Workflow_Node_Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Result.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Result) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Result.Merge(m, src) -} -func (m *Workflow_Node_Result) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Result.Size(m) -} -func (m *Workflow_Node_Result) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Result.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Result proto.InternalMessageInfo - -func (m *Workflow_Node_Result) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow_Node_Result) GetInstanceHash() []byte { - if m != nil { - return m.InstanceHash - } - return nil -} - -func (m *Workflow_Node_Result) GetTaskKey() string { - if m != nil { - return m.TaskKey - } - return "" -} - -type Workflow_Node_Event struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - InstanceHash []byte `protobuf:"bytes,2,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` - EventKey string `protobuf:"bytes,3,opt,name=eventKey,proto3" json:"eventKey,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Event) Reset() { *m = Workflow_Node_Event{} } -func (m *Workflow_Node_Event) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Event) ProtoMessage() {} -func (*Workflow_Node_Event) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 1} -} - -func (m *Workflow_Node_Event) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Event.Unmarshal(m, b) -} -func (m *Workflow_Node_Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Event.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Event) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Event.Merge(m, src) -} -func (m *Workflow_Node_Event) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Event.Size(m) -} -func (m *Workflow_Node_Event) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Event.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Event proto.InternalMessageInfo - -func (m *Workflow_Node_Event) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow_Node_Event) GetInstanceHash() []byte { - if m != nil { - return m.InstanceHash - } - return nil -} - -func (m *Workflow_Node_Event) GetEventKey() string { - if m != nil { - return m.EventKey - } - return "" -} - -type Workflow_Node_Task struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - InstanceHash []byte `protobuf:"bytes,2,opt,name=instanceHash,proto3" json:"instanceHash,omitempty"` - TaskKey string `protobuf:"bytes,3,opt,name=taskKey,proto3" json:"taskKey,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Task) Reset() { *m = Workflow_Node_Task{} } -func (m *Workflow_Node_Task) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Task) ProtoMessage() {} -func (*Workflow_Node_Task) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 2} -} - -func (m *Workflow_Node_Task) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Task.Unmarshal(m, b) -} -func (m *Workflow_Node_Task) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Task.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Task) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Task.Merge(m, src) -} -func (m *Workflow_Node_Task) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Task.Size(m) -} -func (m *Workflow_Node_Task) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Task.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Task proto.InternalMessageInfo - -func (m *Workflow_Node_Task) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow_Node_Task) GetInstanceHash() []byte { - if m != nil { - return m.InstanceHash - } - return nil -} - -func (m *Workflow_Node_Task) GetTaskKey() string { - if m != nil { - return m.TaskKey - } - return "" -} - -type Workflow_Node_Map struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Outputs []*Workflow_Node_Map_Output `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Map) Reset() { *m = Workflow_Node_Map{} } -func (m *Workflow_Node_Map) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Map) ProtoMessage() {} -func (*Workflow_Node_Map) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 3} -} - -func (m *Workflow_Node_Map) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Map.Unmarshal(m, b) -} -func (m *Workflow_Node_Map) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Map.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Map) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Map.Merge(m, src) -} -func (m *Workflow_Node_Map) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Map.Size(m) -} -func (m *Workflow_Node_Map) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Map.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Map proto.InternalMessageInfo - -func (m *Workflow_Node_Map) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow_Node_Map) GetOutputs() []*Workflow_Node_Map_Output { - if m != nil { - return m.Outputs - } - return nil -} - -type Workflow_Node_Map_Output struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // Types that are valid to be assigned to Value: - // *Workflow_Node_Map_Output_Ref - Value isWorkflow_Node_Map_Output_Value `protobuf_oneof:"value"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Map_Output) Reset() { *m = Workflow_Node_Map_Output{} } -func (m *Workflow_Node_Map_Output) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Map_Output) ProtoMessage() {} -func (*Workflow_Node_Map_Output) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 3, 0} -} - -func (m *Workflow_Node_Map_Output) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Map_Output.Unmarshal(m, b) -} -func (m *Workflow_Node_Map_Output) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Map_Output.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Map_Output) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Map_Output.Merge(m, src) -} -func (m *Workflow_Node_Map_Output) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Map_Output.Size(m) -} -func (m *Workflow_Node_Map_Output) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Map_Output.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Map_Output proto.InternalMessageInfo - -func (m *Workflow_Node_Map_Output) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -type isWorkflow_Node_Map_Output_Value interface { - isWorkflow_Node_Map_Output_Value() -} - -type Workflow_Node_Map_Output_Ref struct { - Ref *Workflow_Node_Map_Output_Reference `protobuf:"bytes,2,opt,name=ref,proto3,oneof"` -} - -func (*Workflow_Node_Map_Output_Ref) isWorkflow_Node_Map_Output_Value() {} - -func (m *Workflow_Node_Map_Output) GetValue() isWorkflow_Node_Map_Output_Value { - if m != nil { - return m.Value - } - return nil -} - -func (m *Workflow_Node_Map_Output) GetRef() *Workflow_Node_Map_Output_Reference { - if x, ok := m.GetValue().(*Workflow_Node_Map_Output_Ref); ok { - return x.Ref - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Workflow_Node_Map_Output) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Workflow_Node_Map_Output_Ref)(nil), - } -} - -type Workflow_Node_Map_Output_Reference struct { - NodeKey string `protobuf:"bytes,1,opt,name=nodeKey,proto3" json:"nodeKey,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Map_Output_Reference) Reset() { *m = Workflow_Node_Map_Output_Reference{} } -func (m *Workflow_Node_Map_Output_Reference) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Map_Output_Reference) ProtoMessage() {} -func (*Workflow_Node_Map_Output_Reference) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 3, 0, 0} -} - -func (m *Workflow_Node_Map_Output_Reference) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Map_Output_Reference.Unmarshal(m, b) -} -func (m *Workflow_Node_Map_Output_Reference) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Map_Output_Reference.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Map_Output_Reference) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Map_Output_Reference.Merge(m, src) -} -func (m *Workflow_Node_Map_Output_Reference) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Map_Output_Reference.Size(m) -} -func (m *Workflow_Node_Map_Output_Reference) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Map_Output_Reference.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Map_Output_Reference proto.InternalMessageInfo - -func (m *Workflow_Node_Map_Output_Reference) GetNodeKey() string { - if m != nil { - return m.NodeKey - } - return "" -} - -func (m *Workflow_Node_Map_Output_Reference) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -type Workflow_Node_Filter struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Conditions []*Workflow_Node_Filter_Condition `protobuf:"bytes,2,rep,name=conditions,proto3" json:"conditions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Filter) Reset() { *m = Workflow_Node_Filter{} } -func (m *Workflow_Node_Filter) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Filter) ProtoMessage() {} -func (*Workflow_Node_Filter) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 4} -} - -func (m *Workflow_Node_Filter) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Filter.Unmarshal(m, b) -} -func (m *Workflow_Node_Filter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Filter.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Filter) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Filter.Merge(m, src) -} -func (m *Workflow_Node_Filter) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Filter.Size(m) -} -func (m *Workflow_Node_Filter) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Filter.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Filter proto.InternalMessageInfo - -func (m *Workflow_Node_Filter) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow_Node_Filter) GetConditions() []*Workflow_Node_Filter_Condition { - if m != nil { - return m.Conditions - } - return nil -} - -type Workflow_Node_Filter_Condition struct { - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Predicate Workflow_Node_Filter_Condition_Predicate `protobuf:"varint,2,opt,name=predicate,proto3,enum=types.Workflow_Node_Filter_Condition_Predicate" json:"predicate,omitempty"` - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Node_Filter_Condition) Reset() { *m = Workflow_Node_Filter_Condition{} } -func (m *Workflow_Node_Filter_Condition) String() string { return proto.CompactTextString(m) } -func (*Workflow_Node_Filter_Condition) ProtoMessage() {} -func (*Workflow_Node_Filter_Condition) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 0, 4, 0} -} - -func (m *Workflow_Node_Filter_Condition) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Node_Filter_Condition.Unmarshal(m, b) -} -func (m *Workflow_Node_Filter_Condition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Node_Filter_Condition.Marshal(b, m, deterministic) -} -func (m *Workflow_Node_Filter_Condition) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Node_Filter_Condition.Merge(m, src) -} -func (m *Workflow_Node_Filter_Condition) XXX_Size() int { - return xxx_messageInfo_Workflow_Node_Filter_Condition.Size(m) -} -func (m *Workflow_Node_Filter_Condition) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Node_Filter_Condition.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Node_Filter_Condition proto.InternalMessageInfo - -func (m *Workflow_Node_Filter_Condition) GetKey() string { - if m != nil { - return m.Key - } - return "" -} - -func (m *Workflow_Node_Filter_Condition) GetPredicate() Workflow_Node_Filter_Condition_Predicate { - if m != nil { - return m.Predicate - } - return Workflow_Node_Filter_Condition_Unknown -} - -func (m *Workflow_Node_Filter_Condition) GetValue() string { - if m != nil { - return m.Value - } - return "" -} - -type Workflow_Edge struct { - Src string `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"` - Dst string `protobuf:"bytes,2,opt,name=dst,proto3" json:"dst,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Workflow_Edge) Reset() { *m = Workflow_Edge{} } -func (m *Workflow_Edge) String() string { return proto.CompactTextString(m) } -func (*Workflow_Edge) ProtoMessage() {} -func (*Workflow_Edge) Descriptor() ([]byte, []int) { - return fileDescriptor_980f671c228050a1, []int{0, 1} -} - -func (m *Workflow_Edge) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Workflow_Edge.Unmarshal(m, b) -} -func (m *Workflow_Edge) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Workflow_Edge.Marshal(b, m, deterministic) -} -func (m *Workflow_Edge) XXX_Merge(src proto.Message) { - xxx_messageInfo_Workflow_Edge.Merge(m, src) -} -func (m *Workflow_Edge) XXX_Size() int { - return xxx_messageInfo_Workflow_Edge.Size(m) -} -func (m *Workflow_Edge) XXX_DiscardUnknown() { - xxx_messageInfo_Workflow_Edge.DiscardUnknown(m) -} - -var xxx_messageInfo_Workflow_Edge proto.InternalMessageInfo - -func (m *Workflow_Edge) GetSrc() string { - if m != nil { - return m.Src - } - return "" -} - -func (m *Workflow_Edge) GetDst() string { - if m != nil { - return m.Dst - } - return "" -} - -func init() { - proto.RegisterEnum("types.Workflow_Node_Filter_Condition_Predicate", Workflow_Node_Filter_Condition_Predicate_name, Workflow_Node_Filter_Condition_Predicate_value) - proto.RegisterType((*Workflow)(nil), "types.Workflow") - proto.RegisterType((*Workflow_Node)(nil), "types.Workflow.Node") - proto.RegisterType((*Workflow_Node_Result)(nil), "types.Workflow.Node.Result") - proto.RegisterType((*Workflow_Node_Event)(nil), "types.Workflow.Node.Event") - proto.RegisterType((*Workflow_Node_Task)(nil), "types.Workflow.Node.Task") - proto.RegisterType((*Workflow_Node_Map)(nil), "types.Workflow.Node.Map") - proto.RegisterType((*Workflow_Node_Map_Output)(nil), "types.Workflow.Node.Map.Output") - proto.RegisterType((*Workflow_Node_Map_Output_Reference)(nil), "types.Workflow.Node.Map.Output.Reference") - proto.RegisterType((*Workflow_Node_Filter)(nil), "types.Workflow.Node.Filter") - proto.RegisterType((*Workflow_Node_Filter_Condition)(nil), "types.Workflow.Node.Filter.Condition") - proto.RegisterType((*Workflow_Edge)(nil), "types.Workflow.Edge") -} - -func init() { proto.RegisterFile("protobuf/types/workflow.proto", fileDescriptor_980f671c228050a1) } - -var fileDescriptor_980f671c228050a1 = []byte{ - // 575 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xdd, 0x8a, 0xd3, 0x40, - 0x14, 0xc7, 0x93, 0xe6, 0xa3, 0x9b, 0xd3, 0x45, 0x96, 0x61, 0x2f, 0x62, 0x44, 0x2c, 0x0b, 0xc2, - 0xba, 0x68, 0x22, 0x11, 0x11, 0x2f, 0xbc, 0x59, 0xa9, 0x14, 0x96, 0xf5, 0x63, 0xf0, 0xfb, 0x2e, - 0x4d, 0x4e, 0xda, 0xd0, 0x76, 0x26, 0x64, 0x26, 0x5b, 0xfa, 0x06, 0x3e, 0x83, 0xde, 0xfa, 0x42, - 0xbe, 0x89, 0x8f, 0x20, 0x33, 0x69, 0x5a, 0x17, 0xe3, 0x2a, 0xe2, 0x5d, 0xce, 0xc9, 0xef, 0x9c, - 0xf3, 0xff, 0x9f, 0x99, 0x04, 0x6e, 0x96, 0x15, 0x97, 0x7c, 0x52, 0xe7, 0x91, 0x5c, 0x97, 0x28, - 0xa2, 0x15, 0xaf, 0xe6, 0xf9, 0x82, 0xaf, 0x42, 0x9d, 0x27, 0x8e, 0xce, 0x1e, 0x7d, 0xf3, 0x60, - 0xef, 0xdd, 0xe6, 0x0d, 0x21, 0x60, 0xcf, 0x12, 0x31, 0xf3, 0xcd, 0xa1, 0x79, 0xbc, 0x4f, 0xf5, - 0x33, 0x39, 0x00, 0x6b, 0x8e, 0x6b, 0xbf, 0x37, 0x34, 0x8f, 0x3d, 0xaa, 0x1e, 0xc9, 0x09, 0x38, - 0x8c, 0x67, 0x28, 0x7c, 0x7b, 0x68, 0x1d, 0x0f, 0xe2, 0xc3, 0x50, 0x77, 0x0a, 0xdb, 0x2e, 0xe1, - 0x73, 0x9e, 0x21, 0x6d, 0x10, 0xc5, 0x62, 0x36, 0x45, 0xe1, 0x3b, 0xdd, 0xec, 0x28, 0x9b, 0x22, - 0x6d, 0x90, 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0xde, 0xcb, 0x79, - 0xcd, 0xb2, 0x44, 0xc9, 0x8b, 0x90, 0x4d, 0x0b, 0x86, 0xd1, 0xe5, 0xbf, 0xe3, 0xc4, 0xd5, 0xf1, - 0x83, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x3b, 0xdc, 0x61, 0x43, 0x36, 0x05, 0x00, 0x00, -} diff --git a/scripts/build-proto.sh b/scripts/build-proto.sh index ad5b6ab53..45f2aeb76 100755 --- a/scripts/build-proto.sh +++ b/scripts/build-proto.sh @@ -10,7 +10,7 @@ GRPC_PLUGIN="--go_out=plugins=grpc,paths=source_relative:." protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/event.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/execution.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/instance.proto -protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/workflow.proto +protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/types/process.proto protoc --gogofaster_out=plugins=grpc,paths=source_relative:./service/ \ --proto_path=/project/protobuf/types \ @@ -20,6 +20,6 @@ protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/api/event.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/api/execution.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/api/instance.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/api/service.proto -protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/api/workflow.proto +protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/api/process.proto protoc $GRPC_PLUGIN --proto_path=$PROJECT $GRPC/coreapi/api.proto diff --git a/sdk/execution/execution.go b/sdk/execution/execution.go index a69b80493..e5d609704 100644 --- a/sdk/execution/execution.go +++ b/sdk/execution/execution.go @@ -8,8 +8,8 @@ import ( "github.com/mesg-foundation/engine/execution" "github.com/mesg-foundation/engine/hash" instancesdk "github.com/mesg-foundation/engine/sdk/instance" + processesdk "github.com/mesg-foundation/engine/sdk/process" servicesdk "github.com/mesg-foundation/engine/sdk/service" - workflowsdk "github.com/mesg-foundation/engine/sdk/workflow" ) const ( @@ -23,17 +23,17 @@ type Execution struct { ps *pubsub.PubSub service servicesdk.Service instance *instancesdk.Instance - workflow *workflowsdk.Workflow + process *processesdk.Process execDB database.ExecutionDB } // New creates a new Execution SDK with given options. -func New(ps *pubsub.PubSub, service servicesdk.Service, instance *instancesdk.Instance, workflow *workflowsdk.Workflow, execDB database.ExecutionDB) *Execution { +func New(ps *pubsub.PubSub, service servicesdk.Service, instance *instancesdk.Instance, process *processesdk.Process, execDB database.ExecutionDB) *Execution { return &Execution{ ps: ps, service: service, instance: instance, - workflow: workflow, + process: process, execDB: execDB, } } @@ -121,7 +121,7 @@ func (e *Execution) validateExecutionOutput(instanceHash hash.Hash, taskKey stri } // Execute executes a task tasKey with inputData and tags for service serviceID. -func (e *Execution) Execute(workflowHash, instanceHash, eventHash, parentHash hash.Hash, stepID string, taskKey string, inputData map[string]interface{}, tags []string) (executionHash hash.Hash, err error) { +func (e *Execution) Execute(processHash, instanceHash, eventHash, parentHash hash.Hash, stepID string, taskKey string, inputData map[string]interface{}, tags []string) (executionHash hash.Hash, err error) { if parentHash != nil && eventHash != nil { return nil, fmt.Errorf("cannot have both parent and event hash") } @@ -139,8 +139,8 @@ func (e *Execution) Execute(workflowHash, instanceHash, eventHash, parentHash ha return nil, err } - if !workflowHash.IsZero() { - _, err := e.workflow.Get(workflowHash) + if !processHash.IsZero() { + _, err := e.process.Get(processHash) if err != nil { return nil, err } @@ -150,7 +150,7 @@ func (e *Execution) Execute(workflowHash, instanceHash, eventHash, parentHash ha return nil, err } - exec := execution.New(workflowHash, instance.Hash, parentHash, eventHash, stepID, taskKey, inputData, tags) + exec := execution.New(processHash, instance.Hash, parentHash, eventHash, stepID, taskKey, inputData, tags) if err := exec.Execute(); err != nil { return nil, err } diff --git a/sdk/execution/execution_test.go b/sdk/execution/execution_test.go index e2f04f566..09974e062 100644 --- a/sdk/execution/execution_test.go +++ b/sdk/execution/execution_test.go @@ -12,17 +12,17 @@ import ( "github.com/mesg-foundation/engine/hash" "github.com/mesg-foundation/engine/instance" instancesdk "github.com/mesg-foundation/engine/sdk/instance" + processesdk "github.com/mesg-foundation/engine/sdk/process" servicesdk "github.com/mesg-foundation/engine/sdk/service" - workflowsdk "github.com/mesg-foundation/engine/sdk/workflow" "github.com/mesg-foundation/engine/service" "github.com/stretchr/testify/require" ) const ( - servicedbname = "service.db.test" - instdbname = "instance.db.test" - execdbname = "exec.db.test" - workflowdbname = "workflow.db.test" + servicedbname = "service.db.test" + instdbname = "instance.db.test" + execdbname = "exec.db.test" + processdbname = "process.db.test" ) type apiTesting struct { @@ -30,18 +30,18 @@ type apiTesting struct { serviceDB *database.ServiceDB executionDB *database.LevelDBExecutionDB instanceDB *database.LevelDBInstanceDB - workflowDB *database.LevelDBWorkflowDB + processDB *database.LevelDBProcessDB } func (t *apiTesting) close() { require.NoError(t, t.serviceDB.Close()) require.NoError(t, t.executionDB.Close()) require.NoError(t, t.instanceDB.Close()) - require.NoError(t, t.workflowDB.Close()) + require.NoError(t, t.processDB.Close()) require.NoError(t, os.RemoveAll(servicedbname)) require.NoError(t, os.RemoveAll(execdbname)) require.NoError(t, os.RemoveAll(instdbname)) - require.NoError(t, os.RemoveAll(workflowdbname)) + require.NoError(t, os.RemoveAll(processdbname)) } func newTesting(t *testing.T) (*Execution, *apiTesting) { @@ -58,18 +58,18 @@ func newTesting(t *testing.T) (*Execution, *apiTesting) { execDB, err := database.NewExecutionDB(execdbname) require.NoError(t, err) - workflowDB, err := database.NewWorkflowDB(workflowdbname) + processDB, err := database.NewProcessDB(processdbname) require.NoError(t, err) - workflow := workflowsdk.New(instance, workflowDB) + process := processesdk.New(instance, processDB) - sdk := New(pubsub.New(0), service, instance, workflow, execDB) + sdk := New(pubsub.New(0), service, instance, process, execDB) return sdk, &apiTesting{ T: t, serviceDB: db, executionDB: execDB, instanceDB: instDB, - workflowDB: workflowDB, + processDB: processDB, } } diff --git a/sdk/process/process.go b/sdk/process/process.go new file mode 100644 index 000000000..e9d40c36f --- /dev/null +++ b/sdk/process/process.go @@ -0,0 +1,80 @@ +package processesdk + +import ( + "fmt" + + "github.com/mesg-foundation/engine/database" + "github.com/mesg-foundation/engine/hash" + "github.com/mesg-foundation/engine/process" + instancesdk "github.com/mesg-foundation/engine/sdk/instance" +) + +// Process exposes process APIs of MESG. +type Process struct { + processDB database.ProcessDB + instance *instancesdk.Instance +} + +// New creates a new Process SDK with given options. +func New(instance *instancesdk.Instance, processDB database.ProcessDB) *Process { + return &Process{ + processDB: processDB, + instance: instance, + } +} + +// Create creates a new service from definition. +func (w *Process) Create(wf *process.Process) (*process.Process, error) { + wf.Hash = hash.Dump(wf) + + for _, node := range wf.Nodes { + switch n := node.(type) { + case process.Result: + if _, err := w.instance.Get(n.InstanceHash); err != nil { + return nil, err + } + case process.Event: + if _, err := w.instance.Get(n.InstanceHash); err != nil { + return nil, err + } + case process.Task: + if _, err := w.instance.Get(n.InstanceHash); err != nil { + return nil, err + } + } + } + + // check if process already exists. + if _, err := w.processDB.Get(wf.Hash); err == nil { + return nil, &AlreadyExistsError{Hash: wf.Hash} + } + + if err := wf.Validate(); err != nil { + return nil, err + } + return wf, w.processDB.Save(wf) +} + +// Delete deletes the process by hash. +func (w *Process) Delete(hash hash.Hash) error { + return w.processDB.Delete(hash) +} + +// Get returns the process that matches given hash. +func (w *Process) Get(hash hash.Hash) (*process.Process, error) { + return w.processDB.Get(hash) +} + +// List returns all processes. +func (w *Process) List() ([]*process.Process, error) { + return w.processDB.All() +} + +// AlreadyExistsError is an not found error. +type AlreadyExistsError struct { + Hash hash.Hash +} + +func (e *AlreadyExistsError) Error() string { + return fmt.Sprintf("process %q already exists", e.Hash.String()) +} diff --git a/sdk/sdk.go b/sdk/sdk.go index 6845e49b8..6306ff4a3 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -8,8 +8,8 @@ import ( eventsdk "github.com/mesg-foundation/engine/sdk/event" executionsdk "github.com/mesg-foundation/engine/sdk/execution" instancesdk "github.com/mesg-foundation/engine/sdk/instance" + processesdk "github.com/mesg-foundation/engine/sdk/process" servicesdk "github.com/mesg-foundation/engine/sdk/service" - workflowsdk "github.com/mesg-foundation/engine/sdk/workflow" ) // SDK exposes all functionalities of MESG Engine. @@ -18,19 +18,19 @@ type SDK struct { Instance *instancesdk.Instance Execution *executionsdk.Execution Event *eventsdk.Event - Workflow *workflowsdk.Workflow + Process *processesdk.Process } // New creates a new SDK with given options. -func New(app *cosmos.App, c container.Container, instanceDB database.InstanceDB, execDB database.ExecutionDB, workflowDB database.WorkflowDB, engineName, port string) (*SDK, error) { +func New(app *cosmos.App, c container.Container, instanceDB database.InstanceDB, execDB database.ExecutionDB, processDB database.ProcessDB, engineName, port string) (*SDK, error) { initDefaultAppModules(app) ps := pubsub.New(0) initDefaultAppModules(app) serviceSDK := servicesdk.NewSDK(app) servicesdk.NewModule(app, c) instanceSDK := instancesdk.New(c, serviceSDK, instanceDB, engineName, port) - workflowSDK := workflowsdk.New(instanceSDK, workflowDB) - executionSDK := executionsdk.New(ps, serviceSDK, instanceSDK, workflowSDK, execDB) + processSDK := processesdk.New(instanceSDK, processDB) + executionSDK := executionsdk.New(ps, serviceSDK, instanceSDK, processSDK, execDB) eventSDK := eventsdk.New(ps, serviceSDK, instanceSDK) // TODO: is it the best place to load the app? if err := app.Load(); err != nil { @@ -41,23 +41,23 @@ func New(app *cosmos.App, c container.Container, instanceDB database.InstanceDB, Instance: instanceSDK, Execution: executionSDK, Event: eventSDK, - Workflow: workflowSDK, + Process: processSDK, }, nil } // NewDeprecated creates a new SDK with given options. -func NewDeprecated(c container.Container, serviceDB *database.ServiceDB, instanceDB database.InstanceDB, execDB database.ExecutionDB, workflowDB database.WorkflowDB, engineName, port string) *SDK { +func NewDeprecated(c container.Container, serviceDB *database.ServiceDB, instanceDB database.InstanceDB, execDB database.ExecutionDB, processDB database.ProcessDB, engineName, port string) *SDK { ps := pubsub.New(0) serviceSDK := servicesdk.NewDeprecated(c, serviceDB) instanceSDK := instancesdk.New(c, serviceSDK, instanceDB, engineName, port) - workflowSDK := workflowsdk.New(instanceSDK, workflowDB) - executionSDK := executionsdk.New(ps, serviceSDK, instanceSDK, workflowSDK, execDB) + processSDK := processesdk.New(instanceSDK, processDB) + executionSDK := executionsdk.New(ps, serviceSDK, instanceSDK, processSDK, execDB) eventSDK := eventsdk.New(ps, serviceSDK, instanceSDK) return &SDK{ Service: serviceSDK, Instance: instanceSDK, Execution: executionSDK, Event: eventSDK, - Workflow: workflowSDK, + Process: processSDK, } } diff --git a/sdk/workflow/workflow.go b/sdk/workflow/workflow.go deleted file mode 100644 index 2523eeaec..000000000 --- a/sdk/workflow/workflow.go +++ /dev/null @@ -1,80 +0,0 @@ -package workflowsdk - -import ( - "fmt" - - "github.com/mesg-foundation/engine/database" - "github.com/mesg-foundation/engine/hash" - instancesdk "github.com/mesg-foundation/engine/sdk/instance" - "github.com/mesg-foundation/engine/workflow" -) - -// Workflow exposes workflow APIs of MESG. -type Workflow struct { - workflowDB database.WorkflowDB - instance *instancesdk.Instance -} - -// New creates a new Workflow SDK with given options. -func New(instance *instancesdk.Instance, workflowDB database.WorkflowDB) *Workflow { - return &Workflow{ - workflowDB: workflowDB, - instance: instance, - } -} - -// Create creates a new service from definition. -func (w *Workflow) Create(wf *workflow.Workflow) (*workflow.Workflow, error) { - wf.Hash = hash.Dump(wf) - - for _, node := range wf.Nodes { - switch n := node.(type) { - case workflow.Result: - if _, err := w.instance.Get(n.InstanceHash); err != nil { - return nil, err - } - case workflow.Event: - if _, err := w.instance.Get(n.InstanceHash); err != nil { - return nil, err - } - case workflow.Task: - if _, err := w.instance.Get(n.InstanceHash); err != nil { - return nil, err - } - } - } - - // check if workflow already exists. - if _, err := w.workflowDB.Get(wf.Hash); err == nil { - return nil, &AlreadyExistsError{Hash: wf.Hash} - } - - if err := wf.Validate(); err != nil { - return nil, err - } - return wf, w.workflowDB.Save(wf) -} - -// Delete deletes the workflow by hash. -func (w *Workflow) Delete(hash hash.Hash) error { - return w.workflowDB.Delete(hash) -} - -// Get returns the workflow that matches given hash. -func (w *Workflow) Get(hash hash.Hash) (*workflow.Workflow, error) { - return w.workflowDB.Get(hash) -} - -// List returns all workflows. -func (w *Workflow) List() ([]*workflow.Workflow, error) { - return w.workflowDB.All() -} - -// AlreadyExistsError is an not found error. -type AlreadyExistsError struct { - Hash hash.Hash -} - -func (e *AlreadyExistsError) Error() string { - return fmt.Sprintf("workflow %q already exists", e.Hash.String()) -} diff --git a/server/grpc/api/execution.go b/server/grpc/api/execution.go index 8017a8c7d..fcb47a8e5 100644 --- a/server/grpc/api/execution.go +++ b/server/grpc/api/execution.go @@ -134,7 +134,7 @@ func toProtoExecution(exec *execution.Execution) (*types.Execution, error) { return &types.Execution{ Hash: exec.Hash, - WorkflowHash: exec.WorkflowHash, + ProcessHash: exec.ProcessHash, ParentHash: exec.ParentHash, EventHash: exec.EventHash, Status: types.Status(exec.Status), diff --git a/server/grpc/api/process.go b/server/grpc/api/process.go new file mode 100644 index 000000000..91339fc18 --- /dev/null +++ b/server/grpc/api/process.go @@ -0,0 +1,236 @@ +package api + +import ( + "context" + "fmt" + + "github.com/mesg-foundation/engine/filter" + "github.com/mesg-foundation/engine/process" + "github.com/mesg-foundation/engine/protobuf/api" + "github.com/mesg-foundation/engine/protobuf/types" + "github.com/mesg-foundation/engine/sdk" +) + +// ProcessServer is the type to aggregate all Service APIs. +type ProcessServer struct { + sdk *sdk.SDK +} + +// NewProcessServer creates a new ProcessServer. +func NewProcessServer(sdk *sdk.SDK) *ProcessServer { + return &ProcessServer{sdk: sdk} +} + +// Create creates a new service from definition. +func (s *ProcessServer) Create(ctx context.Context, req *api.CreateProcessRequest) (*api.CreateProcessResponse, error) { + wf, err := fromProtoProcess(&types.Process{ + Key: req.Key, + Nodes: req.Nodes, + Edges: req.Edges, + }) + if err != nil { + return nil, err + } + wf, err = s.sdk.Process.Create(wf) + if err != nil { + return nil, err + } + return &api.CreateProcessResponse{Hash: wf.Hash}, nil +} + +// Delete deletes service by hash or sid. +func (s *ProcessServer) Delete(ctx context.Context, request *api.DeleteProcessRequest) (*api.DeleteProcessResponse, error) { + return &api.DeleteProcessResponse{}, s.sdk.Process.Delete(request.Hash) +} + +// Get returns service from given hash. +func (s *ProcessServer) Get(ctx context.Context, req *api.GetProcessRequest) (*types.Process, error) { + wf, err := s.sdk.Process.Get(req.Hash) + if err != nil { + return nil, err + } + return toProtoProcess(wf), nil +} + +// List returns all processes. +func (s *ProcessServer) List(ctx context.Context, req *api.ListProcessRequest) (*api.ListProcessResponse, error) { + processes, err := s.sdk.Process.List() + if err != nil { + return nil, err + } + wfs := toProtoProcesses(processes) + return &api.ListProcessResponse{ + Processes: wfs, + }, nil +} + +func fromProtoProcessNodes(nodes []*types.Process_Node) ([]process.Node, error) { + res := make([]process.Node, len(nodes)) + for i, node := range nodes { + switch n := node.Type.(type) { + case *types.Process_Node_Event_: + res[i] = process.Event{Key: n.Event.Key, InstanceHash: n.Event.InstanceHash, EventKey: n.Event.EventKey} + case *types.Process_Node_Result_: + res[i] = process.Result{Key: n.Result.Key, InstanceHash: n.Result.InstanceHash, TaskKey: n.Result.TaskKey} + case *types.Process_Node_Task_: + res[i] = process.Task{InstanceHash: n.Task.InstanceHash, TaskKey: n.Task.TaskKey, Key: n.Task.Key} + case *types.Process_Node_Map_: + outputs := make([]process.Output, len(n.Map.Outputs)) + for j, output := range n.Map.Outputs { + out := process.Output{Key: output.Key} + switch x := output.Value.(type) { + case *types.Process_Node_Map_Output_Ref: + out.Ref = &process.OutputReference{ + NodeKey: output.GetRef().NodeKey, + Key: output.GetRef().Key, + } + default: + return nil, fmt.Errorf("output has unexpected type %T", x) + } + outputs[j] = out + } + res[i] = process.Map{Key: n.Map.Key, Outputs: outputs} + case *types.Process_Node_Filter_: + conditions := make([]filter.Condition, len(n.Filter.Conditions)) + for j, condition := range n.Filter.Conditions { + cond := filter.Condition{Key: condition.Key, Value: condition.Value} + switch condition.Predicate { + case types.Process_Node_Filter_Condition_EQ: + cond.Predicate = filter.EQ + default: + return nil, fmt.Errorf("predicate %q not supported", condition.Predicate) + } + conditions[j] = cond + } + res[i] = process.Filter{Key: n.Filter.Key, Filter: filter.Filter{Conditions: conditions}} + default: + return nil, fmt.Errorf("node has unexpected type %T", n) + } + } + return res, nil +} + +func fromProtoProcessEdges(edges []*types.Process_Edge) []process.Edge { + res := make([]process.Edge, len(edges)) + for i, edge := range edges { + res[i] = process.Edge{ + Src: edge.Src, + Dst: edge.Dst, + } + } + return res +} + +func fromProtoProcess(wf *types.Process) (*process.Process, error) { + nodes, err := fromProtoProcessNodes(wf.Nodes) + if err != nil { + return nil, err + } + return &process.Process{ + Key: wf.Key, + Graph: process.Graph{ + Nodes: nodes, + Edges: fromProtoProcessEdges(wf.Edges), + }, + }, nil +} + +func toProtoProcessNodes(nodes []process.Node) []*types.Process_Node { + res := make([]*types.Process_Node, len(nodes)) + for i, node := range nodes { + protoNode := types.Process_Node{} + switch n := node.(type) { + case *process.Result: + protoNode.Type = &types.Process_Node_Result_{ + Result: &types.Process_Node_Result{ + Key: n.Key, + InstanceHash: n.InstanceHash, + TaskKey: n.TaskKey, + }, + } + case *process.Event: + protoNode.Type = &types.Process_Node_Event_{ + Event: &types.Process_Node_Event{ + Key: n.Key, + InstanceHash: n.InstanceHash, + EventKey: n.EventKey, + }, + } + case *process.Task: + protoNode.Type = &types.Process_Node_Task_{ + Task: &types.Process_Node_Task{ + Key: n.Key, + InstanceHash: n.InstanceHash, + TaskKey: n.TaskKey, + }, + } + case *process.Map: + outputs := make([]*types.Process_Node_Map_Output, len(n.Outputs)) + for j, output := range n.Outputs { + out := &types.Process_Node_Map_Output{Key: output.Key} + if output.Ref != nil { + out.Value = &types.Process_Node_Map_Output_Ref{ + Ref: &types.Process_Node_Map_Output_Reference{ + NodeKey: output.Ref.NodeKey, + Key: output.Ref.Key, + }, + } + } + outputs[j] = out + } + + protoNode.Type = &types.Process_Node_Map_{ + Map: &types.Process_Node_Map{ + Key: n.Key, + Outputs: outputs, + }, + } + case *process.Filter: + conditions := make([]*types.Process_Node_Filter_Condition, len(n.Conditions)) + for j, condition := range n.Conditions { + cond := &types.Process_Node_Filter_Condition{Key: condition.Key, Value: condition.Value} + if condition.Predicate == filter.EQ { + cond.Predicate = types.Process_Node_Filter_Condition_EQ + } + conditions[j] = cond + } + + protoNode.Type = &types.Process_Node_Filter_{ + Filter: &types.Process_Node_Filter{ + Key: n.Key, + Conditions: conditions, + }, + } + } + res[i] = &protoNode + } + return res +} + +func toProtoProcessEdges(edges []process.Edge) []*types.Process_Edge { + res := make([]*types.Process_Edge, len(edges)) + for i, edge := range edges { + res[i] = &types.Process_Edge{ + Src: edge.Src, + Dst: edge.Dst, + } + } + return res +} + +func toProtoProcess(wf *process.Process) *types.Process { + return &types.Process{ + Hash: wf.Hash, + Key: wf.Key, + Nodes: toProtoProcessNodes(wf.Nodes), + Edges: toProtoProcessEdges(wf.Edges), + } +} + +func toProtoProcesses(processes []*process.Process) []*types.Process { + wfs := make([]*types.Process, len(processes)) + for i, wf := range processes { + wfs[i] = toProtoProcess(wf) + } + return wfs +} diff --git a/server/grpc/api/workflow.go b/server/grpc/api/workflow.go deleted file mode 100644 index 80774aea8..000000000 --- a/server/grpc/api/workflow.go +++ /dev/null @@ -1,236 +0,0 @@ -package api - -import ( - "context" - "fmt" - - "github.com/mesg-foundation/engine/filter" - "github.com/mesg-foundation/engine/protobuf/api" - "github.com/mesg-foundation/engine/protobuf/types" - "github.com/mesg-foundation/engine/sdk" - "github.com/mesg-foundation/engine/workflow" -) - -// WorkflowServer is the type to aggregate all Service APIs. -type WorkflowServer struct { - sdk *sdk.SDK -} - -// NewWorkflowServer creates a new WorkflowServer. -func NewWorkflowServer(sdk *sdk.SDK) *WorkflowServer { - return &WorkflowServer{sdk: sdk} -} - -// Create creates a new service from definition. -func (s *WorkflowServer) Create(ctx context.Context, req *api.CreateWorkflowRequest) (*api.CreateWorkflowResponse, error) { - wf, err := fromProtoWorkflow(&types.Workflow{ - Key: req.Key, - Nodes: req.Nodes, - Edges: req.Edges, - }) - if err != nil { - return nil, err - } - wf, err = s.sdk.Workflow.Create(wf) - if err != nil { - return nil, err - } - return &api.CreateWorkflowResponse{Hash: wf.Hash}, nil -} - -// Delete deletes service by hash or sid. -func (s *WorkflowServer) Delete(ctx context.Context, request *api.DeleteWorkflowRequest) (*api.DeleteWorkflowResponse, error) { - return &api.DeleteWorkflowResponse{}, s.sdk.Workflow.Delete(request.Hash) -} - -// Get returns service from given hash. -func (s *WorkflowServer) Get(ctx context.Context, req *api.GetWorkflowRequest) (*types.Workflow, error) { - wf, err := s.sdk.Workflow.Get(req.Hash) - if err != nil { - return nil, err - } - return toProtoWorkflow(wf), nil -} - -// List returns all workflows. -func (s *WorkflowServer) List(ctx context.Context, req *api.ListWorkflowRequest) (*api.ListWorkflowResponse, error) { - workflows, err := s.sdk.Workflow.List() - if err != nil { - return nil, err - } - wfs := toProtoWorkflows(workflows) - return &api.ListWorkflowResponse{ - Workflows: wfs, - }, nil -} - -func fromProtoWorkflowNodes(nodes []*types.Workflow_Node) ([]workflow.Node, error) { - res := make([]workflow.Node, len(nodes)) - for i, node := range nodes { - switch n := node.Type.(type) { - case *types.Workflow_Node_Event_: - res[i] = workflow.Event{Key: n.Event.Key, InstanceHash: n.Event.InstanceHash, EventKey: n.Event.EventKey} - case *types.Workflow_Node_Result_: - res[i] = workflow.Result{Key: n.Result.Key, InstanceHash: n.Result.InstanceHash, TaskKey: n.Result.TaskKey} - case *types.Workflow_Node_Task_: - res[i] = workflow.Task{InstanceHash: n.Task.InstanceHash, TaskKey: n.Task.TaskKey, Key: n.Task.Key} - case *types.Workflow_Node_Map_: - outputs := make([]workflow.Output, len(n.Map.Outputs)) - for j, output := range n.Map.Outputs { - out := workflow.Output{Key: output.Key} - switch x := output.Value.(type) { - case *types.Workflow_Node_Map_Output_Ref: - out.Ref = &workflow.OutputReference{ - NodeKey: output.GetRef().NodeKey, - Key: output.GetRef().Key, - } - default: - return nil, fmt.Errorf("output has unexpected type %T", x) - } - outputs[j] = out - } - res[i] = workflow.Map{Key: n.Map.Key, Outputs: outputs} - case *types.Workflow_Node_Filter_: - conditions := make([]filter.Condition, len(n.Filter.Conditions)) - for j, condition := range n.Filter.Conditions { - cond := filter.Condition{Key: condition.Key, Value: condition.Value} - switch condition.Predicate { - case types.Workflow_Node_Filter_Condition_EQ: - cond.Predicate = filter.EQ - default: - return nil, fmt.Errorf("predicate %q not supported", condition.Predicate) - } - conditions[j] = cond - } - res[i] = workflow.Filter{Key: n.Filter.Key, Filter: filter.Filter{Conditions: conditions}} - default: - return nil, fmt.Errorf("node has unexpected type %T", n) - } - } - return res, nil -} - -func fromProtoWorkflowEdges(edges []*types.Workflow_Edge) []workflow.Edge { - res := make([]workflow.Edge, len(edges)) - for i, edge := range edges { - res[i] = workflow.Edge{ - Src: edge.Src, - Dst: edge.Dst, - } - } - return res -} - -func fromProtoWorkflow(wf *types.Workflow) (*workflow.Workflow, error) { - nodes, err := fromProtoWorkflowNodes(wf.Nodes) - if err != nil { - return nil, err - } - return &workflow.Workflow{ - Key: wf.Key, - Graph: workflow.Graph{ - Nodes: nodes, - Edges: fromProtoWorkflowEdges(wf.Edges), - }, - }, nil -} - -func toProtoWorkflowNodes(nodes []workflow.Node) []*types.Workflow_Node { - res := make([]*types.Workflow_Node, len(nodes)) - for i, node := range nodes { - protoNode := types.Workflow_Node{} - switch n := node.(type) { - case *workflow.Result: - protoNode.Type = &types.Workflow_Node_Result_{ - Result: &types.Workflow_Node_Result{ - Key: n.Key, - InstanceHash: n.InstanceHash, - TaskKey: n.TaskKey, - }, - } - case *workflow.Event: - protoNode.Type = &types.Workflow_Node_Event_{ - Event: &types.Workflow_Node_Event{ - Key: n.Key, - InstanceHash: n.InstanceHash, - EventKey: n.EventKey, - }, - } - case *workflow.Task: - protoNode.Type = &types.Workflow_Node_Task_{ - Task: &types.Workflow_Node_Task{ - Key: n.Key, - InstanceHash: n.InstanceHash, - TaskKey: n.TaskKey, - }, - } - case *workflow.Map: - outputs := make([]*types.Workflow_Node_Map_Output, len(n.Outputs)) - for j, output := range n.Outputs { - out := &types.Workflow_Node_Map_Output{Key: output.Key} - if output.Ref != nil { - out.Value = &types.Workflow_Node_Map_Output_Ref{ - Ref: &types.Workflow_Node_Map_Output_Reference{ - NodeKey: output.Ref.NodeKey, - Key: output.Ref.Key, - }, - } - } - outputs[j] = out - } - - protoNode.Type = &types.Workflow_Node_Map_{ - Map: &types.Workflow_Node_Map{ - Key: n.Key, - Outputs: outputs, - }, - } - case *workflow.Filter: - conditions := make([]*types.Workflow_Node_Filter_Condition, len(n.Conditions)) - for j, condition := range n.Conditions { - cond := &types.Workflow_Node_Filter_Condition{Key: condition.Key, Value: condition.Value} - if condition.Predicate == filter.EQ { - cond.Predicate = types.Workflow_Node_Filter_Condition_EQ - } - conditions[j] = cond - } - - protoNode.Type = &types.Workflow_Node_Filter_{ - Filter: &types.Workflow_Node_Filter{ - Key: n.Key, - Conditions: conditions, - }, - } - } - res[i] = &protoNode - } - return res -} - -func toProtoWorkflowEdges(edges []workflow.Edge) []*types.Workflow_Edge { - res := make([]*types.Workflow_Edge, len(edges)) - for i, edge := range edges { - res[i] = &types.Workflow_Edge{ - Src: edge.Src, - Dst: edge.Dst, - } - } - return res -} - -func toProtoWorkflow(wf *workflow.Workflow) *types.Workflow { - return &types.Workflow{ - Hash: wf.Hash, - Key: wf.Key, - Nodes: toProtoWorkflowNodes(wf.Nodes), - Edges: toProtoWorkflowEdges(wf.Edges), - } -} - -func toProtoWorkflows(workflows []*workflow.Workflow) []*types.Workflow { - wfs := make([]*types.Workflow, len(workflows)) - for i, wf := range workflows { - wfs[i] = toProtoWorkflow(wf) - } - return wfs -} diff --git a/server/grpc/core/test_test.go b/server/grpc/core/test_test.go index 4371d4787..457fe8f92 100644 --- a/server/grpc/core/test_test.go +++ b/server/grpc/core/test_test.go @@ -15,7 +15,7 @@ const ( servicedbname = "service.db.test" instancedbname = "instance.db.test" execdbname = "exec.db.test" - workflowdbname = "workflow.db.test" + processdbname = "process.db.test" ) func newServerWithContainer(t *testing.T, c container.Container) (*Server, func()) { @@ -29,10 +29,10 @@ func newServerWithContainer(t *testing.T, c container.Container) (*Server, func( execDB, err := database.NewExecutionDB(execdbname) require.NoError(t, err) - workflowDB, err := database.NewWorkflowDB(workflowdbname) + processDB, err := database.NewProcessDB(processdbname) require.NoError(t, err) - a := sdk.NewDeprecated(c, db, instanceDB, execDB, workflowDB, "", "") + a := sdk.NewDeprecated(c, db, instanceDB, execDB, processDB, "", "") server := NewServer(a) @@ -40,11 +40,11 @@ func newServerWithContainer(t *testing.T, c container.Container) (*Server, func( db.Close() instanceDB.Close() execDB.Close() - workflowDB.Close() + processDB.Close() os.RemoveAll(servicedbname) os.RemoveAll(instancedbname) os.RemoveAll(execdbname) - os.RemoveAll(workflowdbname) + os.RemoveAll(processdbname) } return server, closer } diff --git a/server/grpc/server.go b/server/grpc/server.go index ed3c2fbc6..1a88d2512 100644 --- a/server/grpc/server.go +++ b/server/grpc/server.go @@ -67,7 +67,7 @@ func (s *Server) register() { protobuf_api.RegisterExecutionServer(s.instance, api.NewExecutionServer(s.sdk)) protobuf_api.RegisterInstanceServer(s.instance, api.NewInstanceServer(s.sdk)) protobuf_api.RegisterServiceServer(s.instance, api.NewServiceServer(s.sdk)) - protobuf_api.RegisterWorkflowServer(s.instance, api.NewWorkflowServer(s.sdk)) + protobuf_api.RegisterProcessServer(s.instance, api.NewProcessServer(s.sdk)) reflection.Register(s.instance) }