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

Fix #676 Add an easier way to access Events API retry info #677

Merged
merged 2 commits into from
Jan 28, 2021

Conversation

seratch
Copy link
Member

@seratch seratch commented Jan 28, 2021

This pull request enables Events API listeners to access x-slack-retry-num / x-slack-retry-reason header values (retry_attempt / retry_reason in Socket Mode) in the following way.

app.event(AppMentionEvent.class, (req, ctx) -> {
  Integer num = ctx.getRetryNum(); // 0-3
  String reason = ctx.getRetryReason(); // timeout, http_error etc
  return ctx.ack();
});

Fixes #676

Category (place an x in each of the [ ])

  • bolt (Bolt for Java)
  • bolt-socket-mode (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to the those rules.

@seratch seratch added enhancement M-T: A feature request for new functionality project:bolt labels Jan 28, 2021
@seratch seratch added this to the 1.6.0 milestone Jan 28, 2021
@seratch seratch self-assigned this Jan 28, 2021
@@ -15,4 +15,11 @@

private String channelId;

// X-Slack-Retry-Num: 2 in HTTP Mode
// "retry_attempt": 0, in Socket Mode
Copy link
Member Author

Choose a reason for hiding this comment

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

@stevengill @mwbrooks
The names are a bit different here. Do we prefer retryAttempt? I personally feel retryNum is fine as it's a number.

Copy link
Member

Choose a reason for hiding this comment

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

I'd personally prefer to keep the names consistent between the headers and variables. It makes it easier to understand that the two are identical and intended to match. So I'd lean toward retryNum as well.

@codecov
Copy link

codecov bot commented Jan 28, 2021

Codecov Report

Merging #677 (8c6a5e5) into main (10165f6) will increase coverage by 0.06%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #677      +/-   ##
============================================
+ Coverage     78.79%   78.86%   +0.06%     
- Complexity     3052     3060       +8     
============================================
  Files           331      331              
  Lines          8830     8847      +17     
  Branches        833      839       +6     
============================================
+ Hits           6958     6977      +19     
+ Misses         1364     1363       -1     
+ Partials        508      507       -1     
Impacted Files Coverage Δ Complexity Δ
...m/slack/api/bolt/request/builtin/EventRequest.java 77.58% <83.33%> (+1.49%) 17.00 <0.00> (+4.00)
...t/socket_mode/request/SocketModeRequestParser.java 100.00% <100.00%> (ø) 6.00 <0.00> (+2.00)
...i/methods/metrics/impl/MemoryMetricsDatastore.java 92.95% <0.00%> (+1.40%) 42.00% <0.00%> (+1.00%)
.../com/slack/api/bolt/socket_mode/SocketModeApp.java 81.66% <0.00%> (+3.33%) 13.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10165f6...8c6a5e5. Read the comment docs.

@@ -15,4 +15,11 @@

private String channelId;

// X-Slack-Retry-Num: 2 in HTTP Mode
// "retry_attempt": 0, in Socket Mode
Copy link
Member

Choose a reason for hiding this comment

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

I'd personally prefer to keep the names consistent between the headers and variables. It makes it easier to understand that the two are identical and intended to match. So I'd lean toward retryNum as well.

@seratch seratch merged commit 841bffb into slackapi:main Jan 28, 2021
@seratch seratch deleted the issue-676-event-retries branch January 28, 2021 22:19
@sagar-ranglani
Copy link

Any plans on adding this for boltjs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality project:bolt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an easier way to access X-Slack-Retry-Num / X-Slack-Retry-Reason in Bolt apps
3 participants