Class: Prosody::Client
- Inherits:
-
Object
- Object
- Prosody::Client
- Defined in:
- lib/prosody/native_stubs.rb
Overview
Main client for interacting with the Prosody messaging system. Provides methods for sending messages and subscribing to Kafka topics.
Class Method Summary collapse
-
.new(config) ⇒ Client
Creates a new Prosody client with the given configuration.
Instance Method Summary collapse
-
#assigned_partitions ⇒ Integer
Returns the number of Kafka partitions currently assigned to this consumer.
-
#consumer_state ⇒ Symbol
Returns the current state of the consumer.
-
#is_stalled? ⇒ Boolean
Checks if the consumer is stalled.
-
#send_message(topic, key, payload) ⇒ void
Sends a message to the specified Kafka topic.
-
#source_system ⇒ String
Returns the configured source system identifier.
-
#subscribe(handler) ⇒ void
Subscribes to Kafka topics using the provided handler.
-
#unsubscribe ⇒ void
Unsubscribes from all topics, stopping message processing.
Class Method Details
.new(config) ⇒ Client
Creates a new Prosody client with the given configuration.
294 295 296 |
# File 'lib/prosody/native_stubs.rb', line 294 def self.new(config) raise NotImplementedError, "This method is implemented natively in Rust" end |
Instance Method Details
#assigned_partitions ⇒ Integer
Returns the number of Kafka partitions currently assigned to this consumer.
This method can be used to monitor the consumer’s workload and ensure proper load balancing across multiple consumer instances.
316 317 318 |
# File 'lib/prosody/native_stubs.rb', line 316 def assigned_partitions raise NotImplementedError, "This method is implemented natively in Rust" end |
#consumer_state ⇒ Symbol
Returns the current state of the consumer.
The consumer can be in one of three states:
-
‘:unconfigured` - The consumer has not been configured yet
-
‘:configured` - The consumer is configured but not running
-
‘:running` - The consumer is actively consuming messages
306 307 308 |
# File 'lib/prosody/native_stubs.rb', line 306 def consumer_state raise NotImplementedError, "This method is implemented natively in Rust" end |
#is_stalled? ⇒ Boolean
Checks if the consumer is stalled.
A stalled consumer is one that has stopped processing messages due to errors or reaching processing limits. This can be used to detect unhealthy consumers that need attention.
327 328 329 |
# File 'lib/prosody/native_stubs.rb', line 327 def is_stalled? raise NotImplementedError, "This method is implemented natively in Rust" end |
#send_message(topic, key, payload) ⇒ void
This method returns an undefined value.
Sends a message to the specified Kafka topic.
341 342 343 |
# File 'lib/prosody/native_stubs.rb', line 341 def (topic, key, payload) raise NotImplementedError, "This method is implemented natively in Rust" end |
#source_system ⇒ String
Returns the configured source system identifier.
The source system is used to identify the originating service or component in produced messages, enabling loop detection.
387 388 389 |
# File 'lib/prosody/native_stubs.rb', line 387 def source_system raise NotImplementedError, "This method is implemented natively in Rust" end |
#subscribe(handler) ⇒ void
This method returns an undefined value.
Subscribes to Kafka topics using the provided handler. The handler must implement an ‘on_message(context, message)` method.
360 361 362 |
# File 'lib/prosody/native_stubs.rb', line 360 def subscribe(handler) raise NotImplementedError, "This method is implemented natively in Rust" end |
#unsubscribe ⇒ void
This method returns an undefined value.
Unsubscribes from all topics, stopping message processing.
This method gracefully shuts down the consumer, completing any in-flight messages before stopping.
374 375 376 |
# File 'lib/prosody/native_stubs.rb', line 374 def unsubscribe raise NotImplementedError, "This method is implemented natively in Rust" end |