prosody 0.3.0-aarch64-linux → 0.5.0-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,5 +6,5 @@ module Prosody
6
6
  # This version number follows semantic versioning and is used by the
7
7
  # gem system to identify the library version. It should be updated
8
8
  # according to semver guidelines when making releases.
9
- VERSION = "0.3.0"
9
+ VERSION = "0.5.0"
10
10
  end
data/lib/prosody.rb CHANGED
@@ -40,3 +40,9 @@ begin
40
40
  rescue LoadError
41
41
  require_relative "prosody/prosody"
42
42
  end
43
+
44
+ # Loaded last: the keyed-state surface reopens the native Prosody::Context and
45
+ # subclasses the error hierarchy, so every native class and base error must
46
+ # already exist.
47
+ require_relative "prosody/state"
48
+ require_relative "prosody/request"
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3
+ "bootstrap-sha": "a5c4faa0b7a5bf14d74c7c77de72883b20fc41fa",
4
+ "include-component-in-tag": true,
5
+ "include-v-in-tag": true,
6
+ "tag-separator": "/",
3
7
  "packages": {
4
8
  ".": {
5
9
  "release-type": "ruby",
@@ -24,7 +24,8 @@ module Prosody
24
24
  # Create a new configuration with initial values
25
25
  #
26
26
  # @param kwargs Initial configuration values
27
- def initialize: (?Hash[Symbol, untyped] kwargs) ?{ (Configuration) -> void } -> void
27
+ def initialize: (?Hash[Symbol, untyped] options) ?{ (Configuration) -> void } -> void
28
+ | (**untyped options) ?{ (Configuration) -> void } -> void
28
29
 
29
30
  # Kafka bootstrap server addresses
30
31
  def bootstrap_servers: () -> Array[String]?
@@ -102,6 +103,26 @@ module Prosody
102
103
  def source_system: () -> String?
103
104
  def source_system=: (_ToS) -> String
104
105
 
106
+ # Address for the peer listener. Prosody reads PROSODY_PEER_BIND_ADDRESS when absent.
107
+ def peer_bind_address: () -> String?
108
+ def peer_bind_address=: (_ToS) -> String
109
+
110
+ # Connect URI for remote peers. Prosody reads PROSODY_PEER_ADVERTISED_CONNECT when absent.
111
+ def peer_advertised_connect: () -> String?
112
+ def peer_advertised_connect=: (_ToS) -> String
113
+
114
+ # Network name for direct routes. Prosody reads PROSODY_PEER_NETWORK_NAME when absent.
115
+ def peer_network_name: () -> String?
116
+ def peer_network_name=: (_ToS) -> String
117
+
118
+ # Peer cache capacity. Prosody reads PROSODY_PEER_CACHE_CAPACITY when absent.
119
+ def peer_cache_capacity: () -> Integer?
120
+ def peer_cache_capacity=: (Integer | _ToInt) -> Integer
121
+
122
+ # Peer registration lease. Prosody reads PROSODY_PEER_REGISTRATION_TTL when absent.
123
+ def peer_registration_ttl: () -> Float?
124
+ def peer_registration_ttl=: (Numeric) -> Float
125
+
105
126
  # Topic to send failed messages to
106
127
  def failure_topic: () -> String?
107
128
  def failure_topic=: (_ToS) -> String
@@ -198,21 +219,21 @@ module Prosody
198
219
  def defer_failure_window: () -> Float?
199
220
  def defer_failure_window=: (Numeric) -> Float
200
221
 
201
- # Defer cache size
202
- def defer_cache_size: () -> Integer?
203
- def defer_cache_size=: (Integer | _ToInt) -> Integer
204
-
205
222
  # Maximum deferred store cache entries. Env: PROSODY_DEFER_STORE_CACHE_SIZE
206
223
  def defer_store_cache_size: () -> Integer?
207
224
  def defer_store_cache_size=: (Integer | _ToInt) -> Integer
208
225
 
209
- # Defer seek timeout (seconds)
210
- def defer_seek_timeout: () -> Float?
211
- def defer_seek_timeout=: (Numeric) -> Float
226
+ # Maximum messages retained by the shared Kafka loader. Env: PROSODY_LOADER_CACHE_SIZE. Default: 1024
227
+ def loader_cache_size: () -> Integer?
228
+ def loader_cache_size=: (Integer | _ToInt) -> Integer
212
229
 
213
- # Defer discard threshold (messages)
214
- def defer_discard_threshold: () -> Integer?
215
- def defer_discard_threshold=: (Integer | _ToInt) -> Integer
230
+ # Kafka loader seek timeout (seconds). Env: PROSODY_LOADER_SEEK_TIMEOUT. Default: 30
231
+ def loader_seek_timeout: () -> Float?
232
+ def loader_seek_timeout=: (Numeric) -> Float
233
+
234
+ # Sequential-read distance before the loader seeks. Env: PROSODY_LOADER_DISCARD_THRESHOLD. Default: 100
235
+ def loader_discard_threshold: () -> Integer?
236
+ def loader_discard_threshold=: (Integer | _ToInt) -> Integer
216
237
 
217
238
  # Handler execution timeout (seconds)
218
239
  def timeout: () -> Float?
@@ -234,6 +255,44 @@ module Prosody
234
255
  def timer_spans: () -> String?
235
256
  def timer_spans=: (_ToS) -> String
236
257
 
258
+ # Keyed-state collections to register before subscribe. Accepts an array of
259
+ # definition objects (from Prosody.value/map/deque and their message_*
260
+ # siblings) or already-serialized registration hashes.
261
+ def state_collections: () -> Array[untyped]?
262
+ def state_collections=: (untyped) -> Array[untyped]
263
+
264
+ # Subsystem under which published JSON collections are advertised.
265
+ # Uses PROSODY_SUBSYSTEM when omitted. Published collections require it.
266
+ def subsystem: () -> String?
267
+ def subsystem=: (_ToS) -> String
268
+
269
+ # Root directory for the local keyed-state cache. Falls back to
270
+ # PROSODY_STATE_CACHE_DIR. Must not be an empty string.
271
+ def state_cache_dir: () -> String?
272
+ def state_cache_dir=: (_ToS) -> String
273
+
274
+ # Capacity of the owning keyed-state cache. Accepts a human-readable size.
275
+ # Uses PROSODY_STATE_OWNED_CACHE_SIZE when omitted. Otherwise, the engine
276
+ # selects its default.
277
+ def state_owned_cache_size: () -> String?
278
+ def state_owned_cache_size=: (String | _ToS) -> String
279
+
280
+ # Capacity of the published-state read cache. Uses
281
+ # PROSODY_STATE_READ_CACHE_SIZE when omitted. It then uses the owned cache
282
+ # size when set, or 1 MiB when both sizes are unset.
283
+ def state_read_cache_size: () -> String?
284
+ def state_read_cache_size=: (String | _ToS) -> String
285
+
286
+ # Default published-read cache TTL in seconds, or false to bypass it. Uses
287
+ # PROSODY_STATE_READ_CACHE_TTL when omitted, then 5 seconds.
288
+ def state_read_cache: () -> (Float | false)?
289
+ def state_read_cache=: (Numeric | false) -> (Float | false)
290
+
291
+ # Delay in whole seconds between staging a provisional cell and the recovery
292
+ # sweep. Falls back to PROSODY_STATE_RECOVERY_DELAY (read by core).
293
+ def state_recovery_delay: () -> Float?
294
+ def state_recovery_delay=: (Numeric) -> Float
295
+
237
296
  # Convert configuration to a hash with non-nil values only
238
297
  def to_hash: () -> Hash[Symbol, untyped]
239
298
  end
data/sig/handler.rbs CHANGED
@@ -1,4 +1,8 @@
1
1
  module Prosody
2
+ # Base error class for all Prosody errors (defined in lib/prosody/handler.rb).
3
+ class Error < ::StandardError
4
+ end
5
+
2
6
  # Abstract base for all errors raised by EventHandler methods.
3
7
  # Subclasses must implement `#permanent?` to indicate retry behavior.
4
8
  class EventHandlerError < Prosody::Error
@@ -22,7 +26,7 @@ module Prosody
22
26
 
23
27
  # Mixin providing class-level methods to wrap instance methods so that
24
28
  # specified exceptions are re-wrapped as PermanentError or TransientError.
25
- module ErrorClassification
29
+ module ErrorClassification : Module
26
30
  # Wraps the given instance method so that specified exception types
27
31
  # are caught and re-raised as Prosody::PermanentError.
28
32
  #
@@ -52,11 +56,16 @@ module Prosody
52
56
  def wrap_errors: (Symbol method_name, Array[Class] exception_classes, singleton(EventHandlerError) error_class) -> void
53
57
  end
54
58
 
55
- # Abstract base class for handling incoming messages from Prosody.
56
- # Subclasses must implement `#on_message` to process received messages.
57
- class EventHandler
59
+ # Abstract base class for handling events from Prosody.
60
+ # Subclasses must implement all three handler methods.
61
+ class EventHandler[Payload = json_value, Response = json_value]
58
62
  extend ErrorClassification
59
63
 
64
+ def self.validate_handler!: [Payload, Response] (EventHandler[Payload, Response] handler) -> void
65
+
66
+ private def self.validate_method!: [Payload, Response] (EventHandler[Payload, Response] handler, Array[Module] owners, Symbol name) -> void
67
+ private def self.accepts_two_parameters?: (Method method) -> bool
68
+
60
69
  # Process a single message received from Prosody.
61
70
  # This method must be implemented by subclasses to define
62
71
  # custom message handling logic.
@@ -64,7 +73,10 @@ module Prosody
64
73
  # @param context the message context containing metadata and control capabilities
65
74
  # @param message the message content with payload and metadata
66
75
  # @raise [NotImplementedError] if not overridden by subclass
67
- def on_message: (Context context, Message message) -> void
76
+ def on_message: (Context context, Message[Payload] message) -> Response
77
+
78
+ # Process an excise record.
79
+ def on_excise: (Context context, ExciseMessage message) -> Response
68
80
 
69
81
  # Process a timer that has fired.
70
82
  # This method is called when a previously scheduled timer fires.
data/sig/processor.rbs CHANGED
@@ -40,13 +40,17 @@ module Prosody
40
40
  # OpenTelemetry context carrier for trace propagation
41
41
  attr_reader carrier: Hash[String, String]
42
42
 
43
+ # Structured event fields for error reporting
44
+ attr_reader event_context: Hash[Symbol, untyped]
45
+
43
46
  # Creates a new execute command with all required parameters
44
47
  def initialize: (
45
- task_id: String,
46
- carrier: Hash[String, String],
47
- block: ^() -> void,
48
- callback: ^(bool, untyped) -> bool,
49
- token: CancellationToken
48
+ String task_id,
49
+ Hash[String, String] carrier,
50
+ Hash[Symbol, untyped] event_context,
51
+ ^() -> untyped block,
52
+ ^(bool, untyped) -> untyped callback,
53
+ CancellationToken token
50
54
  ) -> void
51
55
  end
52
56
 
@@ -82,19 +86,31 @@ module Prosody
82
86
  # @yield the block to execute asynchronously
83
87
  # @return token that can be used to cancel the task
84
88
  def submit: (
85
- task_id: String,
86
- carrier: Hash[String, String],
87
- callback: ^(bool, untyped) -> bool
89
+ String task_id,
90
+ Hash[String, String] carrier,
91
+ Hash[String | Symbol, untyped] event_context,
92
+ ^(bool, untyped) -> untyped callback
88
93
  ) { () -> untyped } -> CancellationToken
89
94
 
90
95
  private
91
96
 
97
+ def running?: () -> bool?
98
+
92
99
  # Main processing loop for the async thread
93
100
  def process_commands: () -> void
94
101
 
95
- # Handles execution of a task with proper context propagation and error handling
96
- # @param command the command containing task details
97
- # @param barrier barrier for tracking active tasks
98
- def handle_execute: (Commands::Execute, Async::Barrier) -> void
102
+ # Handles execution of a task with proper context propagation and error handling.
103
+ # The barrier belongs to the external async gem and is intentionally kept
104
+ # untyped rather than publishing a partial signature for that dependency.
105
+ def handle_execute: (Commands::Execute, untyped) -> void
106
+
107
+ def run_with_cancellation: (
108
+ String,
109
+ CancellationToken,
110
+ ^() -> untyped,
111
+ ^(bool, untyped) -> untyped,
112
+ untyped,
113
+ Hash[Symbol, untyped]
114
+ ) -> void
99
115
  end
100
116
  end
data/sig/prosody.rbs CHANGED
@@ -1,4 +1,8 @@
1
1
  module Prosody
2
+ # Any value representable by JSON. This is the default payload type for
3
+ # messages and handlers; applications can substitute a narrower record type.
4
+ type json_value = nil | bool | Integer | Float | String | Array[json_value] | Hash[String, json_value]
5
+
2
6
  @logger: Logger?
3
7
 
4
8
  # Returns the module-level logger, creating a default if not yet set.
@@ -8,6 +12,24 @@ module Prosody
8
12
  # Sets the module-level logger. Pass nil to reset to the default.
9
13
  def self.logger=: (Logger?) -> Logger?
10
14
 
15
+ # Exports buffered telemetry without shutting down the process-global pipeline.
16
+ def self.flush_telemetry: () -> void
17
+
18
+ # Exports buffered telemetry and shuts down the process-global pipeline.
19
+ def self.shutdown_telemetry: () -> void
20
+
21
+ # Manages Kafka topics.
22
+ class AdminClient
23
+ # Creates an admin client for the specified Kafka bootstrap servers.
24
+ def self.new: (Array[String]) -> AdminClient
25
+
26
+ # Creates a topic.
27
+ def create_topic: (String, Integer, Integer) -> void
28
+
29
+ # Deletes a topic.
30
+ def delete_topic: (String) -> void
31
+ end
32
+
11
33
  # Wrapper for dynamically-typed results from async operations.
12
34
  # This is an internal class used for bridging Rust and Ruby.
13
35
  class DynamicResult
@@ -65,7 +87,7 @@ module Prosody
65
87
 
66
88
  # Represents a Kafka message with its metadata and payload.
67
89
  # Provides access to message properties like topic, partition, offset, and content.
68
- class Message
90
+ class Message[Payload = json_value]
69
91
  # Returns the Kafka topic this message was published to.
70
92
  # @return [String] The topic name
71
93
  def topic: () -> String
@@ -87,8 +109,17 @@ module Prosody
87
109
  def timestamp: () -> Time
88
110
 
89
111
  # Returns the deserialized message payload.
90
- # @return [untyped] The message content
91
- def payload: () -> untyped
112
+ # @return [Payload] The message content
113
+ def payload: () -> Payload
114
+ end
115
+
116
+ # Represents an excise record with no payload.
117
+ class ExciseMessage
118
+ def topic: () -> String
119
+ def partition: () -> Integer
120
+ def offset: () -> Integer
121
+ def key: () -> String
122
+ def timestamp: () -> Time
92
123
  end
93
124
 
94
125
  # Represents a timer that was scheduled to fire at a specific time.
@@ -118,10 +149,11 @@ module Prosody
118
149
  # @raise [ArgumentError] If the configuration is invalid
119
150
  # @raise [RuntimeError] If client initialization fails
120
151
  def self.new: (Hash[Symbol, untyped] | Configuration config) -> Client
152
+ | (**untyped options) -> Client
121
153
 
122
154
  # Returns the current state of the consumer.
123
155
  #
124
- # @return [Symbol] The consumer state: :unconfigured, :configured, or :running
156
+ # @return [Symbol] The consumer state: :shut_down, :unconfigured, :configured, or :running
125
157
  def consumer_state: () -> Symbol
126
158
 
127
159
  # Returns the number of Kafka partitions currently assigned to this consumer.
@@ -141,10 +173,13 @@ module Prosody
141
173
  #
142
174
  # @param topic [String] The destination topic name
143
175
  # @param key [String] The message key for partitioning
144
- # @param payload [untyped] The message payload (will be serialized)
176
+ # @param payload [json_value] The message payload (will be serialized)
145
177
  # @return [void]
146
178
  # @raise [RuntimeError] If the message cannot be sent
147
- def send_message: (String topic, String key, untyped payload) -> void
179
+ def send_message: (String topic, String key, json_value payload) -> void
180
+
181
+ # Sends an excise record for a key.
182
+ def excise: (String topic, String key) -> void
148
183
 
149
184
  # Subscribes to Kafka topics using the provided handler.
150
185
  # The handler must implement an `on_message(context, message)` method.
@@ -152,7 +187,7 @@ module Prosody
152
187
  # @param handler [EventHandler] A handler object that processes messages
153
188
  # @return [void]
154
189
  # @raise [RuntimeError] If subscription fails
155
- def subscribe: (EventHandler) -> void
190
+ def subscribe: [Payload, Response] (EventHandler[Payload, Response]) -> void
156
191
 
157
192
  # Unsubscribes from all topics, stopping message processing.
158
193
  #
@@ -160,6 +195,13 @@ module Prosody
160
195
  # @raise [RuntimeError] If unsubscription fails
161
196
  def unsubscribe: () -> void
162
197
 
198
+ # Shuts down all client services.
199
+ # Concurrent and repeated calls wait for the same shutdown operation.
200
+ #
201
+ # @return [void]
202
+ # @raise [RuntimeError] If shutdown fails
203
+ def shutdown: () -> void
204
+
163
205
  # Returns the configured source system identifier.
164
206
  #
165
207
  # The source system is used to identify the originating service or
@@ -167,5 +209,9 @@ module Prosody
167
209
  #
168
210
  # @return [String] The source system identifier
169
211
  def source_system: () -> String
212
+
213
+ def state: [T] (_ToS subsystem, _ValueDefinition[T] definition) -> PublishedValue[T]
214
+ | [V] (_ToS subsystem, _MapDefinition[V] definition) -> PublishedMap[V]
215
+ | [T] (_ToS subsystem, _DequeDefinition[T] definition) -> PublishedDeque[T]
170
216
  end
171
217
  end
data/sig/request.rbs ADDED
@@ -0,0 +1,66 @@
1
+ module Prosody
2
+ class Success[Value] < Data
3
+ attr_reader value: Value
4
+ end
5
+
6
+ class Failure < Data
7
+ attr_reader error: response_error
8
+ end
9
+
10
+ class HandlerError < Data
11
+ attr_reader message: String
12
+ end
13
+
14
+ class Timeout < Data
15
+ def message: () -> String
16
+ end
17
+
18
+ class FormatMismatch < Data
19
+ def message: () -> String
20
+ end
21
+
22
+ class MalformedResponse < Data
23
+ def message: () -> String
24
+ end
25
+
26
+ type response_error = HandlerError | Timeout | FormatMismatch | MalformedResponse
27
+ type outcome[Value] = Success[Value] | Failure
28
+ type outcomes[Value] = Hash[String, outcome[Value]]
29
+ type native_request = {
30
+ topic: String,
31
+ key: String,
32
+ payload: json_value,
33
+ subsystems: Array[String],
34
+ timeout: Integer | Float
35
+ }
36
+ type native_excise_request = {
37
+ topic: String,
38
+ key: String,
39
+ subsystems: Array[String],
40
+ timeout: Integer | Float
41
+ }
42
+
43
+ class Client
44
+ # The timeout value uses seconds.
45
+ # The method raises if the request cannot start or the Kafka send fails.
46
+ def request: (
47
+ topic: String,
48
+ key: String,
49
+ payload: json_value,
50
+ subsystems: Array[String],
51
+ timeout: Integer | Float
52
+ ) -> outcomes[json_value]
53
+
54
+ def request_excise: (
55
+ topic: String,
56
+ key: String,
57
+ subsystems: Array[String],
58
+ timeout: Integer | Float
59
+ ) -> outcomes[json_value]
60
+
61
+ private
62
+
63
+ def native_request: (native_request request) -> outcomes[json_value]
64
+ def native_request_excise: (native_excise_request request) -> outcomes[json_value]
65
+ end
66
+ end
data/sig/sentry.rbs ADDED
@@ -0,0 +1,6 @@
1
+ module Prosody
2
+ module SentryIntegration
3
+ def self.enabled?: () -> bool
4
+ def self.capture_exception: (Exception exception, ?Hash[Symbol, untyped] context) -> untyped
5
+ end
6
+ end