redis-client 0.2.1 → 0.5.0
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 +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +2 -3
- data/README.md +71 -8
- data/Rakefile +43 -23
- data/lib/redis_client/command_builder.rb +91 -0
- data/lib/redis_client/config.rb +19 -50
- data/lib/redis_client/connection_mixin.rb +40 -0
- data/lib/redis_client/decorator.rb +84 -0
- data/lib/redis_client/pooled.rb +38 -30
- data/lib/redis_client/ruby_connection/buffered_io.rb +153 -0
- data/lib/redis_client/{resp3.rb → ruby_connection/resp3.rb} +0 -26
- data/lib/redis_client/{connection.rb → ruby_connection.rb} +26 -31
- data/lib/redis_client/version.rb +1 -1
- data/lib/redis_client.rb +183 -36
- data/redis-client.gemspec +2 -4
- metadata +12 -59
- data/.rubocop.yml +0 -190
- data/ext/redis_client/hiredis/export.clang +0 -2
- data/ext/redis_client/hiredis/export.gcc +0 -7
- data/ext/redis_client/hiredis/extconf.rb +0 -61
- data/ext/redis_client/hiredis/hiredis_connection.c +0 -708
- data/ext/redis_client/hiredis/vendor/.gitignore +0 -9
- data/ext/redis_client/hiredis/vendor/.travis.yml +0 -131
- data/ext/redis_client/hiredis/vendor/CHANGELOG.md +0 -364
- data/ext/redis_client/hiredis/vendor/CMakeLists.txt +0 -165
- data/ext/redis_client/hiredis/vendor/COPYING +0 -29
- data/ext/redis_client/hiredis/vendor/Makefile +0 -308
- data/ext/redis_client/hiredis/vendor/README.md +0 -664
- data/ext/redis_client/hiredis/vendor/adapters/ae.h +0 -130
- data/ext/redis_client/hiredis/vendor/adapters/glib.h +0 -156
- data/ext/redis_client/hiredis/vendor/adapters/ivykis.h +0 -84
- data/ext/redis_client/hiredis/vendor/adapters/libev.h +0 -179
- data/ext/redis_client/hiredis/vendor/adapters/libevent.h +0 -175
- data/ext/redis_client/hiredis/vendor/adapters/libuv.h +0 -117
- data/ext/redis_client/hiredis/vendor/adapters/macosx.h +0 -115
- data/ext/redis_client/hiredis/vendor/adapters/qt.h +0 -135
- data/ext/redis_client/hiredis/vendor/alloc.c +0 -86
- data/ext/redis_client/hiredis/vendor/alloc.h +0 -91
- data/ext/redis_client/hiredis/vendor/appveyor.yml +0 -24
- data/ext/redis_client/hiredis/vendor/async.c +0 -887
- data/ext/redis_client/hiredis/vendor/async.h +0 -147
- data/ext/redis_client/hiredis/vendor/async_private.h +0 -75
- data/ext/redis_client/hiredis/vendor/dict.c +0 -352
- data/ext/redis_client/hiredis/vendor/dict.h +0 -126
- data/ext/redis_client/hiredis/vendor/fmacros.h +0 -12
- data/ext/redis_client/hiredis/vendor/hiredis-config.cmake.in +0 -13
- data/ext/redis_client/hiredis/vendor/hiredis.c +0 -1174
- data/ext/redis_client/hiredis/vendor/hiredis.h +0 -336
- data/ext/redis_client/hiredis/vendor/hiredis.pc.in +0 -12
- data/ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in +0 -13
- data/ext/redis_client/hiredis/vendor/hiredis_ssl.h +0 -157
- data/ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in +0 -12
- data/ext/redis_client/hiredis/vendor/net.c +0 -612
- data/ext/redis_client/hiredis/vendor/net.h +0 -56
- data/ext/redis_client/hiredis/vendor/read.c +0 -739
- data/ext/redis_client/hiredis/vendor/read.h +0 -129
- data/ext/redis_client/hiredis/vendor/sds.c +0 -1289
- data/ext/redis_client/hiredis/vendor/sds.h +0 -278
- data/ext/redis_client/hiredis/vendor/sdsalloc.h +0 -44
- data/ext/redis_client/hiredis/vendor/sockcompat.c +0 -248
- data/ext/redis_client/hiredis/vendor/sockcompat.h +0 -92
- data/ext/redis_client/hiredis/vendor/ssl.c +0 -544
- data/ext/redis_client/hiredis/vendor/test.c +0 -1401
- data/ext/redis_client/hiredis/vendor/test.sh +0 -78
- data/ext/redis_client/hiredis/vendor/win32.h +0 -56
- data/lib/redis_client/buffered_io.rb +0 -151
- data/lib/redis_client/hiredis_connection.rb +0 -80
    
        data/lib/redis_client.rb
    CHANGED
    
    | @@ -1,12 +1,57 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            +
            require "set"
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            require "redis_client/version"
         | 
