Skip to content

Commit

Permalink
Introduce new event type for source playback (#140)
Browse files Browse the repository at this point in the history
* Introduce new event type for source playback

We'll use this to notify from task-runner to studio about the availability of source playback

* review suggestions
  • Loading branch information
mjh1 authored Jun 9, 2023
1 parent 3564f9c commit f125f4d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/data/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func ParseEvent(data []byte) (Event, error) {
return nil, fmt.Errorf("error unmarshalling task result event: %w", err)
}
return trev, nil
case EventTypeTaskResultPartial:
var event *TaskResultPartialEvent
if err := json.Unmarshal(data, &event); err != nil {
return nil, fmt.Errorf("error unmarshalling task partial result event: %w", err)
}
return event, nil
default:
return nil, fmt.Errorf("unknown event type=%q, streamId=%q, ts=%v", base.Type(), base.StreamID_, base.Timestamp_)
}
Expand Down
21 changes: 21 additions & 0 deletions pkg/data/task_partial_result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package data

const EventTypeTaskResultPartial EventType = "task_result_partial"

func NewTaskResultPartialEvent(info TaskInfo, output *TaskPartialOutput) *TaskResultPartialEvent {
return &TaskResultPartialEvent{
Base: newEventBase(EventTypeTaskResultPartial, ""),
Task: info,
Output: output,
}
}

type TaskResultPartialEvent struct {
Base
Task TaskInfo `json:"task"`
Output *TaskPartialOutput `json:"output,omitempty"`
}

type TaskPartialOutput struct {
Upload *UploadTaskOutput `json:"upload,omitempty"`
}

0 comments on commit f125f4d

Please sign in to comment.