Class: Prosody::Client

Inherits:
Object
  • Object
show all
Includes:
State::Reading
Defined in:
lib/prosody/native_stubs.rb,
lib/prosody/state.rb,
lib/prosody/request.rb,
sig/prosody.rbs,
sig/request.rbs

Overview

Main client for interacting with the Prosody messaging system. Provides methods for sending messages and subscribing to Kafka topics.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(config) ⇒ Client .new(options) ⇒ Client

Creates a new Prosody client with the given configuration.

Overloads:

Parameters:

Returns:

  • (Client)

    A new client instance

Raises:

  • (ArgumentError)

    If the configuration is invalid

  • (RuntimeError)

    If client initialization fails



394
395
396
# File 'lib/prosody/native_stubs.rb', line 394

def self.new(config)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

Instance Method Details

#assigned_partitionsInteger

Returns the number of Kafka partitions currently assigned to this consumer.

Returns:

  • (Integer)

    The number of assigned partitions



421
422
423
# File 'lib/prosody/native_stubs.rb', line 421

def assigned_partitions
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#consumer_stateSymbol

Returns the current state of the consumer.

Returns:

  • (Symbol)

    The consumer state: :shut_down, :unconfigured, :configured, or :running



407
408
409
# File 'lib/prosody/native_stubs.rb', line 407

def consumer_state
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#excise(topic, key) ⇒ void

This method returns an undefined value.

Sends an excise record for a key.

Parameters:

  • topic (String)
  • key (String)


458
459
460
# File 'lib/prosody/native_stubs.rb', line 458

def excise(topic, key)
  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.

Returns:

  • (Boolean)

    true if the consumer is stalled, false otherwise



432
433
434
# File 'lib/prosody/native_stubs.rb', line 432

def is_stalled?
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#native_request(_request) ⇒ outcomes[json_value]

Parameters:

Returns:

  • (outcomes[json_value])

Raises:

  • (NotImplementedError)


411
412
413
# File 'lib/prosody/native_stubs.rb', line 411

def native_request(_request)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#native_request_exciseoutcomes[json_value]

Parameters:

  • request (native_excise_request)

Returns:

  • (outcomes[json_value])


64
# File 'sig/request.rbs', line 64

def native_request_excise: (native_excise_request request) -> outcomes[json_value]

#published_deque(subsystem, name, read_cache, read_cache_disabled) ⇒ Object

Raises:

  • (NotImplementedError)


536
537
538
# File 'lib/prosody/native_stubs.rb', line 536

def published_deque(subsystem, name, read_cache, read_cache_disabled)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#published_map(subsystem, name, read_cache, read_cache_disabled) ⇒ Object

Raises:

  • (NotImplementedError)


531
532
533
# File 'lib/prosody/native_stubs.rb', line 531

def published_map(subsystem, name, read_cache, read_cache_disabled)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#published_value(subsystem, name, read_cache, read_cache_disabled) ⇒ Object

Raises:

  • (NotImplementedError)


526
527
528
# File 'lib/prosody/native_stubs.rb', line 526

def published_value(subsystem, name, read_cache, read_cache_disabled)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#request(topic:, key:, payload:, subsystems:, timeout:) ⇒ Object

The timeout value uses seconds. The method raises if the request cannot start or the Kafka send fails.



25
26
27
28
29
30
31
32
33
# File 'lib/prosody/request.rb', line 25

def request(topic:, key:, payload:, subsystems:, timeout:)
  native_request(
    topic: topic,
    key: key,
    payload: payload,
    subsystems: subsystems,
    timeout: timeout
  )
end

#request_excise(topic:, key:, subsystems:, timeout:) ⇒ Object

Returns one excise outcome for each subsystem.



36
37
38
39
40
41
42
43
# File 'lib/prosody/request.rb', line 36

def request_excise(topic:, key:, subsystems:, timeout:)
  native_request_excise(
    topic: topic,
    key: key,
    subsystems: subsystems,
    timeout: timeout
  )
end

#send_message(topic, key, payload) ⇒ void

This method returns an undefined value.

Sends a message to the specified Kafka topic.

Parameters:

  • topic (String)

    The destination topic name

  • key (String)

    The message key for partitioning

  • payload (json_value)

    The message payload (will be serialized)

Raises:

  • (RuntimeError)

    If the message cannot be sent



448
449
450
# File 'lib/prosody/native_stubs.rb', line 448

def send_message(topic, key, payload)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#shutdownvoid

This method returns an undefined value.

Shuts down all client services. Concurrent and repeated calls wait for the same shutdown operation.

Raises:

  • (RuntimeError)

    If shutdown fails



508
509
510
# File 'lib/prosody/native_stubs.rb', line 508

def shutdown
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#source_systemString

Returns the configured source system identifier.

The source system is used to identify the originating service or component in produced messages, enabling loop detection.

Returns:

  • (String)

    The source system identifier



521
522
523
# File 'lib/prosody/native_stubs.rb', line 521

def source_system
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#statevoid #statevoid #statevoid

Overloads:

  • #statevoid

    This method returns an undefined value.

  • #statevoid

    This method returns an undefined value.

  • #statevoid

    This method returns an undefined value.



213
214
215
# File 'sig/prosody.rbs', line 213

def state: [T] (_ToS subsystem, _ValueDefinition[T] definition) -> PublishedValue[T]
| [V] (_ToS subsystem, _MapDefinition[V] definition) -> PublishedMap[V]
| [T] (_ToS subsystem, _DequeDefinition[T] definition) -> PublishedDeque[T]

#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.

Parameters:

  • handler (EventHandler)

    A handler object that processes messages

Raises:

  • (RuntimeError)

    If subscription fails



485
486
487
# File 'lib/prosody/native_stubs.rb', line 485

def subscribe(handler)
  raise NotImplementedError, "This method is implemented natively in Rust"
end

#unsubscribevoid

This method returns an undefined value.

Unsubscribes from all topics, stopping message processing.

Raises:

  • (RuntimeError)

    If unsubscription fails



497
498
499
# File 'lib/prosody/native_stubs.rb', line 497

def unsubscribe
  raise NotImplementedError, "This method is implemented natively in Rust"
end