Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow graph structure #1209

Merged
merged 16 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion execution/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,23 @@ type Execution struct {
Status Status `hash:"-"`
InstanceHash hash.Hash `hash:"name:instanceHash"`
TaskKey string `hash:"name:taskKey"`
StepID string `hash:"name:stepID"`
Tags []string `hash:"name:tags"`
Inputs map[string]interface{} `hash:"name:inputs"`
Outputs map[string]interface{} `hash:"-"`
Error string `hash:"-"`
}

// New returns a new execution. It returns an error if inputs are invalid.
func New(workflowHash, instanceHash, parentHash, eventHash hash.Hash, taskKey string, inputs map[string]interface{}, tags []string) *Execution {
func New(workflowHash, instanceHash, parentHash, eventHash hash.Hash, stepID string, taskKey string, inputs map[string]interface{}, tags []string) *Execution {
exec := &Execution{
WorkflowHash: workflowHash,
EventHash: eventHash,
InstanceHash: instanceHash,
ParentHash: parentHash,
Inputs: inputs,
TaskKey: taskKey,
StepID: stepID,
Tags: tags,
Status: Created,
}
Expand Down
10 changes: 5 additions & 5 deletions execution/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestNewFromService(t *testing.T) {
tags = []string{"tag"}
)

execution := New(nil, hash, parentHash, eventHash, taskKey, nil, tags)
execution := New(nil, hash, parentHash, eventHash, "", taskKey, nil, tags)
require.NotNil(t, execution)
require.Equal(t, hash, execution.InstanceHash)
require.Equal(t, parentHash, execution.ParentHash)
Expand All @@ -30,15 +30,15 @@ func TestNewFromService(t *testing.T) {
}

func TestExecute(t *testing.T) {
e := New(nil, nil, nil, nil, "", nil, nil)
e := New(nil, nil, nil, nil, "", "", nil, nil)
require.NoError(t, e.Execute())
require.Equal(t, InProgress, e.Status)
require.Error(t, e.Execute())
}

func TestComplete(t *testing.T) {
output := map[string]interface{}{"foo": "bar"}
e := New(nil, nil, nil, nil, "", nil, nil)
e := New(nil, nil, nil, nil, "", "", nil, nil)

e.Execute()
require.NoError(t, e.Complete(output))
Expand All @@ -49,7 +49,7 @@ func TestComplete(t *testing.T) {

func TestFailed(t *testing.T) {
err := errors.New("test")
e := New(nil, nil, nil, nil, "", nil, nil)
e := New(nil, nil, nil, nil, "", "", nil, nil)
e.Execute()
require.NoError(t, e.Failed(err))
require.Equal(t, Failed, e.Status)
Expand All @@ -68,7 +68,7 @@ func TestExecutionHash(t *testing.T) {
ids := make(map[string]bool)

f := func(instanceHash, parentHash, eventID []byte, taskKey, input string, tags []string) bool {
e := New(nil, instanceHash, parentHash, eventID, taskKey, map[string]interface{}{"input": input}, tags)
e := New(nil, instanceHash, parentHash, eventID, "", taskKey, map[string]interface{}{"input": input}, tags)
if ids[string(e.Hash)] {
return false
}
Expand Down
57 changes: 33 additions & 24 deletions protobuf/api/workflow.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion protobuf/api/workflow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ service Workflow {
message CreateWorkflowRequest {
string key = 2; // Workflow's key
types.Workflow.Trigger trigger = 3; // Trigger for the workflow.
repeated types.Workflow.Task tasks = 4; // Task to execute when the trigger is valid.
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.
Expand Down
79 changes: 44 additions & 35 deletions protobuf/types/execution.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions protobuf/types/execution.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ message Execution {
// Hash is a unique hash to identify execution.
string hash = 1;

// wokflowHash is the unique hash of the workflow associated to this execution.
string workflowHash = 11;

// parentHash is the unique hash of parent execution. if execution is triggered by another one, dependency execution considered as the parent.
string parentHash = 2;

Expand All @@ -59,4 +56,10 @@ 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.
string workflowHash = 11;

// step of the workflow.
string stepID = 12;
}
Loading