| 6 | 
            +
            require "redis_client/command_builder"
         | 
| 4 7 | 
             
            require "redis_client/config"
         | 
| 5 8 | 
             
            require "redis_client/sentinel_config"
         | 
| 6 | 
            -
            require "redis_client/connection"
         | 
| 7 9 | 
             
            require "redis_client/middlewares"
         | 
| 8 10 |  | 
| 9 11 | 
             
            class RedisClient
         | 
| 12 | 
            +
              @driver_definitions = {}
         | 
| 13 | 
            +
              @drivers = {}
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              @default_driver = nil
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              class << self
         | 
| 18 | 
            +
                def register_driver(name, &block)
         | 
| 19 | 
            +
                  @driver_definitions[name] = block
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def driver(name)
         | 
| 23 | 
            +
                  return name if name.is_a?(Class)
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  name = name.to_sym
         | 
| 26 | 
            +
                  unless @driver_definitions.key?(name)
         | 
| 27 | 
            +
                    raise ArgumentError, "Unknown driver #{name.inspect}, expected one of: `#{@driver_definitions.keys.inspect}`"
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  @drivers[name] ||= @driver_definitions[name]&.call
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def default_driver
         | 
| 34 | 
            +
                  unless @default_driver
         | 
| 35 | 
            +
                    @driver_definitions.each_key do |name|
         | 
| 36 | 
            +
                      if @default_driver = driver(name)
         | 
| 37 | 
            +
                        break
         | 
| 38 | 
            +
                      end
         | 
| 39 | 
            +
                    rescue LoadError
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                  @default_driver
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def default_driver=(name)
         | 
| 46 | 
            +
                  @default_driver = driver(name)
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              register_driver :ruby do
         | 
| 51 | 
            +
                require "redis_client/ruby_connection"
         | 
| 52 | 
            +
                RubyConnection
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 10 55 | 
             
              module Common
         | 
| 11 56 | 
             
                attr_reader :config, :id
         | 
| 12 57 | 
             
                attr_accessor :connect_timeout, :read_timeout, :write_timeout
         | 
| @@ -23,6 +68,7 @@ class RedisClient | |
| 23 68 | 
             
                  @connect_timeout = connect_timeout
         | 
| 24 69 | 
             
                  @read_timeout = read_timeout
         | 
| 25 70 | 
             
                  @write_timeout = write_timeout
         | 
| 71 | 
            +
                  @command_builder = config.command_builder
         | 
| 26 72 | 
             
                end
         | 
| 27 73 |  | 
| 28 74 | 
             
                def timeout=(timeout)
         | 
| @@ -32,6 +78,8 @@ class RedisClient | |
| 32 78 |  | 
| 33 79 | 
             
              Error = Class.new(StandardError)
         | 
| 34 80 |  | 
| 81 | 
            +
              UnsupportedServer = Class.new(Error)
         | 
| 82 | 
            +
             | 
| 35 83 | 
             
              ConnectionError = Class.new(Error)
         | 
| 36 84 |  | 
| 37 85 | 
             
              FailoverError = Class.new(ConnectionError)
         | 
| @@ -43,6 +91,8 @@ class RedisClient | |
| 43 91 | 
             
              CheckoutTimeoutError = Class.new(ConnectTimeoutError)
         | 
| 44 92 |  | 
| 45 93 | 
             
              class CommandError < Error
         | 
| 94 | 
            +
                attr_reader :command
         | 
| 95 | 
            +
             | 
| 46 96 | 
             
                class << self
         | 
| 47 97 | 
             
                  def parse(error_message)
         | 
| 48 98 | 
             
                    code = error_message.split(' ', 2).first
         | 
| @@ -50,14 +100,22 @@ class RedisClient | |
| 50 100 | 
             
                    klass.new(error_message)
         | 
| 51 101 | 
             
                  end
         | 
| 52 102 | 
             
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                def _set_command(command)
         | 
| 105 | 
            +
                  @command = command
         | 
| 106 | 
            +
                end
         | 
| 53 107 | 
             
              end
         | 
| 54 108 |  | 
| 55 109 | 
             
              AuthenticationError = Class.new(CommandError)
         | 
| 56 110 | 
             
              PermissionError = Class.new(CommandError)
         | 
| 111 | 
            +
              ReadOnlyError = Class.new(CommandError)
         | 
