Skip to content

Commit d1aa8a4

Browse files
committed
Replace celluloid-io with async-websocket.
1 parent 74a5164 commit d1aa8a4

File tree

13 files changed

+42
-37
lines changed

13 files changed

+42
-37
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2018-08-22 08:29:35 -0400 using RuboCop version 0.58.2.
3+
# on 2018-08-27 14:23:13 +0200 using RuboCop version 0.58.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
### Changelog
22

3-
#### 0.7.1 (Next)
3+
#### 0.8.0 (Next)
44

5+
* [#75](https://github.com/slack-ruby/slack-ruby-bot-server/pull/75): Default to `async-websocket` instead of `celluloid-io` - [@dblock](https://github.com/dblock).
56
* Your contribution here.
67

78
#### 0.7.0 (8/22/2018)

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ else
1616
warn "Invalid ENV['DATABASE_ADAPTER']: #{ENV['DATABASE_ADAPTER']}."
1717
end
1818

19+
gem 'slack-ruby-bot', github: 'dblock/slack-ruby-bot', branch: 'async'
20+
gem 'slack-ruby-client', github: 'dblock/slack-ruby-client', branch: 'async'
21+
1922
gemspec
2023

2124
group :development, :test do

UPGRADING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Upgrading Slack-Ruby-Bot-Server
22
===============================
33

4+
### Upgrading to >= 0.8.0
5+
6+
### Different Asynchronous I/O Library
7+
8+
The library now uses [async-websocket](https://github.com/socketry/async-websocket) instead of [celluloid-io](https://github.com/celluloid/celluloid-io). If your application is built on Celluloid you may need to make changes and use `Async::Reactor.run` and the likes.
9+
10+
See [#75](https://github.com/slack-ruby/slack-ruby-bot-server/pull/75) for more information.
11+
412
### Upgrading to >= 0.7.0
513

614
#### New Ping Worker

lib/slack-ruby-bot-server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'celluloid/current'
1+
require 'async/websocket'
22

33
require 'grape-swagger'
44
require 'slack-ruby-bot'

lib/slack-ruby-bot-server/ping.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module SlackRubyBotServer
22
class Ping
3-
include Celluloid
4-
53
attr_reader :client
64
attr_reader :options
75
attr_reader :error_count
@@ -13,8 +11,11 @@ def initialize(client, options = {})
1311
end
1412

1513
def start!
16-
every ping_interval do
17-
check!
14+
::Async::Reactor.run do |task|
15+
loop do
16+
task.sleep ping_interval
17+
break unless check!
18+
end
1819
end
1920
end
2021

@@ -23,16 +24,18 @@ def start!
2324
def check!
2425
if online?
2526
@error_count = 0
27+
true
2628
else
2729
down!
2830
end
2931
rescue StandardError => e
3032
case e.message
3133
when 'account_inactive', 'invalid_auth' then
3234
logger.warn "Error pinging team #{owner.id}: #{e.message}, terminating."
33-
terminate
35+
false
3436
else
3537
logger.warn "Error pinging team #{owner.id}: #{e.message}."
38+
true
3639
end
3740
end
3841

@@ -51,14 +54,14 @@ def presence
5154
def down!
5255
logger.warn "DOWN: #{owner}, #{retries_left} #{retries_left == 1 ? 'retry' : 'retries'} left"
5356
@error_count += 1
54-
return if retries_left?
57+
return true if retries_left?
5558
restart!
59+
false
5660
end
5761

5862
def restart!
5963
logger.warn "RESTART: #{owner}"
60-
driver.emit(:close, WebSocket::Driver::CloseEvent.new(1001, 'bot offline')) if driver
61-
terminate
64+
driver.close if driver
6265
end
6366

6467
def ping_interval
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SlackRubyBotServer
2-
VERSION = '0.7.1'.freeze
2+
VERSION = '0.8.0'.freeze
33
end

sample_apps/sample_app_activerecord/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ gem 'pg'
77
gem 'rack-server-pages'
88
gem 'rack-test'
99
gem 'slack-ruby-bot-server', path: '../../'
10+
gem 'slack-ruby-client', github: 'dblock/slack-ruby-client', branch: 'async'
1011

1112
group :development, :test do
1213
gem 'standalone_migrations', '~> 5.2'

sample_apps/sample_app_activerecord/config.ru

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ require 'yaml'
77

88
ActiveRecord::Base.establish_connection(YAML.load_file('config/postgresql.yml')[ENV['RACK_ENV']])
99

10-
if ENV['RACK_ENV'] == 'development'
11-
puts 'Loading NewRelic in developer mode ...'
12-
require 'new_relic/rack/developer_mode'
13-
use NewRelic::Rack::DeveloperMode
14-
end
15-
1610
NewRelic::Agent.manual_start
1711

1812
SlackRubyBotServer::App.instance.prepare!

sample_apps/sample_app_mongoid/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
33
gem 'mongoid'
44
gem 'newrelic-slack-ruby-bot'
55
gem 'slack-ruby-bot-server', path: '../../'
6+
gem 'slack-ruby-client', github: 'dblock/slack-ruby-client', branch: 'async'
67

78
gem 'kaminari-mongoid'
89
gem 'mongoid-scroll'

0 commit comments

Comments
 (0)