yrb-lite 0.1.0.beta3-x64-mingw-ucrt → 0.1.0.beta4-x64-mingw-ucrt
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/CHANGELOG.md +17 -1
- data/lib/yrb_lite/3.4/yrb_lite.so +0 -0
- data/lib/yrb_lite/4.0/yrb_lite.so +0 -0
- data/lib/yrb_lite/sync.rb +25 -4
- data/lib/yrb_lite/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3672b18498ed0869245f9fa46f1533e566c8bea07de50e9434c12be6fc59809a
|
|
4
|
+
data.tar.gz: fc387717203ebc9cfcb0b2bc1f2f237cbaef5b94227a52dabfbf51d7aa114b17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 273faf59f30c643e90a02ad07615123d1084d80070d0c51e011b62599dfde282b4cfb052215ab3af73e62ec3c11a2285410d8093f863bc8ba3a929d820a226e1
|
|
7
|
+
data.tar.gz: 1e139b9e19c82834852bf9809dbbe318e67b4c9997263c7be1259d284ee96fc0f0237a1d1e2859727817df8e5d16025f355b98af7b7e11d9b0723e27fbc2f7e7
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,21 @@ to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.0.beta4] - 2026-06-18
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- `on_change` block recorders now run in the **channel instance's context**
|
|
14
|
+
(via `instance_exec`), so a recorder can call the channel's own methods --
|
|
15
|
+
`current_user`, `params`, request/connection-scoped accessors -- directly,
|
|
16
|
+
instead of plumbing them in through a thread-local. A non-Proc callable (an
|
|
17
|
+
object responding to `#call`) is still invoked with `#call` and its own
|
|
18
|
+
context. `on_load`/`on_save` are unchanged: they can run in the shared
|
|
19
|
+
document registry during a cold load or eviction, where no connection
|
|
20
|
+
instance exists, so they remain key-only. Existing block recorders that use
|
|
21
|
+
only the `(key, update)` arguments and lexically-scoped constants are
|
|
22
|
+
unaffected; the only behavioral change is `self` inside the block.
|
|
23
|
+
|
|
9
24
|
## [0.1.0.beta3] - 2026-06-18
|
|
10
25
|
|
|
11
26
|
### Changed
|
|
@@ -76,7 +91,8 @@ to follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
76
91
|
- Precompiled native gems for common platforms (no Rust toolchain needed to
|
|
77
92
|
install) via the cross-gem workflow.
|
|
78
93
|
|
|
79
|
-
[Unreleased]: https://github.com/jpcamara/yrb-lite/compare/v0.1.0.
|
|
94
|
+
[Unreleased]: https://github.com/jpcamara/yrb-lite/compare/v0.1.0.beta4...main
|
|
95
|
+
[0.1.0.beta4]: https://github.com/jpcamara/yrb-lite/compare/v0.1.0.beta3...v0.1.0.beta4
|
|
80
96
|
[0.1.0.beta3]: https://github.com/jpcamara/yrb-lite/compare/v0.1.0.beta2...v0.1.0.beta3
|
|
81
97
|
[0.1.0.beta2]: https://github.com/jpcamara/yrb-lite/compare/v0.1.0.beta1...v0.1.0.beta2
|
|
82
98
|
[0.1.0.beta1]: https://github.com/jpcamara/yrb-lite/releases/tag/v0.1.0.beta1
|
|
Binary file
|
|
Binary file
|
data/lib/yrb_lite/sync.rb
CHANGED
|
@@ -20,6 +20,10 @@ module YrbLite
|
|
|
20
20
|
# on_load { |key| Document.find_by(key: key)&.content }
|
|
21
21
|
# on_save { |key, update| Document.find_by(key: key)&.update!(content: update) }
|
|
22
22
|
#
|
|
23
|
+
# # on_change blocks run in the channel instance's context, so instance
|
|
24
|
+
# # methods (current_user, params, ...) are available without plumbing:
|
|
25
|
+
# on_change { |key, update| Document.record!(key, update, by: current_user) }
|
|
26
|
+
#
|
|
23
27
|
# def subscribed
|
|
24
28
|
# sync_for params[:id]
|
|
25
29
|
# end
|
|
@@ -73,6 +77,13 @@ module YrbLite
|
|
|
73
77
|
# the change is rejected: neither applied to the shared document nor
|
|
74
78
|
# broadcast to other subscribers.
|
|
75
79
|
#
|
|
80
|
+
# A block recorder runs in the *channel instance's* context, so it can
|
|
81
|
+
# call the channel's own methods (current_user, params, a per-connection
|
|
82
|
+
# Current.* accessor) directly, with no thread-local plumbing. (A non-Proc
|
|
83
|
+
# callable is invoked with #call instead, since it carries its own
|
|
84
|
+
# context.) on_change always fires from within sync_receive, unlike
|
|
85
|
+
# on_load/on_save, which can run context-free in the shared registry.
|
|
86
|
+
#
|
|
76
87
|
# Registering an on_change switches that channel onto the strict path
|
|
77
88
|
# (record, apply, broadcast). Without it, the default fast path applies
|
|
78
89
|
# and broadcasts, with an optional on_save snapshot.
|
|
@@ -282,9 +293,9 @@ module YrbLite
|
|
|
282
293
|
next :noop unless update
|
|
283
294
|
next :gap unless awareness.update_ready?(update)
|
|
284
295
|
|
|
285
|
-
recorder
|
|
286
|
-
awareness.apply_update(update)
|
|
287
|
-
sync_distribute(encoded)
|
|
296
|
+
sync_record_change(recorder, update) # durable write; raise to reject
|
|
297
|
+
awareness.apply_update(update) # only recorded changes reach the doc
|
|
298
|
+
sync_distribute(encoded) # ...and only then the wire
|
|
288
299
|
:recorded
|
|
289
300
|
end
|
|
290
301
|
|
|
@@ -422,7 +433,9 @@ module YrbLite
|
|
|
422
433
|
return :gap
|
|
423
434
|
end
|
|
424
435
|
|
|
425
|
-
self.class.on_change
|
|
436
|
+
if (recorder = self.class.on_change)
|
|
437
|
+
sync_record_change(recorder, update) # record before relay
|
|
438
|
+
end
|
|
426
439
|
sync_distribute(encoded)
|
|
427
440
|
:recorded
|
|
428
441
|
when MSG_KIND_AWARENESS
|
|
@@ -460,6 +473,14 @@ module YrbLite
|
|
|
460
473
|
saver.call(@sync_key, sync_awareness.encode_state_as_update)
|
|
461
474
|
end
|
|
462
475
|
|
|
476
|
+
# Invoke the on_change recorder. A block/proc runs in this channel instance's
|
|
477
|
+
# context (instance_exec) so it can reach the channel's own methods; a
|
|
478
|
+
# non-Proc callable is invoked with #call, since it carries its own context.
|
|
479
|
+
def sync_record_change(recorder, update)
|
|
480
|
+
args = [@sync_key, update]
|
|
481
|
+
recorder.is_a?(Proc) ? instance_exec(*args, &recorder) : recorder.call(*args)
|
|
482
|
+
end
|
|
483
|
+
|
|
463
484
|
# -- Shared document registry ------------------------------------------
|
|
464
485
|
|
|
465
486
|
@registry = {}
|
data/lib/yrb_lite/version.rb
CHANGED