Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #550 from weaveworks/bus-ping-equiv-to-instance-ping
Browse files Browse the repository at this point in the history
Bring the bus implementation of Ping up-to-date
  • Loading branch information
squaremo authored Apr 26, 2017
2 parents 602eae1 + 35ba455 commit ef6e60a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions platform/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func PlatformTestBattery(t *testing.T, wrap func(mock Platform) Platform) {
mock.ApplyError = applyErrors
err = client.Apply(expectedDefs)
if !reflect.DeepEqual(flux.UnderlyingError(err), applyErrors) {
t.Errorf("expected ApplyError, got %#v", err)
t.Errorf("expected ApplyError, got %+v: %s", err, err.Error())
}

err = client.Sync(expectedSyncDef)
Expand All @@ -222,6 +222,6 @@ func PlatformTestBattery(t *testing.T, wrap func(mock Platform) Platform) {
mock.SyncError = syncErrors
err = client.Sync(expectedSyncDef)
if !reflect.DeepEqual(flux.UnderlyingError(err), syncErrors) {
t.Errorf("expected SyncError, got %#v", err)
t.Errorf("expected SyncError, got %+v: %s", err, err.Error())
}
}
10 changes: 6 additions & 4 deletions platform/rpc/nats/bus.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ func (n *NATS) AwaitPresence(instID flux.InstanceID, timeout time.Duration) erro

func (n *NATS) Ping(instID flux.InstanceID) error {
var response PingResponse
err := n.enc.Request(string(instID)+methodPing, ping{}, &response, timeout)
if err == nil {
err = extractError(response.ErrorResponse)
if err := n.enc.Request(string(instID)+methodPing, ping{}, &response, timeout); err != nil {
if err == nats.ErrTimeout {
err = platform.UnavailableError(err)
}
return err
}
return err
return extractError(response.ErrorResponse)
}

// ErrorResponse is for dropping into responses so they have
Expand Down

0 comments on commit ef6e60a

Please sign in to comment.