| 112 | 
            +
              WrongTypeError = Class.new(CommandError)
         | 
| 57 113 |  | 
| 58 114 | 
             
              CommandError::ERRORS = {
         | 
| 59 115 | 
             
                "WRONGPASS" => AuthenticationError,
         | 
| 60 116 | 
             
                "NOPERM" => PermissionError,
         | 
| 117 | 
            +
                "READONLY" => ReadOnlyError,
         | 
| 118 | 
            +
                "WRONGTYPE" => WrongTypeError,
         | 
| 61 119 | 
             
              }.freeze
         | 
| 62 120 |  | 
| 63 121 | 
             
              class << self
         | 
| @@ -90,6 +148,11 @@ class RedisClient | |
| 90 148 | 
             
                @disable_reconnection = false
         | 
| 91 149 | 
             
              end
         | 
| 92 150 |  | 
| 151 | 
            +
              def inspect
         | 
| 152 | 
            +
                id_string = " id=#{id}" if id
         | 
| 153 | 
            +
                "#<#{self.class.name} #{config.server_url}#{id_string}>"
         | 
| 154 | 
            +
              end
         | 
| 155 | 
            +
             | 
| 93 156 | 
             
              def size
         | 
| 94 157 | 
             
                1
         | 
| 95 158 | 
             
              end
         | 
| @@ -115,67 +178,89 @@ class RedisClient | |
| 115 178 | 
             
              end
         | 
| 116 179 |  | 
| 117 180 | 
             
              def pubsub
         | 
| 118 | 
            -
                sub = PubSub.new(ensure_connected)
         | 
| 181 | 
            +
                sub = PubSub.new(ensure_connected, @command_builder)
         | 
| 119 182 | 
             
                @raw_connection = nil
         | 
| 120 183 | 
             
                sub
         | 
| 121 184 | 
             
              end
         | 
| 122 185 |  | 
| 123 | 
            -
              def call(*command)
         | 
| 124 | 
            -
                command =  | 
| 125 | 
            -
                ensure_connected do |connection|
         | 
| 186 | 
            +
              def call(*command, **kwargs)
         | 
| 187 | 
            +
                command = @command_builder.generate!(command, kwargs)
         | 
| 188 | 
            +
                result = ensure_connected do |connection|
         | 
| 126 189 | 
             
                  Middlewares.call(command, config) do
         | 
| 127 190 | 
             
                    connection.call(command, nil)
         | 
| 128 191 | 
             
                  end
         | 
| 129 192 | 
             
                end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                if block_given?
         | 
| 195 | 
            +
                  yield result
         | 
| 196 | 
            +
                else
         | 
| 197 | 
            +
                  result
         | 
| 198 | 
            +
                end
         | 
| 130 199 | 
             
              end
         | 
| 131 200 |  | 
| 132 | 
            -
              def call_once(*command)
         | 
| 133 | 
            -
                command =  | 
| 134 | 
            -
                ensure_connected(retryable: false) do |connection|
         | 
| 201 | 
            +
              def call_once(*command, **kwargs)
         | 
| 202 | 
            +
                command = @command_builder.generate!(command, kwargs)
         | 
| 203 | 
            +
                result = ensure_connected(retryable: false) do |connection|
         | 
| 135 204 | 
             
                  Middlewares.call(command, config) do
         | 
| 136 205 | 
             
                    connection.call(command, nil)
         | 
| 137 206 | 
             
                  end
         | 
| 138 207 | 
             
                end
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                if block_given?
         | 
| 210 | 
            +
                  yield result
         | 
| 211 | 
            +
                else
         | 
| 212 | 
            +
                  result
         | 
| 213 | 
            +
                end
         | 
| 139 214 | 
             
              end
         | 
| 140 215 |  | 
| 141 | 
            -
              def blocking_call(timeout, *command)
         | 
| 142 | 
            -
                command =  | 
| 143 | 
            -
                ensure_connected do |connection|
         | 
| 216 | 
            +
              def blocking_call(timeout, *command, **kwargs)
         | 
| 217 | 
            +
                command = @command_builder.generate!(command, kwargs)
         | 
| 218 | 
            +
                result = ensure_connected do |connection|
         | 
| 144 219 | 
             
                  Middlewares.call(command, config) do
         | 
| 145 220 | 
             
                    connection.call(command, timeout)
         | 
| 146 221 | 
             
                  end
         | 
| 147 222 | 
             
                end
         | 
| 223 | 
            +
             | 
| 224 | 
            +
                if block_given?
         | 
| 225 | 
            +
                  yield result
         | 
