Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/rogchap/wombat
Browse files Browse the repository at this point in the history
  • Loading branch information
rogchap committed Apr 26, 2021
2 parents bcde752 + 73941a3 commit b107d60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,3 @@ jobs:
asset_path: Wombat_${{ steps.version.outputs.tag }}_Windows_x86_64.zip/Wombat_${{ steps.version.outputs.tag }}_Windows_x86_64.zip
asset_name: Wombat_${{ steps.version.outputs.tag }}_Windows_x86_64.zip
asset_content_type: application/octet-stream

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Support export/import request to/from grpcurl command. Thanks to [@devkanro](https://github.com/devkanro) & [@iou90](https://github.com/iou90)
- Immediately retry a disconnected grpc connection before attempting to send a request. Thanks to [@aschey](https://github.com/aschey)

### Fixed
- Update dependencies to fix an issue with newer versions of webkit2gtk. Thanks to [@aschey](https://github.com/aschey)
Expand Down
19 changes: 17 additions & 2 deletions internal/app/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,19 @@ func fieldViewsFromDesc(fds protoreflect.FieldDescriptors, isOneof bool, cd *cyc
return fields, nil
}

func (a *api) RetryConnection() {
state := a.client.conn.GetState()
if state == connectivity.TransientFailure || state == connectivity.Shutdown {
// State is currently disconnected. Do a quick retry in case the server restarted recently.
a.client.conn.ResetConnectBackoff()
stateChanged := make(chan bool)
waitForStateChange := func(data ...interface{}) { stateChanged <- true }
a.runtime.Events.Once(eventClientStateChanged, waitForStateChange)
// Wait for at least one retry to complete before continuing
<-stateChanged
}
}

func (a *api) Send(method string, rawJSON []byte, rawHeaders interface{}) (rerr error) {
defer func() {
if rerr != nil {
Expand All @@ -718,6 +731,8 @@ func (a *api) Send(method string, rawJSON []byte, rawHeaders interface{}) (rerr
}
}()

a.RetryConnection()

md, err := a.getMethodDesc(method)
if err != nil {
return err
Expand Down Expand Up @@ -1033,8 +1048,8 @@ func (a *api) ImportCommand(kind string, command string) (rerr error) {
return err
}

return a.emitServicesSelect("/" + args.Method, args.Data, args.Metadata)
return a.emitServicesSelect("/"+args.Method, args.Data, args.Metadata)
}

return nil
}
}

0 comments on commit b107d60

Please sign in to comment.