From 7e578f80bd4a73edbda8d8cebba7b5bc400b1c40 Mon Sep 17 00:00:00 2001 From: Mothiki Date: Mon, 21 Aug 2017 19:45:36 -0700 Subject: [PATCH 1/3] check for staus failed and return error --- monitors.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitors.go b/monitors.go index 96face0..9b685df 100644 --- a/monitors.go +++ b/monitors.go @@ -80,9 +80,9 @@ func (m *Monitor) JobUpdate(updateKey aurora.JobUpdateKey, interval int, timeout if status == aurora.JobUpdateStatus_ROLLED_FORWARD { fmt.Println("Update succeded") return true, nil - } else { + } else if status == aurora.JobUpdateStatus_FAILED { fmt.Println("Update failed") - return false, nil + return false, errors.New("update failed") } } From dcab5e698f32157111f3651d2203d59151693f85 Mon Sep 17 00:00:00 2001 From: Mothiki Date: Tue, 22 Aug 2017 16:55:20 -0700 Subject: [PATCH 2/3] monitor job update returns on Rolle back and update fail --- monitors.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/monitors.go b/monitors.go index 9b685df..53cfe37 100644 --- a/monitors.go +++ b/monitors.go @@ -24,6 +24,11 @@ import ( "github.com/rdelval/gorealis/response" ) +const ( + UpdateFailed = "update failed" + RolledBack = "update rolled back" +) + type Monitor struct { Client Realis } @@ -82,7 +87,12 @@ func (m *Monitor) JobUpdate(updateKey aurora.JobUpdateKey, interval int, timeout return true, nil } else if status == aurora.JobUpdateStatus_FAILED { fmt.Println("Update failed") - return false, errors.New("update failed") + return false, errors.New(UpdateFailed) + } else if status == aurora.JobUpdateStatus_ROLLED_BACK { + fmt.Println("rolled back") + return false, errors.New(RolledBack) + } else { + return false, nil } } From 4bc0a694aead63bf772ce872d506640fc2f69574 Mon Sep 17 00:00:00 2001 From: Mothiki Date: Tue, 22 Aug 2017 17:03:35 -0700 Subject: [PATCH 3/3] use switch instead of if else conditions --- monitors.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/monitors.go b/monitors.go index 53cfe37..caf98d0 100644 --- a/monitors.go +++ b/monitors.go @@ -82,16 +82,17 @@ func (m *Monitor) JobUpdate(updateKey aurora.JobUpdateKey, interval int, timeout // Rolled forward is the only state in which an update has been successfully updated // if we encounter an inactive state and it is not at rolled forward, update failed - if status == aurora.JobUpdateStatus_ROLLED_FORWARD { + switch status { + case aurora.JobUpdateStatus_ROLLED_FORWARD: fmt.Println("Update succeded") return true, nil - } else if status == aurora.JobUpdateStatus_FAILED { + case aurora.JobUpdateStatus_FAILED: fmt.Println("Update failed") return false, errors.New(UpdateFailed) - } else if status == aurora.JobUpdateStatus_ROLLED_BACK { + case aurora.JobUpdateStatus_ROLLED_BACK: fmt.Println("rolled back") return false, errors.New(RolledBack) - } else { + default: return false, nil } }