Return 0 instead of -1

This commit is contained in:
andreacappelletti97 2023-04-10 13:37:52 -05:00
parent 59f1dc6dff
commit cf418eb307
3 changed files with 5 additions and 5 deletions

View file

@ -708,18 +708,18 @@ func (c *Client) GetDatabaseWorkerCount(ctx context.Context, orgID string, datab
resp, err := c.httpClient.Get(url)
if err != nil {
return -1, errors.Wrap(err, "getting database-worker-count")
return 0, errors.Wrap(err, "getting database-worker-count")
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
b, _ := io.ReadAll(resp.Body)
return -1, errors.Errorf("status code: %d: %s", resp.StatusCode, b)
return 0, errors.Errorf("status code: %d: %s", resp.StatusCode, b)
}
var workers int
if err := json.NewDecoder(resp.Body).Decode(&workers); err != nil {
return -1, errors.Wrap(err, "reading response body")
return 0, errors.Wrap(err, "reading response body")
}
return workers, nil

View file

@ -789,7 +789,7 @@ func (c *Controller) WorkerCount(ctx context.Context, qdbid dax.QualifiedDatabas
tx, err := c.Transactor.BeginTx(ctx, false)
if err != nil {
return -1, errors.Wrap(err, "beginning tx")
return 0, errors.Wrap(err, "beginning tx")
}
defer tx.Rollback()

View file

@ -72,7 +72,7 @@ func jobsForWorker(dt *DaxTransaction, worker *models.Worker, roleType dax.RoleT
func (w *workerJobService) WorkerCount(tx dax.Transaction, roleType dax.RoleType, qdbid dax.QualifiedDatabaseID) (int, error) {
dt, ok := tx.(*DaxTransaction)
if !ok {
return -1, dax.NewErrInvalidTransaction("*sqldb.DaxTransaction")
return 0, dax.NewErrInvalidTransaction("*sqldb.DaxTransaction")
}
worker := &models.Worker{}