redis-cluster 1.0.0.pre.rc.1 → 1.0.0.pre.rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd6f66183d627b2454e9e7ba629274ba32a1e78
4
- data.tar.gz: 3519af542e7ed85abb0593bccbb9dba0f451762d
3
+ metadata.gz: 87ff565ce3c8c2268935d56508aa5b5896a3f8eb
4
+ data.tar.gz: 474dd846727e7c52d56fea04333e0d35223026b0
5
5
  SHA512:
6
- metadata.gz: f8c89e900077de31226af2067769576136735356388dd69d4f528697a3f67d4e2fa6685def24ba27a24a5f57992cf91eca2002a61c49e9baa4c94ae7c582c100
7
- data.tar.gz: 74921e593e6a1338e2bcc382f6e27718b3d8a4808dd7ed8d589d539b3d3f9fce72ccac5bd0f0d002f1b142b2b04a0fe2ef3966f77fa92a68165ed1a2c01b0d6d
6
+ metadata.gz: 37eb706afca0090ea9a43bcf769ac86a06d2c423b8f20ebd9aa68a7631076ed165ab83ddc3fec015a92a3499b65f825c90ac453c7d8d74fa1bbee38e2c975235
7
+ data.tar.gz: b794604db2cf25cffbfbc92fd8120f9a7801f923f54ed077549d96f77a368f49b04dd8da33a60bb9c497a61a365aafb4c913a011e0f00f4445f2c140ebb3bcef
data/README.md CHANGED
@@ -100,8 +100,9 @@ Option for RedisCluster.
100
100
  Middlewares are hooks that RedisCluster provide to observe RedisCluster events. To register a middlewares, provide callable object (object that respond to call)
101
101
  or give block in register method. Middlewares must give block result as return value.
102
102
  ````ruby
103
+ # Using callable
103
104
  class Callable
104
- call
105
+ def call
105
106
  start = Time.now
106
107
  yield
107
108
  rescue StandardError => e
@@ -112,6 +113,7 @@ class Callable
112
113
  end
113
114
  redis.middlewares.register(:commit, Callable.new)
114
115
 
116
+ # Using proc
115
117
  redis.middlewares.register(:commit) do |*args, &block|
116
118
  begin
117
119
  res = block.call
@@ -126,21 +128,23 @@ end
126
128
 
127
129
  Currently there are 3 events that RedisCluster publish.
128
130
  - `:commit`
129
- RedisCluster will fire `:commit` events when RedisCluster::Client call redis server. It give queue of command as arguments.
131
+ RedisCluster will fire `:commit` events when RedisCluster::Client call redis server. It give `RedisCluster::Client` as arguments.
130
132
  ````ruby
131
- redis.middlewares.register(:commit) do |queues, &block|
133
+ redis.middlewares.register(:commit) do |client, &block|
132
134
  puts 'this is :commit events'
133
- puts "first command: #{queues.first.first}
134
- puts "last command: #{queues.last.first}
135
+ puts "client url: #{client.url}"
136
+ puts "first command: #{client.queue.first.first}"
137
+ puts "last command: #{client.queue.last.first}"
135
138
  block.call
136
139
  end
137
140
  ````
138
141
  - `:call`
139
- This events is fired when command is issued in RedisCluster client before any load balancing is done. It give call arguments as arguments
142
+ This events is fired when command is issued in RedisCluster client before any load balancing is done. It give `RedisCluster` and `RedisCluster#call` arguments as arguments
140
143
  ````ruby
141
- redis.middlewares.register(:call) do |keys, command, opts = {}, &block|
144
+ redis.middlewares.register(:call) do |client, keys, command, opts = {}, &block|
142
145
  puts "keys to load balance: #{keys}"
143
146
  puts "redis command: #{command.first}"
147
+ puts "in pipelined?: #{client.pipelined?}"
144
148
  block.call
145
149
  end
146
150
  redis.get('something')
@@ -149,9 +153,9 @@ Currently there are 3 events that RedisCluster publish.
149
153
  # redis command: get
150
154
  ````
151
155
  - `:pipelined`
152
- This events is fired when pipelined method is called from redis client. It does not give any arguments
156
+ This events is fired when pipelined method is called from redis client. It does give `RedisCluster` as arguments
153
157
  ````ruby
154
- redis.middlewares.register(:pipelined) do |&block|
158
+ redis.middlewares.register(:pipelined) do |client, &block|
155
159
  puts 'pipelined is called'
156
160
  block.call
157
161
  end
data/lib/redis-cluster.rb CHANGED
@@ -47,13 +47,13 @@ class RedisCluster
47
47
  end
48
48
 
49
49
  def call(*args, &block)
50
- middlewares.invoke(:call, *args) do
50
+ middlewares.invoke(:call, self, *args) do
51
51
  _call(*args, &block)
52
52
  end
53
53
  end
54
54
 
55
55
  def pipelined(*args, &block)
56
- middlewares.invoke(:pipelined, *args) do
56
+ middlewares.invoke(:pipelined, self, *args) do
57
57
  _pipelined(*args, &block)
58
58
  end
59
59
  end
@@ -42,7 +42,7 @@ class RedisCluster
42
42
  def commit
43
43
  return _commit unless middlewares
44
44
 
45
- middlewares.invoke(:commit, queue.dup) do
45
+ middlewares.invoke(:commit, self) do
46
46
  _commit
47
47
  end
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RedisCluster
4
- VERSION = '1.0.0-rc.1'
4
+ VERSION = '1.0.0-rc.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.rc.1
4
+ version: 1.0.0.pre.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bukalapak