Skip to content

Commit

Permalink
Move event struct into separate file.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwo committed Apr 12, 2024
1 parent ad7f088 commit 1c0ec43
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ require (
github.com/elastic/gosigar v0.14.2 // indirect
github.com/elgris/jsondiff v0.0.0-20160530203242-765b5c24c302 // indirect
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/color v1.15.0
github.com/flynn/noise v1.1.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand Down
38 changes: 38 additions & 0 deletions pkg/models/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package models

import "time"

// EventTopic is a high level categorisation that can be applied to an event. It
// should be a human-readable string with no dynamic content. They are used to
// disambiguate events from the same component occurring in different contexts.
// For example, an event emitted by S3 storage used as an input source and the
// same event emitted by S3 storage used as a publisher would be tagged with
// different topics.
//
// EventTopics do not need to conform to a centralized list – each module should
// use event topics that make sense for their own logic. Event topics SHOULD be
// unique.
type EventTopic string

// Event represents a progress report made by the system in its attempt to run a
// job. Events are generated by the orchestrator and also passed back to the
// orchestrator from the compute node.
//
// Events may be delivered in an async fashion – i.e, they may arrive much later
// than the moment they occurred.
type Event struct {
// A human-readable string giving the user all the information they need to
// understand and respond to an Event, if a response is required.
Message string `json:"Message"`

// The topic of the event. See the documentation on EventTopic.
Topic EventTopic `json:"Topic"`

// The moment the event occurred, which may be different to the moment it
// was recorded.
Timestamp time.Time `json:"Timestamp"`

// Any additional metadata that the system or user may need to know about
// the event in order to handle it properly.
Details map[string]string `json:"Details,omitempty"`
}
35 changes: 0 additions & 35 deletions pkg/models/job_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,38 +66,3 @@ func (jh JobHistory) Occurred() time.Time {
}
return jh.Time
}

// EventTopic is a high level categorisation that can be applied to an event. It
// should be a human-readable string with no dynamic content. They are used to
// disambiguate events from the same component occurring in different contexts.
// For example, an event emitted by S3 storage used as an input source and the
// same event emitted by S3 storage used as a publisher would be tagged with
// different topics.
//
// EventTopics do not need to conform to a centralized list – each module should
// use event topics that make sense for their own logic. Event topics SHOULD be
// unique.
type EventTopic string

// Event represents a progress report made by the system in its attempt to run a
// job. Events are generated by the orchestrator and also passed back to the
// orchestrator from the compute node.
//
// Events may be delivered in an async fashion – i.e, they may arrive much later
// than the moment they occurred.
type Event struct {
// A human-readable string giving the user all the information they need to
// understand and respond to an Event, if a response is required.
Message string `json:"Message"`

// The topic of the event. See the documentation on EventTopic.
Topic EventTopic `json:"Topic"`

// The moment the event occurred, which may be different to the moment it
// was recorded.
Timestamp time.Time `json:"Timestamp"`

// Any additional metadata that the system or user may need to know about
// the event in order to handle it properly.
Details map[string]string `json:"Details,omitempty"`
}

0 comments on commit 1c0ec43

Please sign in to comment.