README.md in redis-client-0.9.0 vs README.md in redis-client-0.10.0
- old
+ new
@@ -341,16 +341,17 @@
end
```
## Production
-### Instrumentation
+### Instrumentation and Middlewares
-`redis-client` offers a public instrumentation API monitoring tools.
+`redis-client` offers a public middleware API to aid in monitoring and library extension. Middleware can be registered
+either globally or on a given configuration instance.
```ruby
-module MyRedisInstrumentation
+module MyGlobalRedisInstrumentation
def connect(redis_config)
MyMonitoringService.instrument("redis.connect") { super }
end
def call(command, redis_config)
@@ -359,13 +360,20 @@
def call_pipelined(commands, redis_config)
MyMonitoringService.instrument("redis.pipeline") { super }
end
end
-RedisClient.register(MyRedisInstrumentation)
+RedisClient.register(MyGlobalRedisInstrumentation)
```
-Note that this instrumentation is global.
+Note that `RedisClient.register` is global and apply to all `RedisClient` instances.
+
+To add middlewares to only a single client, you can provide them when creating the config:
+
+```ruby
+redis_config = RedisClient.config(middlewares: [AnotherRedisInstrumentation])
+redis_config.new_client
+```
### Timeouts
The client allows you to configure connect, read, and write timeouts.
Passing a single `timeout` option will set all three values: