Last active
May 3, 2018 23:28
-
-
Save pdk/d68b4538b2dc48052d899e0558fce469 to your computer and use it in GitHub Desktop.
translated java to go
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
func isJobReady(dataSource DataSource, batchDate time.Date, params map[string]string) (bool, error) { | |
alphaBatchId, ok := params["batchId"] | |
if !ok { | |
return false, fmt.Errorf("batchId value required in params") | |
} | |
client := blorp.LookupClient(dataSource) | |
response, err := client.status(alphaBatchId) | |
if err != nil { | |
log.Printf("Unable to obtain batch status from alpha due to %s", err) | |
// communication error is not a serious problem. we'll just try again later. | |
return false, nil | |
} | |
if IsBatchFailureStatus[response.Status] { | |
log.Printf("Batch job status from Blorp Core indicates job failure, status=%s", | |
response.status) | |
return false, fmt.Errorf("Blorp failed to complete batch job. status from core was: %s", | |
response.status) | |
} | |
ready := strings.ToLower(response.Status) == "completed" | |
log.Printf("alpha batchId=%s, status=%s, ready=%s", alphaBatchId, response.status, ready) | |
return ready, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment