Class: ModelContextProtocol::Server::RedisConfig
- Inherits:
-
Object
- Object
- ModelContextProtocol::Server::RedisConfig
show all
- Includes:
- Singleton
- Defined in:
- lib/model_context_protocol/server/redis_config.rb
Defined Under Namespace
Classes: Configuration, NotConfiguredError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RedisConfig.
39
40
41
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 39
def initialize
reset!
end
|
Instance Attribute Details
#manager ⇒ Object
Returns the value of attribute manager.
13
14
15
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 13
def manager
@manager
end
|
Class Method Details
15
16
17
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 15
def self.configure(&block)
instance.configure(&block)
end
|
19
20
21
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 19
def self.configured?
instance.configured?
end
|
.pool ⇒ Object
23
24
25
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 23
def self.pool
instance.pool
end
|
.reset! ⇒ Object
31
32
33
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 31
def self.reset!
instance.reset!
end
|
.shutdown! ⇒ Object
27
28
29
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 27
def self.shutdown!
instance.shutdown!
end
|
.stats ⇒ Object
35
36
37
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 35
def self.stats
instance.stats
end
|
Instance Method Details
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 43
def configure(&block)
shutdown! if configured?
config = Configuration.new
yield(config) if block_given?
@manager = Server::RedisPoolManager.new(
redis_url: config.redis_url,
pool_size: config.pool_size,
pool_timeout: config.pool_timeout,
ssl_params: config.ssl_params
)
if config.enable_reaper
@manager.configure_reaper(
enabled: true,
interval: config.reaper_interval,
idle_timeout: config.idle_timeout
)
end
@manager.start
end
|
67
68
69
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 67
def configured?
!@manager.nil? && !@manager.pool.nil?
end
|
#pool ⇒ Object
71
72
73
74
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 71
def pool
raise NotConfiguredError unless configured?
@manager.pool
end
|
#reset! ⇒ Object
81
82
83
84
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 81
def reset!
shutdown!
@manager = nil
end
|
#shutdown! ⇒ Object
76
77
78
79
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 76
def shutdown!
@manager&.shutdown
@manager = nil
end
|
#stats ⇒ Object
86
87
88
89
|
# File 'lib/model_context_protocol/server/redis_config.rb', line 86
def stats
return {} unless configured?
@manager.stats
end
|