Class: ModelContextProtocol::Server::StreamableHttpTransport::EventCounter
- Inherits:
-
Object
- Object
- ModelContextProtocol::Server::StreamableHttpTransport::EventCounter
- Defined in:
- lib/model_context_protocol/server/streamable_http_transport/event_counter.rb
Constant Summary collapse
- COUNTER_KEY_PREFIX =
"event_counter:"
Instance Method Summary collapse
-
#initialize(redis_client, server_instance) ⇒ EventCounter
constructor
A new instance of EventCounter.
- #next_event_id ⇒ Object
Constructor Details
#initialize(redis_client, server_instance) ⇒ EventCounter
Returns a new instance of EventCounter.
6 7 8 9 10 11 12 13 14 |
# File 'lib/model_context_protocol/server/streamable_http_transport/event_counter.rb', line 6 def initialize(redis_client, server_instance) @redis = redis_client @server_instance = server_instance @counter_key = "#{COUNTER_KEY_PREFIX}#{server_instance}" if @redis.exists(@counter_key) == 0 @redis.set(@counter_key, 0) end end |
Instance Method Details
#next_event_id ⇒ Object
16 17 18 19 |
# File 'lib/model_context_protocol/server/streamable_http_transport/event_counter.rb', line 16 def next_event_id count = @redis.incr(@counter_key) "#{@server_instance}-#{count}" end |