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

3rd step of simplifaction of task output - remove output key from api filter #971

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 3 additions & 14 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,9 @@ func (a *API) ListenExecution(service string, f *ExecutionFilter) (*ExecutionLis
return nil, err
}

if f != nil {
if f.TaskKey == "" && f.OutputKey != "" {
return nil, fmt.Errorf("execution filter: output key given without task key")
}
if f.HasTaskKey() {
task, err := s.GetTask(f.TaskKey)
if err != nil {
return nil, err
}
if f.HasOutputKey() {
if _, err := task.GetOutput(f.OutputKey); err != nil {
return nil, err
}
}
if f != nil && f.HasTaskKey() {
if _, err := s.GetTask(f.TaskKey); err != nil {
return nil, err
}
}

Expand Down
15 changes: 3 additions & 12 deletions api/execution_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (

// ExecutionFilter store fileds for matching executions.
type ExecutionFilter struct {
Status execution.Status
TaskKey string
OutputKey string
Tags []string
Status execution.Status
TaskKey string
Tags []string
}

// Match matches execution.
Expand All @@ -22,9 +21,6 @@ func (f *ExecutionFilter) Match(e *execution.Execution) bool {
if f.TaskKey != "" && f.TaskKey != "*" && f.TaskKey != e.TaskKey {
return false
}
if f.OutputKey != "" && f.OutputKey != "*" && f.OutputKey != e.OutputKey {
return false
}
if f.Status != 0 && f.Status != e.Status {
return false
}
Expand All @@ -41,11 +37,6 @@ func (f *ExecutionFilter) HasTaskKey() bool {
return f != nil && f.TaskKey != "" && f.TaskKey != "*"
}

// HasOutputKey returns true if output key is set to specified value.
func (f *ExecutionFilter) HasOutputKey() bool {
return f != nil && f.OutputKey != "" && f.OutputKey != "*"
}

// ExecutionListener provides functionalities to listen MESG tasks.
type ExecutionListener struct {
// Channel receives matching executions for tasks.
Expand Down
15 changes: 0 additions & 15 deletions api/execution_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ func TestExecutionFilter(t *testing.T) {
&execution.Execution{TaskKey: "1"},
false,
},
{
&ExecutionFilter{OutputKey: "0"},
&execution.Execution{OutputKey: "0"},
true,
},
{
&ExecutionFilter{OutputKey: "*"},
&execution.Execution{OutputKey: "0"},
true,
},
{
&ExecutionFilter{OutputKey: "0"},
&execution.Execution{OutputKey: "1"},
false,
},
{
&ExecutionFilter{Tags: []string{"0"}},
&execution.Execution{Tags: []string{"0"}},
Expand Down
8 changes: 3 additions & 5 deletions interface/grpc/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ func (s *Server) ListenEvent(request *coreapi.ListenEventRequest, stream coreapi
// ListenResult listens for results from a services.
func (s *Server) ListenResult(request *coreapi.ListenResultRequest, stream coreapi.Core_ListenResultServer) error {
filter := &api.ExecutionFilter{
Status: execution.Completed,
TaskKey: request.TaskFilter,
OutputKey: request.OutputFilter,
Tags: request.TagFilters,
Status: execution.Completed,
TaskKey: request.TaskFilter,
Tags: request.TagFilters,
}
ln, err := s.api.ListenExecution(request.ServiceID, filter)
if err != nil {
Expand All @@ -172,7 +171,6 @@ func (s *Server) ListenResult(request *coreapi.ListenResultRequest, stream corea
if err := stream.Send(&coreapi.ResultData{
ExecutionID: execution.ID,
TaskKey: execution.TaskKey,
OutputKey: execution.OutputKey,
OutputData: string(outputs),
ExecutionTags: execution.Tags,
Error: execution.Error,
Expand Down