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 15843b7 commit fb0a218
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
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 fb0a218

Please sign in to comment.