| 226 | 
            +
                else
         | 
| 227 | 
            +
                  result
         | 
| 228 | 
            +
                end
         | 
| 148 229 | 
             
              end
         | 
| 149 230 |  | 
| 150 | 
            -
              def scan(*args, &block)
         | 
| 231 | 
            +
              def scan(*args, **kwargs, &block)
         | 
| 151 232 | 
             
                unless block_given?
         | 
| 152 | 
            -
                  return to_enum(__callee__, *args)
         | 
| 233 | 
            +
                  return to_enum(__callee__, *args, **kwargs)
         | 
| 153 234 | 
             
                end
         | 
| 154 235 |  | 
| 236 | 
            +
                args = @command_builder.generate!(args, kwargs)
         | 
| 155 237 | 
             
                scan_list(1, ["SCAN", 0, *args], &block)
         | 
| 156 238 | 
             
              end
         | 
| 157 239 |  | 
| 158 | 
            -
              def sscan(key, *args, &block)
         | 
| 240 | 
            +
              def sscan(key, *args, **kwargs, &block)
         | 
| 159 241 | 
             
                unless block_given?
         | 
| 160 | 
            -
                  return to_enum(__callee__, key, *args)
         | 
| 242 | 
            +
                  return to_enum(__callee__, key, *args, **kwargs)
         | 
| 161 243 | 
             
                end
         | 
| 162 244 |  | 
| 245 | 
            +
                args = @command_builder.generate!(args, kwargs)
         | 
| 163 246 | 
             
                scan_list(2, ["SSCAN", key, 0, *args], &block)
         | 
| 164 247 | 
             
              end
         | 
| 165 248 |  | 
| 166 | 
            -
              def hscan(key, *args, &block)
         | 
| 249 | 
            +
              def hscan(key, *args, **kwargs, &block)
         | 
| 167 250 | 
             
                unless block_given?
         | 
| 168 | 
            -
                  return to_enum(__callee__, key, *args)
         | 
| 251 | 
            +
                  return to_enum(__callee__, key, *args, **kwargs)
         | 
| 169 252 | 
             
                end
         | 
| 170 253 |  | 
| 254 | 
            +
                args = @command_builder.generate!(args, kwargs)
         | 
| 171 255 | 
             
                scan_pairs(2, ["HSCAN", key, 0, *args], &block)
         | 
| 172 256 | 
             
              end
         | 
| 173 257 |  | 
| 174 | 
            -
              def zscan(key, *args, &block)
         | 
| 258 | 
            +
              def zscan(key, *args, **kwargs, &block)
         | 
| 175 259 | 
             
                unless block_given?
         | 
| 176 | 
            -
                  return to_enum(__callee__, key, *args)
         | 
| 260 | 
            +
                  return to_enum(__callee__, key, *args, **kwargs)
         | 
| 177 261 | 
             
                end
         | 
| 178 262 |  | 
| 263 | 
            +
                args = @command_builder.generate!(args, kwargs)
         | 
| 179 264 | 
             
                scan_pairs(2, ["ZSCAN", key, 0, *args], &block)
         | 
| 180 265 | 
             
              end
         | 
| 181 266 |  | 
| @@ -190,23 +275,27 @@ class RedisClient | |
| 190 275 | 
             
              end
         | 
| 191 276 |  | 
| 192 277 | 
             
              def pipelined
         | 
| 193 | 
            -
                pipeline = Pipeline.new
         | 
| 278 | 
            +
                pipeline = Pipeline.new(@command_builder)
         | 
| 194 279 | 
             
                yield pipeline
         | 
| 195 280 |  | 
| 196 281 | 
             
                if pipeline._size == 0
         | 
| 197 282 | 
             
                  []
         | 
| 198 283 | 
             
                else
         | 
| 199 | 
            -
                  ensure_connected(retryable: pipeline._retryable?) do |connection|
         | 
| 284 | 
            +
                  results = ensure_connected(retryable: pipeline._retryable?) do |connection|
         | 
| 200 285 | 
             
                    commands = pipeline._commands
         | 
| 201 286 | 
             
                    Middlewares.call_pipelined(commands, config) do
         | 
| 202 287 | 
             
                      connection.call_pipelined(commands, pipeline._timeouts)
         | 
| 203 288 | 
             
                    end
         | 
| 204 289 | 
             
                  end
         | 
| 290 | 
            +
             | 
| 291 | 
            +
                  pipeline._coerce!(results)
         | 
| 205 292 | 
             
                end
         | 
| 206 293 | 
             
              end
         | 
| 207 294 |  | 
| 208 295 | 
             
              def multi(watch: nil, &block)
         | 
