Class: Prosody::Context
- Inherits:
-
Object
- Object
- Prosody::Context
- Defined in:
- lib/prosody/native_stubs.rb
Overview
Represents the context of a Kafka message, providing metadata and control capabilities for message handling.
Instances of this class are created by the native code and passed to your EventHandler’s #on_message method.
Instance Method Summary collapse
-
#clear_and_schedule(time) ⇒ void
Clears all scheduled timers and schedules a new one at the specified time.
-
#clear_scheduled ⇒ void
Clears all scheduled timers.
-
#initialize ⇒ Context
constructor
A new instance of Context.
-
#on_cancel ⇒ void
Blocks until cancellation is signaled.
-
#schedule(time) ⇒ void
Schedules a timer to fire at the specified time.
-
#scheduled ⇒ Array<Time>
Returns all currently scheduled timer times.
-
#should_cancel? ⇒ Boolean
Checks if cancellation has been requested.
-
#unschedule(time) ⇒ void
Unschedules a timer that was scheduled for the specified time.
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
37 38 39 |
# File 'lib/prosody/native_stubs.rb', line 37 def initialize raise NotImplementedError, "This class is implemented natively in Rust" end |
Instance Method Details
#clear_and_schedule(time) ⇒ void
This method returns an undefined value.
Clears all scheduled timers and schedules a new one at the specified time.
This is equivalent to calling clear_scheduled followed by schedule, but performed atomically.
121 122 123 |
# File 'lib/prosody/native_stubs.rb', line 121 def clear_and_schedule(time) raise NotImplementedError, "This method is implemented natively in Rust" end |
#clear_scheduled ⇒ void
This method returns an undefined value.
Clears all scheduled timers.
After calling this method, no timers will be scheduled to fire for this message context.
159 160 161 |
# File 'lib/prosody/native_stubs.rb', line 159 def clear_scheduled raise NotImplementedError, "This method is implemented natively in Rust" end |
#on_cancel ⇒ void
This method returns an undefined value.
Blocks until cancellation is signaled.
Cancellation includes message-level cancellation (e.g., handler timeout) and partition shutdown. During shutdown, cancellation is delayed until near the end of the shutdown timeout to allow in-flight work to complete. This method is useful for long-running handlers that need to wait for external events while remaining responsive to cancellation.
78 79 80 |
# File 'lib/prosody/native_stubs.rb', line 78 def on_cancel raise NotImplementedError, "This method is implemented natively in Rust" end |
#schedule(time) ⇒ void
This method returns an undefined value.
Schedules a timer to fire at the specified time.
Timers allow you to delay execution or implement timeout behavior within your message handlers. When a timer fires, your handler’s #on_timer method will be called with the timer object.
102 103 104 |
# File 'lib/prosody/native_stubs.rb', line 102 def schedule(time) raise NotImplementedError, "This method is implemented natively in Rust" end |
#scheduled ⇒ Array<Time>
Returns all currently scheduled timer times.
The returned array contains Time objects representing when each scheduled timer will fire. The array may be empty if no timers are scheduled.
179 180 181 |
# File 'lib/prosody/native_stubs.rb', line 179 def scheduled raise NotImplementedError, "This method is implemented natively in Rust" end |
#should_cancel? ⇒ Boolean
Checks if cancellation has been requested.
This method can be called within message handlers to detect when the handler should exit. Cancellation includes message-level cancellation (e.g., handler timeout) and partition shutdown. During shutdown, cancellation is delayed until near the end of the shutdown timeout to allow in-flight work to complete.
59 60 61 |
# File 'lib/prosody/native_stubs.rb', line 59 def should_cancel? raise NotImplementedError, "This method is implemented natively in Rust" end |
#unschedule(time) ⇒ void
This method returns an undefined value.
Unschedules a timer that was scheduled for the specified time.
If multiple timers were scheduled for the same time, this will remove one of them. If no timer exists for the specified time, this method does nothing.
143 144 145 |
# File 'lib/prosody/native_stubs.rb', line 143 def unschedule(time) raise NotImplementedError, "This method is implemented natively in Rust" end |