Skip to content

Commit dece694

Browse files
committed
Expose tags to connection pool.
1 parent db15b9f commit dece694

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/async/redis/client.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def initialize(endpoint = Endpoint.local, protocol: endpoint.protocol, **options
8989
@endpoint = endpoint
9090
@protocol = protocol
9191

92-
@pool = connect(**options)
92+
@pool = make_pool(**options)
9393
end
9494

9595
attr :endpoint
@@ -113,7 +113,14 @@ def self.open(*arguments, **options, &block)
113113

114114
protected
115115

116-
def connect(**options)
116+
def assign_default_tags(tags)
117+
tags[:endpoint] = @endpoint.to_s
118+
tags[:protocol] = @protocol.to_s
119+
end
120+
121+
def make_pool(**options)
122+
self.assign_default_tags(options[:tags] ||= {})
123+
117124
Async::Pool::Controller.wrap(**options) do
118125
peer = @endpoint.connect
119126

lib/async/redis/sentinel_client.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(endpoints, master_name: DEFAULT_MASTER_NAME, role: :master, proto
3030
# A cache of sentinel connections.
3131
@sentinels = {}
3232

33-
@pool = connect(**options)
33+
@pool = make_pool(**options)
3434
end
3535

3636
# @attribute [String] The name of the master instance.
@@ -114,8 +114,14 @@ def resolve_slave
114114

115115
protected
116116

117+
def assign_default_tags(tags)
118+
tags[:protocol] = @protocol.to_s
119+
end
120+
117121
# Override the parent method. The only difference is that this one needs to resolve the master/slave address.
118-
def connect(**options)
122+
def make_pool(**options)
123+
self.assign_default_tags(options[:tags] ||= {})
124+
119125
Async::Pool::Controller.wrap(**options) do
120126
endpoint = resolve_address
121127
peer = endpoint.connect

0 commit comments

Comments
 (0)