Skip to content

Commit

Permalink
Merge pull request #93 from dblock/remove-ping
Browse files Browse the repository at this point in the history
Removed ping worker.
  • Loading branch information
dblock authored Feb 25, 2019
2 parents 6556fe2 + fed0db8 commit 62d58a2
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 359 deletions.
7 changes: 1 addition & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-09-08 18:09:56 -0400 using RuboCop version 0.58.2.
# on 2019-02-25 14:24:34 -0500 using RuboCop version 0.58.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -16,11 +16,6 @@ Layout/IndentHeredoc:
- 'sample_apps/sample_app_activerecord/commands/help.rb'
- 'sample_apps/sample_app_mongoid/commands/help.rb'

# Offense count: 1
Lint/HandleExceptions:
Exclude:
- 'lib/slack-ruby-bot-server/ping.rb'

# Offense count: 3
# Configuration parameters: Blacklist.
# Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### Changelog

#### 0.8.4 (Next)
#### 0.9.0 (Next)

* [#93](https://github.com/slack-ruby/slack-ruby-bot-server/pull/93): Removed ping worker in favor of slack-ruby-client lower level ping - [@dblock](https://github.com/dblock).
* Your contribution here.

#### 0.8.3 (2019/01/17)
Expand Down
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,6 @@ SlackRubyBotServer.configure do |config|
end
```

#### Ping Worker

Each `SlackRubyBotServer::Server` instance will start a ping worker that will periodically check the online status of the bot via the Slack web [auth.test](https://api.slack.com/methods/auth.test) and [users.getPresence](https://api.slack.com/methods/users.getPresence) APIs, and will forcefully close the connection if the bot goes offline, causing an automatic reconnect.

You can configure the ping interval, number of retries before restart, and disable the ping worker entirely.

```ruby
SlackRubyBotServer.configure do |config|
config.ping = {
enabled: true, # set to false to disable the ping worker
ping_interval: 30, # interval in seconds
retry_count: 3 # number of unsuccessful retries until a restart
}
end
```

### Access Tokens

By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores a `bot_access_token` that grants a certain amount of privileges to the bot user as described in [Slack OAuth Docs](https://api.slack.com/docs/oauth). You may not want a bot user at all, or may require different auth scopes, such as `users.profile:read` to access user profile information via `Slack::Web::Client#users_profile_get`. To obtain the non-bot access token make the following changes.
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Upgrading Slack-Ruby-Bot-Server
===============================

### Upgrading to >= 0.9.0

### Removed Ping Worker

The ping worker that was added in 0.7.0 has been removed in favor of a lower level implementation in slack-ruby-client. Remove any references to `ping` options.

See [slack-ruby-client#226](https://github.com/slack-ruby/slack-ruby-client/pull/226) for more information.

### Upgrading to >= 0.8.0

### Different Asynchronous I/O Library
Expand Down
1 change: 0 additions & 1 deletion lib/slack-ruby-bot-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require 'grape-swagger'
require 'slack-ruby-bot'
require 'slack-ruby-bot-server/server'
require 'slack-ruby-bot-server/ping'
require 'slack-ruby-bot-server/config'

require 'slack-ruby-bot-server/ext'
Expand Down
2 changes: 0 additions & 2 deletions lib/slack-ruby-bot-server/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ module Config
extend self

attr_accessor :server_class
attr_accessor :ping
attr_accessor :database_adapter

def reset!
self.ping = nil
self.server_class = SlackRubyBotServer::Server
self.database_adapter = if defined?(::Mongoid)
:mongoid
Expand Down
149 changes: 0 additions & 149 deletions lib/slack-ruby-bot-server/ping.rb

This file was deleted.

12 changes: 0 additions & 12 deletions lib/slack-ruby-bot-server/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Server < SlackRubyBot::Server
def initialize(attrs = {})
attrs = attrs.dup
@team = attrs.delete(:team)
@ping_options = attrs.delete(:ping) || {}
raise 'Missing team' unless @team
attrs[:token] = @team.token
super(attrs)
Expand All @@ -24,19 +23,8 @@ def restart!(wait = 1)

private

attr_reader :ping_options

def create_ping
return unless !ping_options.key?(:enabled) || ping_options[:enabled]
SlackRubyBotServer::Ping.new(client, ping_options)
end

def open!
client.owner = team
client.on :open do |_event|
worker = create_ping
worker.start! if worker
end
end
end
end
1 change: 0 additions & 1 deletion lib/slack-ruby-bot-server/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def start!(team)
run_callbacks :starting, team
logger.info "Starting team #{team}."
options = { team: team }
options[:ping] = SlackRubyBotServer::Config.ping if SlackRubyBotServer::Config.ping
server = SlackRubyBotServer::Config.server_class.new(options)
start_server! team, server
run_callbacks :started, team
Expand Down
2 changes: 1 addition & 1 deletion lib/slack-ruby-bot-server/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SlackRubyBotServer
VERSION = '0.8.4'.freeze
VERSION = '0.9.0'.freeze
end
2 changes: 1 addition & 1 deletion slack-ruby-bot-server.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
spec.add_dependency 'rack-cors'
spec.add_dependency 'rack-rewrite'
spec.add_dependency 'rack-server-pages'
spec.add_dependency 'slack-ruby-bot'
spec.add_dependency 'slack-ruby-bot', '>= 0.12.0'
spec.add_dependency 'unicorn'
end
Loading

0 comments on commit 62d58a2

Please sign in to comment.