From 79f06bfa81384a95353b1698096c08c26fef0168 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Thu, 29 Aug 2019 18:07:43 -0700 Subject: [PATCH] Adding PauseUpdateMonitor which allows users to poll Aurora for information on an active Update being carried out until it enters the ROLL_FORWARD_PAUSED state. --- monitors.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/monitors.go b/monitors.go index 69167df..cd9aa06 100644 --- a/monitors.go +++ b/monitors.go @@ -129,11 +129,26 @@ func (m *Monitor) JobUpdateQuery( } } -// Instances will monitor a Job until all instances enter one of the LIVE_STATES -func (m *Monitor) Instances( - key *aurora.JobKey, - instances int32, - interval, timeout int) (bool, error) { +// PausedUpdateMonitor polls Aurora for information about a job update until the job update has entered into +// a ROLL_FORWARD_PAUSED state. +func (m *Monitor) PausedUpdateMonitor(key aurora.JobUpdateKey, interval, timeout time.Duration) (bool, error) { + _, err := m.JobUpdateQuery(aurora.JobUpdateQuery{ + UpdateStatuses: []aurora.JobUpdateStatus{aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED}, + Key: &key, + Limit: 1, + }, + interval, + timeout) + + if err != nil { + return false, errors.Wrap(err, "update has not entered paused state") + } + + return true, err +} + +// Monitor a Job until all instances enter one of the LIVE_STATES +func (m *Monitor) Instances(key *aurora.JobKey, instances int32, interval, timeout int) (bool, error) { return m.ScheduleStatus(key, instances, LiveStates, interval, timeout) }