prosody 0.5.1 → 0.6.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/.config/rail.toml +26 -0
- data/.release-please-manifest.json +1 -1
- data/.ruby-version +1 -1
- data/.taplo.toml +1 -1
- data/AGENTS.md +29 -15
- data/CHANGELOG.md +7 -0
- data/CONFIGURATION.md +19 -16
- data/Cargo.lock +254 -235
- data/Cargo.toml +11 -8
- data/README.md +100 -23
- data/examples/keyed_state.rb +10 -2
- data/examples/keyed_state.rbs +1 -0
- data/ext/prosody/Cargo.toml +1 -1
- data/ext/prosody/src/admin.rs +36 -36
- data/ext/prosody/src/bridge/mod.rs +5 -10
- data/ext/prosody/src/client/config/connections.rs +170 -0
- data/ext/prosody/src/client/config/middleware.rs +184 -0
- data/ext/prosody/src/client/config/mod.rs +396 -0
- data/ext/prosody/src/client/config/state.rs +323 -0
- data/ext/prosody/src/client/mod.rs +31 -117
- data/ext/prosody/src/client/readers.rs +106 -0
- data/ext/prosody/src/client/request.rs +2 -2
- data/ext/prosody/src/client/support.rs +13 -32
- data/ext/prosody/src/gvl.rs +8 -6
- data/ext/prosody/src/handler/{context.rs → context/mod.rs} +36 -150
- data/ext/prosody/src/handler/context/vending.rs +138 -0
- data/ext/prosody/src/handler/message.rs +36 -0
- data/ext/prosody/src/handler/mod.rs +18 -8
- data/ext/prosody/src/handler/state/deque.rs +144 -0
- data/ext/prosody/src/handler/state/mod.rs +163 -268
- data/ext/prosody/src/handler/state/query.rs +264 -0
- data/ext/prosody/src/handler/state/registration.rs +15 -86
- data/ext/prosody/src/handler/state/scan.rs +33 -141
- data/ext/prosody/src/handler/state/set.rs +98 -0
- data/ext/prosody/src/lib.rs +54 -36
- data/ext/prosody/src/logging.rs +6 -6
- data/ext/prosody/src/published.rs +171 -152
- data/ext/prosody/src/scheduler/result.rs +2 -1
- data/ext/prosody/src/util.rs +65 -3
- data/lib/prosody/client.rb +32 -0
- data/lib/prosody/configuration.rb +20 -12
- data/lib/prosody/demand.rb +27 -0
- data/lib/prosody/native_stubs/client.rb +157 -0
- data/lib/prosody/native_stubs/context.rb +178 -0
- data/lib/prosody/native_stubs/message.rb +133 -0
- data/lib/prosody/native_stubs.rb +11 -956
- data/lib/prosody/state/deque.rb +253 -0
- data/lib/prosody/state/map.rb +313 -0
- data/lib/prosody/state/set.rb +121 -0
- data/lib/prosody/state/value.rb +58 -0
- data/lib/prosody/state.rb +157 -677
- data/lib/prosody/version.rb +1 -1
- data/lib/prosody.rb +2 -1
- data/sig/configuration.rbs +19 -10
- data/sig/prosody.rbs +37 -4
- data/sig/published.rbs +102 -0
- data/sig/state.rbs +109 -122
- data/typecheck/payload_types.rb +12 -0
- data/typecheck/payload_types.rbs +1 -0
- metadata +30 -11
- data/ext/prosody/src/client/config.rs +0 -1300
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The value collection: the owned {Prosody::ValueState} handle and the
|
|
4
|
+
# {Prosody::PublishedValue} reader.
|
|
5
|
+
|
|
6
|
+
module Prosody
|
|
7
|
+
# A single-value keyed-state handle.
|
|
8
|
+
#
|
|
9
|
+
# Reads return the stored JSON value (or a {Prosody::Message} for message
|
|
10
|
+
# collections), or `nil` when the value is absent. Writes are buffered and
|
|
11
|
+
# made durable by {#commit}. All operations are fiber-yield async: they look
|
|
12
|
+
# blocking but never block the thread.
|
|
13
|
+
class ValueState < State::Handle
|
|
14
|
+
# Reads the current value.
|
|
15
|
+
#
|
|
16
|
+
# @return [Object, nil] the stored value, or `nil` when absent
|
|
17
|
+
def get = @native.get
|
|
18
|
+
|
|
19
|
+
# Buffers a write of the value.
|
|
20
|
+
#
|
|
21
|
+
# @param value [Object] the value to store (JSON, or a message)
|
|
22
|
+
# @return [void]
|
|
23
|
+
# @raise [PermanentStateError] if `value` is `nil` (use {#clear} to delete)
|
|
24
|
+
def set(value) = @native.set(value)
|
|
25
|
+
|
|
26
|
+
# Buffers a clear of the value.
|
|
27
|
+
#
|
|
28
|
+
# @return [void]
|
|
29
|
+
def clear = @native.clear
|
|
30
|
+
|
|
31
|
+
# Reads the current value. Idiomatic alias of {#get}.
|
|
32
|
+
#
|
|
33
|
+
# @return [Object, nil]
|
|
34
|
+
alias_method :value, :get
|
|
35
|
+
|
|
36
|
+
# Buffers a write of the value. Idiomatic alias of {#set}. As with any Ruby
|
|
37
|
+
# writer, `state.value = x` evaluates to `x` regardless of the return.
|
|
38
|
+
#
|
|
39
|
+
# @param value [Object]
|
|
40
|
+
# @return [void]
|
|
41
|
+
alias_method :value=, :set
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# A read-only view of a published value, opened by
|
|
45
|
+
# +client.state(subsystem, definition)+. Each read takes the user key and
|
|
46
|
+
# sees only committed state. A failed read raises the same state errors as
|
|
47
|
+
# an owned handle. A read in a forked child process raises +RuntimeError+.
|
|
48
|
+
class PublishedValue
|
|
49
|
+
# @param native [Prosody::NativePublishedValue] the native reader
|
|
50
|
+
def initialize(native) = @native = native
|
|
51
|
+
|
|
52
|
+
# Reads the committed value for +key+.
|
|
53
|
+
#
|
|
54
|
+
# @param key [String] the user key
|
|
55
|
+
# @return [Object, nil] the value, or +nil+ when it is absent
|
|
56
|
+
def get(key) = @native.get(key)
|
|
57
|
+
end
|
|
58
|
+
end
|