Adding TerminalUpdateStates function which returns a slice containing all terminal states for an update. Changed signature of JobUpdateStatus from using a map for desired states to a slice. A map is no longer necessary with the new version of thrift and only adds complexity.
This commit is contained in:
parent
2cc19ce7da
commit
a698e3b8dd
4 changed files with 25 additions and 24 deletions
|
@ -7,6 +7,11 @@ Users can check for a Timedout error by using `realis.IsTimeout(err)`.
|
||||||
a Variable Batch Update configured Update is currently in.
|
a Variable Batch Update configured Update is currently in.
|
||||||
* Added new PauseUpdateMonitor which monitors an update until it is an `ROLL_FORWARD_PAUSED` state.
|
* Added new PauseUpdateMonitor which monitors an update until it is an `ROLL_FORWARD_PAUSED` state.
|
||||||
* Added variableBatchStep command to sample client to be used for testing new VariableBatchStep api.
|
* Added variableBatchStep command to sample client to be used for testing new VariableBatchStep api.
|
||||||
|
* JobUpdateStatus has changed function signature from:
|
||||||
|
`JobUpdateStatus(updateKey aurora.JobUpdateKey, desiredStatuses map[aurora.JobUpdateStatus]bool, interval, timeout time.Duration) (aurora.JobUpdateStatus, error)`
|
||||||
|
to
|
||||||
|
`JobUpdateStatus(updateKey aurora.JobUpdateKey, desiredStatuses []aurora.JobUpdateStatus, interval, timeout time.Duration) (aurora.JobUpdateStatus, error)`
|
||||||
|
* Added TerminalUpdateStates function which returns an slice containing all UpdateStates which are considered terminal states.
|
||||||
|
|
||||||
1.21.0
|
1.21.0
|
||||||
|
|
||||||
|
|
25
monitors.go
25
monitors.go
|
@ -38,13 +38,7 @@ func (m *Monitor) JobUpdate(
|
||||||
updateQ := aurora.JobUpdateQuery{
|
updateQ := aurora.JobUpdateQuery{
|
||||||
Key: &updateKey,
|
Key: &updateKey,
|
||||||
Limit: 1,
|
Limit: 1,
|
||||||
UpdateStatuses: []aurora.JobUpdateStatus{
|
UpdateStatuses: TerminalUpdateStates(),
|
||||||
aurora.JobUpdateStatus_ROLLED_FORWARD,
|
|
||||||
aurora.JobUpdateStatus_ROLLED_BACK,
|
|
||||||
aurora.JobUpdateStatus_ABORTED,
|
|
||||||
aurora.JobUpdateStatus_ERROR,
|
|
||||||
aurora.JobUpdateStatus_FAILED,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
updateSummaries, err := m.JobUpdateQuery(
|
updateSummaries, err := m.JobUpdateQuery(
|
||||||
updateQ,
|
updateQ,
|
||||||
|
@ -75,22 +69,13 @@ func (m *Monitor) JobUpdate(
|
||||||
}
|
}
|
||||||
|
|
||||||
// JobUpdateStatus polls the scheduler every certain amount of time to see if the update has entered a specified state.
|
// JobUpdateStatus polls the scheduler every certain amount of time to see if the update has entered a specified state.
|
||||||
func (m *Monitor) JobUpdateStatus(
|
func (m *Monitor) JobUpdateStatus(updateKey aurora.JobUpdateKey,
|
||||||
updateKey aurora.JobUpdateKey,
|
desiredStatuses []aurora.JobUpdateStatus,
|
||||||
desiredStatuses map[aurora.JobUpdateStatus]bool,
|
interval, timeout time.Duration) (aurora.JobUpdateStatus, error) {
|
||||||
interval time.Duration,
|
|
||||||
timeout time.Duration) (aurora.JobUpdateStatus, error) {
|
|
||||||
|
|
||||||
desiredStatusesSlice := make([]aurora.JobUpdateStatus, 0)
|
|
||||||
|
|
||||||
for k := range desiredStatuses {
|
|
||||||
desiredStatusesSlice = append(desiredStatusesSlice, k)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateQ := aurora.JobUpdateQuery{
|
updateQ := aurora.JobUpdateQuery{
|
||||||
Key: &updateKey,
|
Key: &updateKey,
|
||||||
Limit: 1,
|
Limit: 1,
|
||||||
UpdateStatuses: desiredStatusesSlice,
|
UpdateStatuses: desiredStatuses,
|
||||||
}
|
}
|
||||||
summary, err := m.JobUpdateQuery(updateQ, interval, timeout)
|
summary, err := m.JobUpdateQuery(updateQ, interval, timeout)
|
||||||
|
|
||||||
|
|
|
@ -830,7 +830,7 @@ func (r *realisClient) AbortJobUpdate(updateKey aurora.JobUpdateKey, message str
|
||||||
m := Monitor{Client: r}
|
m := Monitor{Client: r}
|
||||||
_, err := m.JobUpdateStatus(
|
_, err := m.JobUpdateStatus(
|
||||||
updateKey,
|
updateKey,
|
||||||
map[aurora.JobUpdateStatus]bool{aurora.JobUpdateStatus_ABORTED: true},
|
[]aurora.JobUpdateStatus{aurora.JobUpdateStatus_ABORTED},
|
||||||
time.Second*5,
|
time.Second*5,
|
||||||
time.Minute)
|
time.Minute)
|
||||||
|
|
||||||
|
@ -1063,7 +1063,6 @@ func (r *realisClient) RollbackJobUpdate(key aurora.JobUpdateKey, message string
|
||||||
|
|
||||||
// VariableBatchStep returns the current batch the update is in during a variable batch update.
|
// VariableBatchStep returns the current batch the update is in during a variable batch update.
|
||||||
func (r *realisClient) VariableBatchStep(key aurora.JobUpdateKey) (int, error) {
|
func (r *realisClient) VariableBatchStep(key aurora.JobUpdateKey) (int, error) {
|
||||||
|
|
||||||
// Query Aurora for an Update that is either paused or rolling forward
|
// Query Aurora for an Update that is either paused or rolling forward
|
||||||
resp, err := r.JobUpdateDetails(aurora.JobUpdateQuery{
|
resp, err := r.JobUpdateDetails(aurora.JobUpdateQuery{
|
||||||
UpdateStatuses: []aurora.JobUpdateStatus{
|
UpdateStatuses: []aurora.JobUpdateStatus{
|
||||||
|
|
12
util.go
12
util.go
|
@ -25,6 +25,18 @@ var TerminalStates = make(map[aurora.ScheduleStatus]bool)
|
||||||
// ActiveJobUpdateStates - States a Job Update may be in where it is considered active.
|
// ActiveJobUpdateStates - States a Job Update may be in where it is considered active.
|
||||||
var ActiveJobUpdateStates = make(map[aurora.JobUpdateStatus]bool)
|
var ActiveJobUpdateStates = make(map[aurora.JobUpdateStatus]bool)
|
||||||
|
|
||||||
|
// TerminalJobUpdateStates returns a slice containing all the terminal states an update may end up in.
|
||||||
|
// This is a function in order to avoid having a slice that can be accidentally mutated.
|
||||||
|
func TerminalUpdateStates() []aurora.JobUpdateStatus {
|
||||||
|
return []aurora.JobUpdateStatus{
|
||||||
|
aurora.JobUpdateStatus_ROLLED_FORWARD,
|
||||||
|
aurora.JobUpdateStatus_ROLLED_BACK,
|
||||||
|
aurora.JobUpdateStatus_ABORTED,
|
||||||
|
aurora.JobUpdateStatus_ERROR,
|
||||||
|
aurora.JobUpdateStatus_FAILED,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// AwaitingPulseJobUpdateStates - States a job update may be in where it is waiting for a pulse.
|
// AwaitingPulseJobUpdateStates - States a job update may be in where it is waiting for a pulse.
|
||||||
var AwaitingPulseJobUpdateStates = make(map[aurora.JobUpdateStatus]bool)
|
var AwaitingPulseJobUpdateStates = make(map[aurora.JobUpdateStatus]bool)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue