Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[socketmode] Add methods with passing context #923

Merged
merged 5 commits into from
Apr 18, 2021

Conversation

im-kulikov
Copy link
Contributor

@im-kulikov im-kulikov commented Apr 8, 2021

There's no chance to gracefully shutdown socketmode.Client. (bug?)

  • Add methods with passing context

    • added socketmode.Client.RunContext
    • added socketmode.Client.OpenContext
    • changed socketmode.Client.openAndDial to pass context
    • added test coverage for socketmode.Client.openAndDial
    • added test coverage for socketmode.Client.RunContext
    • added test coverage for socketmode.Client.OpenContext
  • Use DialContext instead of Dial

  • Graceful shutdown websocket.Conn (websocket connection freeze on conn.ReadJSON)

    • returned context errors to stop reconnect
    • closed channel of messages when exit from Client.run
    • closed websocket connection when context canceled
  • mark test only for go 1.13 and higher

  • fix typo in json tag

Pull Request Guidelines

These are recommendations for pull requests.
They are strictly guidelines to help manage expectations.

PR preparation

Run make pr-prep from the root of the repository to run formatting, linting and tests.

Should this be an issue instead
  • is it a convenience method? (no new functionality, streamlines some use case)
  • exposes a previously private type, const, method, etc.
  • is it application specific (caching, retry logic, rate limiting, etc)
  • is it performance related.
API changes

Since API changes have to be maintained they undergo a more detailed review and are more likely to require changes.

  • no tests, if you're adding to the API include at least a single test of the happy case.
  • If you can accomplish your goal without changing the API, then do so.
  • dependency changes. updates are okay. adding/removing need justification.
Examples of API changes that do not meet guidelines:
  • in library cache for users. caches are use case specific.
  • Convenience methods for Sending Messages, update, post, ephemeral, etc. consider opening an issue instead.

- added socketmode.Client.RunContext
- added socketmode.Client.OpenContext
- changed socketmode.Client.openAndDial to pass context
- added test coverage for socketmode.Client.openAndDial
- added test coverage for socketmode.Client.RunContext
- added test coverage for socketmode.Client.OpenContext
@im-kulikov
Copy link
Contributor Author

test failed only for go1.12 (go1.13 is minimal according to go.mod)

websocket connection freeze on conn.ReadJSON

- returned context errors to stop reconnect
- closed channel of messages when exit from Client.run
- closed websocket connection when context canceled
@kanata2
Copy link
Member

kanata2 commented Apr 17, 2021

Thanks! (I'm planning to drop support of Go 1.12 in v0.9.0.)

@im-kulikov
Copy link
Contributor Author

Is there any what I can do to be merged?

@kanata2 kanata2 added this to the v0.9.0 milestone Apr 18, 2021
Copy link
Member

@kanata2 kanata2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) Thanks!

@kanata2 kanata2 merged commit 24ed201 into slack-go:master Apr 18, 2021
@im-kulikov im-kulikov deleted the socketmode-pass-context branch April 19, 2021 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants