prosody 0.2.1 → 0.4.0
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.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/ARCHITECTURE.md +12 -2
- data/CHANGELOG.md +20 -0
- data/Cargo.lock +586 -450
- data/Cargo.toml +6 -6
- data/README.md +211 -20
- data/Rakefile +11 -1
- data/examples/keyed_state.rb +58 -0
- data/examples/keyed_state.rbs +18 -0
- data/examples/keyed_state_windowing.rb +47 -0
- data/examples/keyed_state_windowing.rbs +16 -0
- data/ext/prosody/Cargo.toml +1 -1
- data/ext/prosody/src/client/config.rs +387 -19
- data/ext/prosody/src/handler/context.rs +146 -5
- data/ext/prosody/src/handler/message.rs +17 -0
- data/ext/prosody/src/handler/mod.rs +4 -2
- data/ext/prosody/src/handler/state.rs +1035 -0
- data/ext/prosody/src/lib.rs +1 -0
- data/lib/prosody/configuration.rb +26 -0
- data/lib/prosody/handler.rb +6 -2
- data/lib/prosody/native_stubs.rb +381 -6
- data/lib/prosody/state.rb +693 -0
- data/lib/prosody/version.rb +1 -1
- data/lib/prosody.rb +5 -0
- data/release-please-config.json +4 -0
- data/sig/configuration.rbs +24 -1
- data/sig/handler.rbs +7 -3
- data/sig/processor.rbs +28 -12
- data/sig/prosody.rbs +11 -6
- data/sig/sentry.rbs +6 -0
- data/sig/state.rbs +272 -0
- data/steep_expectations.yml +47 -0
- data/typecheck/payload_types.rb +43 -0
- data/typecheck/payload_types.rbs +20 -0
- data/typecheck_negative/payload_types.rb +16 -0
- data/typecheck_negative/payload_types.rbs +8 -0
- metadata +24 -11
|
@@ -100,9 +100,26 @@ impl Message {
|
|
|
100
100
|
/// # Errors
|
|
101
101
|
///
|
|
102
102
|
/// Returns an error if payload deserialization fails.
|
|
103
|
+
///
|
|
104
|
+
/// The public RBS exposes this JSON value as `Message[Payload]#payload`.
|
|
105
|
+
/// That generic parameter is static-only: this native boundary continues
|
|
106
|
+
/// to deserialize JSON into ordinary Ruby objects without runtime schema
|
|
107
|
+
/// validation.
|
|
103
108
|
fn payload(ruby: &Ruby, this: &Self) -> Result<Value, Error> {
|
|
104
109
|
serialize(ruby, this.inner.payload())
|
|
105
110
|
}
|
|
111
|
+
|
|
112
|
+
/// Clones the wrapped `ConsumerMessage` for a message-collection write.
|
|
113
|
+
///
|
|
114
|
+
/// The wrapper holds the real `ConsumerMessage`, so a message write clones
|
|
115
|
+
/// the inner value directly — a cheap operation.
|
|
116
|
+
///
|
|
117
|
+
/// # Returns
|
|
118
|
+
///
|
|
119
|
+
/// An owned clone of the wrapped `ConsumerMessage`.
|
|
120
|
+
pub(crate) fn consumer_message(&self) -> ConsumerMessage<serde_json::Value> {
|
|
121
|
+
self.inner.clone()
|
|
122
|
+
}
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
impl From<ConsumerMessage<serde_json::Value>> for Message {
|
|
@@ -38,6 +38,7 @@ use tracing_opentelemetry::OpenTelemetrySpanExt;
|
|
|
38
38
|
|
|
39
39
|
mod context;
|
|
40
40
|
mod message;
|
|
41
|
+
mod state;
|
|
41
42
|
mod trigger;
|
|
42
43
|
|
|
43
44
|
/// A handler that bridges between Kafka messages and Ruby message processing
|
|
@@ -117,7 +118,7 @@ impl FallibleHandler for RubyHandler {
|
|
|
117
118
|
_demand_type: DemandType,
|
|
118
119
|
) -> Result<(), Self::Error>
|
|
119
120
|
where
|
|
120
|
-
C: EventContext
|
|
121
|
+
C: EventContext<Payload = Self::Payload>,
|
|
121
122
|
{
|
|
122
123
|
// Create a new span for the on_message operation as a child of the message's
|
|
123
124
|
// span
|
|
@@ -207,7 +208,7 @@ impl FallibleHandler for RubyHandler {
|
|
|
207
208
|
_demand_type: DemandType,
|
|
208
209
|
) -> Result<(), Self::Error>
|
|
209
210
|
where
|
|
210
|
-
C: EventContext
|
|
211
|
+
C: EventContext<Payload = Self::Payload>,
|
|
211
212
|
{
|
|
212
213
|
// Only process application timers; internal timers are handled by middleware
|
|
213
214
|
if trigger.timer_type != TimerType::Application {
|
|
@@ -340,6 +341,7 @@ pub enum RubyHandlerError {
|
|
|
340
341
|
pub fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
341
342
|
context::init(ruby)?;
|
|
342
343
|
message::init(ruby)?;
|
|
344
|
+
state::init(ruby)?;
|
|
343
345
|
trigger::init(ruby)?;
|
|
344
346
|
|
|
345
347
|
Ok(())
|