| 209 | 
            -
                 | 
| 296 | 
            +
                transaction = nil
         | 
| 297 | 
            +
             | 
| 298 | 
            +
                results = if watch
         | 
| 210 299 | 
             
                  # WATCH is stateful, so we can't reconnect if it's used, the whole transaction
         | 
| 211 300 | 
             
                  # has to be redone.
         | 
| 212 301 | 
             
                  ensure_connected(retryable: false) do |connection|
         | 
| @@ -214,7 +303,7 @@ class RedisClient | |
| 214 303 | 
             
                    begin
         | 
| 215 304 | 
             
                      if transaction = build_transaction(&block)
         | 
| 216 305 | 
             
                        commands = transaction._commands
         | 
| 217 | 
            -
                        Middlewares.call_pipelined(commands, config) do
         | 
| 306 | 
            +
                        results = Middlewares.call_pipelined(commands, config) do
         | 
| 218 307 | 
             
                          connection.call_pipelined(commands, nil)
         | 
| 219 308 | 
             
                        end.last
         | 
| 220 309 | 
             
                      else
         | 
| @@ -239,15 +328,22 @@ class RedisClient | |
| 239 328 | 
             
                    end
         | 
| 240 329 | 
             
                  end
         | 
| 241 330 | 
             
                end
         | 
| 331 | 
            +
             | 
| 332 | 
            +
                if transaction
         | 
| 333 | 
            +
                  transaction._coerce!(results)
         | 
| 334 | 
            +
                else
         | 
| 335 | 
            +
                  results
         | 
| 336 | 
            +
                end
         | 
| 242 337 | 
             
              end
         | 
| 243 338 |  | 
| 244 339 | 
             
              class PubSub
         | 
| 245 | 
            -
                def initialize(raw_connection)
         | 
| 340 | 
            +
                def initialize(raw_connection, command_builder)
         | 
| 246 341 | 
             
                  @raw_connection = raw_connection
         | 
| 342 | 
            +
                  @command_builder = command_builder
         | 
| 247 343 | 
             
                end
         | 
| 248 344 |  | 
| 249 | 
            -
                def call(*command)
         | 
