relax-rb 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62a0df14669076e9278da5f3892d2c46d38dd98c
4
- data.tar.gz: ab67305cef13e1ffa4bf6b5f820dd955f083958f
3
+ metadata.gz: c6d51b5335245cac025f3922d4c94439249d746c
4
+ data.tar.gz: 3b8915bd4a40f0644efcd4d3dc12d6ded8ba6f84
5
5
  SHA512:
6
- metadata.gz: 177266e7d0c87c2d5afca62eef12199e6c1eec813855d54a2e0d5dff7b6489f22d086239e4acb229b87b5a1b312b1143180c2fd9171c0b2b087de767e4de7969
7
- data.tar.gz: 793595b3199140ccd292dff7a4baeb631896e7a60bdaa50f882436452448c77613c2fd2dbbb39c8888e1c8c475a72c5954de04a1622ea13437e18dcdf31e2e10
6
+ metadata.gz: a347952b9f075c2b812de5427650e808c21ab11d489f56dcd898d3a4d9c18d0122c031e80118dc5433de36dbcf2db6d3b82ff9910c310573567b8eaddb761158
7
+ data.tar.gz: 7960faa70a9029b8fb7a9a14ee97e5ce933c14ec8f9f93b98416baa04db96422feade73e44f57b4d2a25febf2a962afb3733d32b106846e85f18501e4e8f840d
data/lib/relax/base.rb CHANGED
@@ -9,7 +9,9 @@ module Relax
9
9
  redis_uri = URI.parse("redis://localhost:6379")
10
10
  end
11
11
 
12
- @@redis ||= Redis.new(url: redis_uri, db: 0)
12
+ @@conn ||= ConnectionPool.new(timeout: 1, size: 5) do
13
+ Redis.new(url: redis_uri, db: 0)
14
+ end
13
15
  end
14
16
  end
15
17
  end
data/lib/relax/bot.rb CHANGED
@@ -12,9 +12,11 @@ module Relax
12
12
  raise BotsPubsubNotSetError, "Environment Variable RELAX_BOTS_PUBSUB is not set"
13
13
  end
14
14
 
15
- redis.multi do
16
- redis.hset(relax_bots_key, team_uid, {team_id: team_uid, token: token}.to_json)
17
- redis.publish(relax_bots_pubsub, {type: 'team_added', team_id: team_uid}.to_json)
15
+ redis.with do |conn|
16
+ conn.multi do
17
+ conn.hset(relax_bots_key, team_uid, {team_id: team_uid, token: token}.to_json)
18
+ conn.publish(relax_bots_pubsub, {type: 'team_added', team_id: team_uid}.to_json)
19
+ end
18
20
  end
19
21
  end
20
22
 
@@ -15,7 +15,7 @@ module Relax
15
15
  self.log("Listening for Relax Events...")
16
16
 
17
17
  while true do
18
- queue_name, event_json = redis.blpop(relax_events_queue)
18
+ queue_name, event_json = redis.with { |c| c.blpop(relax_events_queue) }
19
19
 
20
20
  if queue_name == relax_events_queue
21
21
  event = Event.new(JSON.parse(event_json))
data/lib/relax/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Relax
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/relax.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "redis"
2
2
  require "json"
3
+ require "connection_pool"
3
4
 
4
5
  require "relax/version"
5
6
  require "relax/base"
data/relax-rb.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency "redis", "~> 3.2.1"
31
31
  spec.add_dependency "json", "~> 1.8.3"
32
+ spec.add_dependency "connection_pool", "~> 2.2.0"
32
33
 
33
34
  spec.add_development_dependency "bundler", "~> 1.10"
34
35
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relax-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - arunthampi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.8.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: connection_pool
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.2.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement