-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* export the Flasher status value and version it * change the facility separator in the key to period
- Loading branch information
Showing
3 changed files
with
40 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package types | ||
|
||
import ( | ||
"encoding/json" | ||
"time" | ||
) | ||
|
||
const ( | ||
Version int32 = 1 | ||
) | ||
|
||
// StatusValue is the canonical structure | ||
type StatusValue struct { | ||
UpdatedAt time.Time `json:"updated"` | ||
WorkerID string `json:"worker"` | ||
Target string `json:"target"` | ||
State string `json:"state"` | ||
Status json.RawMessage `json:"status"` | ||
Version int32 `json:"version"` | ||
// WorkSpec json.RawMessage `json:"spec"` XXX: for re-publish use-cases | ||
} | ||
|
||
// MustBytes sets the version field of the StatusValue so any callers don't have | ||
// to deal with it. It will panic if we cannot serialize to JSON for some reason. | ||
func (v *StatusValue) MustBytes() []byte { | ||
v.Version = Version | ||
byt, err := json.Marshal(v) | ||
if err != nil { | ||
panic("unable to serialize status value: " + err.Error()) | ||
} | ||
return byt | ||
} |