| 250 | 
            -
                  raw_connection.write( | 
| 345 | 
            +
                def call(*command, **kwargs)
         | 
| 346 | 
            +
                  raw_connection.write(@command_builder.generate!(command, kwargs))
         | 
| 251 347 | 
             
                  nil
         | 
| 252 348 | 
             
                end
         | 
| 253 349 |  | 
| @@ -273,20 +369,26 @@ class RedisClient | |
| 273 369 | 
             
              end
         | 
| 274 370 |  | 
| 275 371 | 
             
              class Multi
         | 
| 276 | 
            -
                def initialize
         | 
| 372 | 
            +
                def initialize(command_builder)
         | 
| 373 | 
            +
                  @command_builder = command_builder
         | 
| 277 374 | 
             
                  @size = 0
         | 
| 278 375 | 
             
                  @commands = []
         | 
| 376 | 
            +
                  @blocks = nil
         | 
| 279 377 | 
             
                  @retryable = true
         | 
| 280 378 | 
             
                end
         | 
| 281 379 |  | 
| 282 | 
            -
                def call(*command)
         | 
| 283 | 
            -
                   | 
| 380 | 
            +
                def call(*command, **kwargs, &block)
         | 
| 381 | 
            +
                  command = @command_builder.generate!(command, kwargs)
         | 
| 382 | 
            +
                  (@blocks ||= [])[@commands.size] = block if block_given?
         | 
| 383 | 
            +
                  @commands << command
         | 
| 284 384 | 
             
                  nil
         | 
| 285 385 | 
             
                end
         | 
| 286 386 |  | 
| 287 | 
            -
                def call_once(*command)
         | 
| 387 | 
            +
                def call_once(*command, **kwargs)
         | 
| 388 | 
            +
                  command = @command_builder.generate!(command, kwargs)
         | 
| 288 389 | 
             
                  @retryable = false
         | 
| 289 | 
            -
                  @commands  | 
| 390 | 
            +
                  (@blocks ||= [])[@commands.size] = block if block_given?
         | 
| 391 | 
            +
                  @commands << command
         | 
| 290 392 | 
             
                  nil
         | 
| 291 393 | 
             
                end
         | 
| 292 394 |  | 
| @@ -294,6 +396,10 @@ class RedisClient | |
| 294 396 | 
             
                  @commands
         | 
| 295 397 | 
             
                end
         | 
| 296 398 |  | 
| 399 | 
            +
                def _blocks
         | 
| 400 | 
            +
                  @blocks
         | 
| 401 | 
            +
                end
         | 
| 402 | 
            +
             | 
| 297 403 | 
             
                def _size
         | 
| 298 404 | 
             
                  @commands.size
         | 
| 299 405 | 
             
                end
         | 
| @@ -309,18 +415,39 @@ class RedisClient | |
| 309 415 | 
             
                def _retryable?
         | 
| 310 416 | 
             
                  @retryable
         | 
| 311 417 | 
             
                end
         | 
| 418 | 
            +
             | 
| 419 | 
            +
                def _coerce!(results)
         | 
| 420 | 
            +
                  if results
         | 
| 421 | 
            +
                    results.each_with_index do |result, index|
         | 
| 422 | 
            +
                      if result.is_a?(CommandError)
         | 
| 423 | 
            +
                        result._set_command(@commands[index + 1])
         | 
| 424 | 
            +
                        raise result
         | 
| 425 | 
            +
                      end
         | 
| 426 | 
            +
                    end
         | 
| 427 | 
            +
             | 
| 428 | 
            +
                    @blocks&.each_with_index do |block, index|
         | 
| 429 | 
            +
                      if block
         | 
| 430 | 
            +
                        results[index - 1] = block.call(results[index - 1])
         | 
| 431 | 
            +
                      end
         | 
| 432 | 
            +
                    end
         | 
| 433 | 
            +
                  end
         | 
| 434 | 
            +
             | 
| 435 | 
            +
                  results
         | 
| 436 | 
            +
                end
         | 
| 312 437 | 
             
              end
         | 
| 313 438 |  | 
| 314 439 | 
             
              class Pipeline < Multi
         | 
| 315 | 
            -
                def initialize
         | 
| 440 | 
            +
                def initialize(_command_builder)
         | 
| 316 441 | 
             
                  super
         | 
| 317 442 | 
             
                  @timeouts = nil
         | 
| 318 443 | 
             
                end
         | 
| 319 444 |  | 
| 320 | 
            -
                def blocking_call(timeout, *command)
         | 
| 445 | 
            +
                def blocking_call(timeout, *command, **kwargs)
         | 
| 446 | 
            +
                  command = @command_builder.generate!(command, kwargs)
         | 
| 321 447 | 
             
                  @timeouts ||= []
         | 
| 322 448 | 
             
                  @timeouts[@commands.size] = timeout
         | 
| 323 | 
            -
                  @commands  | 
| 449 | 
            +
                  (@blocks ||= [])[@commands.size] = block if block_given?
         | 
| 450 | 
            +
                  @commands << command
         | 
| 324 451 | 
             
                  nil
         | 
| 325 452 | 
             
                end
         | 
| 326 453 |  | 
| @@ -331,12 +458,24 @@ class RedisClient | |
| 331 458 | 
             
                def _empty?
         | 
| 332 459 | 
             
                  @commands.empty?
         | 
| 333 460 | 
             
                end
         | 
| 461 | 
            +
             | 
| 462 | 
            +
                def _coerce!(results)
         | 
| 463 | 
            +
                  return results unless results
         | 
| 464 | 
            +
             | 
| 465 | 
            +
                  @blocks&.each_with_index do |block, index|
         | 
| 466 | 
            +
                    if block
         | 
| 467 | 
            +
                      results[index] = block.call(results[index])
         | 
| 468 | 
            +
                    end
         | 
| 469 | 
            +
                  end
         | 
| 470 | 
            +
             | 
| 471 | 
            +
                  results
         | 
| 472 | 
            +
                end
         | 
| 334 473 | 
             
              end
         | 
| 335 474 |  | 
| 336 475 | 
             
              private
         | 
| 337 476 |  | 
| 338 477 | 
             
              def build_transaction
         | 
| 339 | 
            -
                transaction = Multi.new
         | 
| 478 | 
            +
                transaction = Multi.new(@command_builder)
         | 
| 340 479 | 
             
                transaction.call("MULTI")
         | 
| 341 480 | 
             
                yield transaction
         | 
| 342 481 | 
             
                transaction.call("EXEC")
         | 
| @@ -433,8 +572,16 @@ class RedisClient | |
| 433 572 | 
             
                end
         | 
| 434 573 |  | 
| 435 574 | 
             
                connection
         | 
| 575 | 
            +
              rescue CommandError => error
         | 
| 576 | 
            +
                if error.message.include?("ERR unknown command `HELLO`")
         | 
| 577 | 
            +
                  raise UnsupportedServer,
         | 
| 578 | 
            +
                    "Your Redis server version is too old. redis-client requires Redis 6+. (#{config.server_url})"
         | 
| 579 | 
            +
                else
         | 
| 580 | 
            +
                  raise
         | 
| 581 | 
            +
                end
         | 
| 436 582 | 
             
              end
         | 
| 437 583 | 
             
            end
         | 
| 438 584 |  | 
| 439 | 
            -
            require "redis_client/resp3"
         | 
| 440 585 | 
             
            require "redis_client/pooled"
         | 
| 586 | 
            +
             | 
| 587 | 
            +
            RedisClient.default_driver
         | 
    
        data/redis-client.gemspec
    CHANGED
    
    | @@ -10,6 +10,7 @@ Gem::Specification.new do |spec| | |
| 10 10 |  | 
| 11 11 | 
             
              spec.summary = "Simple low-level client for Redis 6+"
         | 
| 12 12 | 
             
              spec.homepage = "https://github.com/redis-rb/redis-client"
         | 
| 13 | 
            +
              spec.license = "MIT"
         | 
| 13 14 | 
             
              spec.required_ruby_version = ">= 2.5.0"
         | 
| 14 15 |  | 
| 15 16 | 
             
              spec.metadata["allowed_push_host"] = "https://rubygems.org"
         | 
| @@ -22,13 +23,10 @@ Gem::Specification.new do |spec| | |
| 22 23 | 
             
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         | 
| 23 24 | 
             
              spec.files = Dir.chdir(File.expand_path(__dir__)) do
         | 
| 24 25 | 
             
                `git ls-files -z`.split("\x0").reject do |f|
         | 
| 25 | 
            -
                  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|benchmark)/|\.(?:git| | 
| 26 | 
            +
                  (f == __FILE__) || f.match(%r{\A(?:(?:bin|hiredis-client|test|spec|features|benchmark)/|\.(?:git|rubocop))})
         | 
| 26 27 | 
             
                end
         | 
| 27 28 | 
             
              end
         | 
| 28 | 
            -
              spec.bindir = "exe"
         | 
| 29 | 
            -
              spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
         | 
| 30 29 | 
             
              spec.require_paths = ["lib"]
         | 
| 31 | 
            -
              spec.extensions = ["ext/redis_client/hiredis/extconf.rb"]
         | 
| 32 30 |  | 
| 33 31 | 
             
              spec.add_runtime_dependency "connection_pool"
         | 
| 34 32 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: redis-client
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jean Boussier
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 | 
            -
            bindir:  | 
| 9 | 
            +
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2022- | 
| 11 | 
            +
            date: 2022-06-02 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: connection_pool
         | 
| @@ -28,79 +28,32 @@ description: | |
| 28 28 | 
             
            email:
         | 
| 29 29 | 
             
            - jean.boussier@gmail.com
         | 
| 30 30 | 
             
            executables: []
         | 
| 31 | 
            -
            extensions:
         | 
| 32 | 
            -
            - ext/redis_client/hiredis/extconf.rb
         | 
| 31 | 
            +
            extensions: []
         | 
| 33 32 | 
             
            extra_rdoc_files: []
         | 
| 34 33 | 
             
            files:
         | 
| 35 | 
            -
            - ".rubocop.yml"
         | 
| 36 34 | 
             
            - CHANGELOG.md
         | 
| 37 35 | 
             
            - Gemfile
         | 
| 38 36 | 
             
            - Gemfile.lock
         | 
| 39 37 | 
             
            - LICENSE.md
         | 
| 40 38 | 
             
            - README.md
         | 
| 41 39 | 
             
            - Rakefile
         | 
| 42 | 
            -
            - ext/redis_client/hiredis/export.clang
         | 
| 43 | 
            -
            - ext/redis_client/hiredis/export.gcc
         | 
| 44 | 
            -
            - ext/redis_client/hiredis/extconf.rb
         | 
| 45 | 
            -
            - ext/redis_client/hiredis/hiredis_connection.c
         | 
| 46 | 
            -
            - ext/redis_client/hiredis/vendor/.gitignore
         | 
| 47 | 
            -
            - ext/redis_client/hiredis/vendor/.travis.yml
         | 
| 48 | 
            -
            - ext/redis_client/hiredis/vendor/CHANGELOG.md
         | 
| 49 | 
            -
            - ext/redis_client/hiredis/vendor/CMakeLists.txt
         | 
| 50 | 
            -
            - ext/redis_client/hiredis/vendor/COPYING
         | 
| 51 | 
            -
            - ext/redis_client/hiredis/vendor/Makefile
         | 
| 52 | 
            -
            - ext/redis_client/hiredis/vendor/README.md
         | 
| 53 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/ae.h
         | 
| 54 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/glib.h
         | 
| 55 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/ivykis.h
         | 
| 56 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/libev.h
         | 
| 57 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/libevent.h
         | 
| 58 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/libuv.h
         | 
| 59 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/macosx.h
         | 
| 60 | 
            -
            - ext/redis_client/hiredis/vendor/adapters/qt.h
         | 
| 61 | 
            -
            - ext/redis_client/hiredis/vendor/alloc.c
         | 
| 62 | 
            -
            - ext/redis_client/hiredis/vendor/alloc.h
         | 
| 63 | 
            -
            - ext/redis_client/hiredis/vendor/appveyor.yml
         | 
| 64 | 
            -
            - ext/redis_client/hiredis/vendor/async.c
         | 
| 65 | 
            -
            - ext/redis_client/hiredis/vendor/async.h
         | 
| 66 | 
            -
            - ext/redis_client/hiredis/vendor/async_private.h
         | 
| 67 | 
            -
            - ext/redis_client/hiredis/vendor/dict.c
         | 
| 68 | 
            -
            - ext/redis_client/hiredis/vendor/dict.h
         | 
| 69 | 
            -
            - ext/redis_client/hiredis/vendor/fmacros.h
         | 
| 70 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis-config.cmake.in
         | 
| 71 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis.c
         | 
| 72 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis.h
         | 
| 73 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis.pc.in
         | 
| 74 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in
         | 
| 75 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis_ssl.h
         | 
| 76 | 
            -
            - ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in
         | 
| 77 | 
            -
            - ext/redis_client/hiredis/vendor/net.c
         | 
| 78 | 
            -
            - ext/redis_client/hiredis/vendor/net.h
         | 
| 79 | 
            -
            - ext/redis_client/hiredis/vendor/read.c
         | 
| 80 | 
            -
            - ext/redis_client/hiredis/vendor/read.h
         | 
| 81 | 
            -
            - ext/redis_client/hiredis/vendor/sds.c
         | 
| 82 | 
            -
            - ext/redis_client/hiredis/vendor/sds.h
         | 
| 83 | 
            -
            - ext/redis_client/hiredis/vendor/sdsalloc.h
         | 
| 84 | 
            -
            - ext/redis_client/hiredis/vendor/sockcompat.c
         | 
| 85 | 
            -
            - ext/redis_client/hiredis/vendor/sockcompat.h
         | 
| 86 | 
            -
            - ext/redis_client/hiredis/vendor/ssl.c
         | 
| 87 | 
            -
            - ext/redis_client/hiredis/vendor/test.c
         | 
| 88 | 
            -
            - ext/redis_client/hiredis/vendor/test.sh
         | 
| 89 | 
            -
            - ext/redis_client/hiredis/vendor/win32.h
         | 
| 90 40 | 
             
            - lib/redis-client.rb
         | 
| 91 41 | 
             
            - lib/redis_client.rb
         | 
| 92 | 
            -
            - lib/redis_client/ | 
| 42 | 
            +
            - lib/redis_client/command_builder.rb
         | 
| 93 43 | 
             
            - lib/redis_client/config.rb
         | 
| 94 | 
            -
            - lib/redis_client/ | 
| 95 | 
            -
            - lib/redis_client/ | 
| 44 | 
            +
            - lib/redis_client/connection_mixin.rb
         | 
| 45 | 
            +
            - lib/redis_client/decorator.rb
         | 
| 96 46 | 
             
            - lib/redis_client/middlewares.rb
         | 
| 97 47 | 
             
            - lib/redis_client/pooled.rb
         | 
| 98 | 
            -
            - lib/redis_client/ | 
| 48 | 
            +
            - lib/redis_client/ruby_connection.rb
         | 
| 49 | 
            +
            - lib/redis_client/ruby_connection/buffered_io.rb
         | 
| 50 | 
            +
            - lib/redis_client/ruby_connection/resp3.rb
         | 
| 99 51 | 
             
            - lib/redis_client/sentinel_config.rb
         | 
| 100 52 | 
             
            - lib/redis_client/version.rb
         | 
| 101 53 | 
             
            - redis-client.gemspec
         | 
| 102 54 | 
             
            homepage: https://github.com/redis-rb/redis-client
         | 
| 103 | 
            -
            licenses: | 
| 55 | 
            +
            licenses:
         | 
| 56 | 
            +
            - MIT
         | 
| 104 57 | 
             
            metadata:
         | 
| 105 58 | 
             
              allowed_push_host: https://rubygems.org
         | 
| 106 59 | 
             
              homepage_uri: https://github.com/redis-rb/redis-client
         |