solid_objects 0.14.1 → 0.14.3

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.
@@ -0,0 +1,5 @@
1
+ # rbs_inline: enabled
2
+
3
+ require_relative "support"
4
+
5
+ SolidObjectsBenchmark.state_size
data/benchmark/support.rb CHANGED
@@ -7,6 +7,25 @@ require "solid_objects"
7
7
 
8
8
  module SolidObjectsBenchmark
9
9
  DATABASE_PATH = File.expand_path("../tmp/solid_objects_benchmark.sqlite3", __dir__)
10
+ STATE_SIZES = [ 0, 16 * 1_024, 128 * 1_024, 1_024 * 1_024 ].freeze
11
+ STATE_ENTRY_BYTES = 26
12
+
13
+ class StateSizeActor < SolidObjects::Actor
14
+ actor_type "benchmark-state-size"
15
+
16
+ attribute :count, default: 0
17
+ attribute :filler, default: -> { {} }
18
+
19
+ def fill(size:)
20
+ entries = size / STATE_ENTRY_BYTES
21
+ self.filler = Array.new(entries) { |index| [ "key-#{index}", "value-#{index}" ] }.to_h
22
+ filler.length
23
+ end
24
+
25
+ def increment
26
+ self.count = count + 1
27
+ end
28
+ end
10
29
 
11
30
  class CounterActor < SolidObjects::Actor
12
31
  actor_type "benchmark-counter"
@@ -289,6 +308,12 @@ module SolidObjectsBenchmark
289
308
  )
290
309
  end
291
310
 
311
+ # @rbs () -> void
312
+ def state_size
313
+ warm_up_state_size
314
+ STATE_SIZES.each { |size| measure_state_size(size) }
315
+ end
316
+
292
317
  # @rbs () -> void
293
318
  def query_count
294
319
  turn = message_turn_query_count
@@ -433,6 +458,44 @@ module SolidObjectsBenchmark
433
458
  count.times { |index| references[index % actor_count].async.increment }
434
459
  end
435
460
 
461
+ # @rbs () -> void
462
+ def warm_up_state_size
463
+ reference = StateSizeActor.ref("state-size-warm-up")
464
+ reference.fill(size: 0)
465
+ count.times { reference.async.increment }
466
+ worker = SolidObjects::Worker.new
467
+ drain(worker)
468
+ ensure
469
+ worker&.stop
470
+ end
471
+
472
+ # @rbs (Integer) -> void
473
+ def measure_state_size(size)
474
+ silence_large_state_warning
475
+ actor_id = "state-size-#{size}"
476
+ reference = StateSizeActor.ref(actor_id)
477
+ reference.fill(size:)
478
+ state_bytes = committed_state_bytes(actor_id)
479
+ count.times { reference.async.increment }
480
+ worker = SolidObjects::Worker.new
481
+ measure("process #{count} messages with #{state_bytes} bytes of state") { drain(worker) }
482
+ ensure
483
+ worker&.stop
484
+ end
485
+
486
+ # @rbs () -> void
487
+ def silence_large_state_warning
488
+ return unless SolidObjects.configuration.respond_to?(:warn_state_bytes=)
489
+
490
+ SolidObjects.configuration.warn_state_bytes = SolidObjects.configuration.max_state_bytes
491
+ end
492
+
493
+ # @rbs (String) -> Integer
494
+ def committed_state_bytes(actor_id)
495
+ instance = SolidObjects::Instance.find_by!(actor_type: "benchmark-state-size", actor_id:)
496
+ JSON.generate(instance.state).bytesize
497
+ end
498
+
436
499
  # @rbs (SolidObjects::Worker) -> Integer
437
500
  def drain(worker)
438
501
  processed = 0
@@ -13,7 +13,7 @@ Mailbox delivery is at least once. State mutation, message completion, result pe
13
13
 
14
14
  Actor code receives message ID, request ID, attempt, enqueue time, and idempotency key. Documentation requires idempotency for effects outside the actor commit.
15
15
 
16
- Message handlers themselves can run more than once. Sequential execution means one valid activation runs one turn at a time; it does not mean a handler runs once. Handlers for transitions such as `launch`, `checkout`, or `submit` must inspect durable actor state and return safely when the transition already happened. External calls belong in an outbox and still require downstream idempotency.
16
+ Message handlers themselves can run more than once. Sequential execution means that one valid activation runs one turn at a time. It does not guarantee that a handler runs only once. Handlers for transitions such as `launch`, `checkout`, or `submit` must inspect durable actor state and return safely when the transition already happened. External calls belong in an outbox and still require downstream idempotency.
17
17
 
18
18
  ## Consequences
19
19
 
data/docs/architecture.md CHANGED
@@ -7,8 +7,9 @@ It is a database-backed virtual actor runtime for MySQL, PostgreSQL, and
7
7
  SQLite. A virtual actor is a logical object addressed by type and ID whose
8
8
  in-memory activation is created on demand, processes one mailbox turn at a
9
9
  time, persists JSON state, and can disappear when idle without losing its
10
- identity or state. This ports the programming model, not Cloudflare's
11
- serverless runtime, global placement, storage API, or platform guarantees.
10
+ identity or state. This gem ports the programming model. It does not port
11
+ Cloudflare's serverless runtime, global placement, storage API, or platform
12
+ guarantees.
12
13
 
13
14
  The runtime contract is:
14
15
 
@@ -128,8 +129,8 @@ instance first prevents a claimed reminder from recreating a destroyed actor.
128
129
  The broadcast worker claims committed observable-change rows, renders
129
130
  idempotent scalar Turbo replacements with component invalidation metadata,
130
131
  broadcasts to a signed actor stream, and records delivery. It never renders
131
- personalized component HTML. Current actor state remains the reconnect and
132
- request-time component source of truth.
132
+ personalized component HTML. On reconnect, and on a request-time component
133
+ render, Solid Objects reads the current actor state.
133
134
 
134
135
  ### Process registry
135
136
 
@@ -435,6 +436,45 @@ send_to(InventoryActor.ref("sku-123")).reserve(order_id: id, quantity: 2)
435
436
 
436
437
  The source actor commit never waits for the target. The outbox worker allocates the target's sequence after source commit. There is no global order across actors.
437
438
 
439
+ ## Registering effect and commit-action handlers
440
+
441
+ Register an effect handler during application boot. The stable effect ID is the
442
+ idempotency key for the provider call:
443
+
444
+ ```ruby
445
+ SolidObjects.register_effect(:charge_payment) do |arguments, context|
446
+ Payments.charge(
447
+ idempotency_key: context.id,
448
+ payment_id: arguments.fetch("payment_id"),
449
+ amount_cents: arguments.fetch("amount_cents")
450
+ )
451
+ end
452
+ ```
453
+
454
+ A success callback receives `effect_id:`, the originally staged `arguments:`,
455
+ and `result:`. A failure callback receives `effect_id:`, `arguments:`, and
456
+ `error:`, so an actor can correlate concurrent effects without storing a
457
+ separate callback ledger.
458
+
459
+ A commit action is registered the same way and runs inside the short fenced
460
+ transaction:
461
+
462
+ ```ruby
463
+ SolidObjects.register_commit_action(:complete_attempt) do |arguments, context|
464
+ AssessmentAttempt.find(arguments.fetch("attempt_id")).update!(
465
+ score: arguments.fetch("score"),
466
+ actor_message_id: context.message_id
467
+ )
468
+ end
469
+ ```
470
+
471
+ Commit actions require Solid Objects and `ActiveRecord::Base` to share one
472
+ connection pool, and may be invoked again after a database rollback, so keep
473
+ them deterministic, bounded, and database-only. When Solid Objects uses a
474
+ separate actor database, use `emit` and an idempotent effect consumer instead;
475
+ two databases cannot share one transaction.
476
+
477
+
438
478
  ## Reminders
439
479
 
440
480
  A reminder record contains actor identity, a reminder name, target message, JSON arguments, next run time, optional interval, status, and occurrence counter.
@@ -443,7 +483,7 @@ A reminder record contains actor identity, a reminder name, target message, JSON
443
483
  schedule(at: 30.minutes.from_now).expire
444
484
  ```
445
485
 
446
- Reminders are keyed by `(actor, reminder name)`, enforced by a unique index on `(instance_id, name)`. `schedule` is therefore an upsert: scheduling a name that is already armed moves that alarm instead of adding another, which is what makes re-arming safe from a handler that may run more than once. An actor needing several pending items should arm one alarm for the earliest and drain everything due when it fires, rather than one alarm per item; the [reminders guide](../README.md#a-reminder-is-one-named-alarm-per-actor) shows that pattern. A move that changes `next_run_at` emits `solid_objects.reminder.replaced`, because the replacement is otherwise indistinguishable from a first schedule.
486
+ Reminders are keyed by `(actor, reminder name)`, enforced by a unique index on `(instance_id, name)`. `schedule` is therefore an upsert: scheduling a name that is already armed moves that alarm instead of adding another, so re-arming is safe from a handler that may run more than once. An actor needing several pending items should arm one alarm for the earliest and drain everything due when it fires, rather than one alarm per item; the [reminders guide](reminders.md#one-alarm-for-a-whole-queue) shows that pattern. A move that changes `next_run_at` emits `solid_objects.reminder.replaced`, because the replacement is otherwise indistinguishable from a first schedule.
447
487
 
448
488
  When due, the scheduler locks the source instance and creates a normal mailbox
449
489
  row with an idempotency key derived from reminder ID and occurrence. The
@@ -659,7 +699,7 @@ Backoff and a retry limit prevent tight loops. The poison message blocks its act
659
699
 
660
700
  ### Handler redelivery
661
701
 
662
- Sequential processing does not mean single execution. A handler can run, lose its lease before commit, and run again. Logical transitions must guard on durable state:
702
+ Ordered processing does not prevent repeated execution. A handler can run, lose its lease before commit, and run again. Logical transitions must guard on durable state:
663
703
 
664
704
  ```ruby
665
705
  def launch
@@ -1,9 +1,9 @@
1
1
  # Authorization policies
2
2
 
3
- Solid Objects treats actor identities as identifiers, never capabilities.
4
- Knowing an actor ID, message ID, or signed stream token grants no permission.
5
- All five policies deny by default, so a generated installation is
6
- intentionally inert until the host application defines its trust boundary.
3
+ Solid Objects treats actor identities as identifiers. They are not
4
+ capabilities. An actor ID, a message ID, or a signed stream token grants no
5
+ permission. All five policies deny by default, so a generated installation
6
+ answers nothing until the host application defines its trust boundary.
7
7
 
8
8
  ## Policy reference
9
9
 
data/docs/benchmarks.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Performance and storage costs
2
2
 
3
- These numbers are development measurements, not universal capacity guarantees.
4
- They include the runtime's Active Record and database query overhead and will
5
- vary with hardware, schema size, connection pools, durability settings, and
3
+ These numbers are development measurements. They do not guarantee capacity.
4
+ They include the runtime's Active Record and database query overhead, and they
5
+ change with hardware, schema size, connection pools, durability settings, and
6
6
  contention.
7
7
 
8
8
  ## Idle SQLite polling
@@ -109,6 +109,51 @@ result is why Solid Objects does not publish one latency promise. Network
109
109
  topology, adapter behavior, host schema, logging, callbacks, and contention all
110
110
  matter.
111
111
 
112
+ ## State size and committed throughput
113
+
114
+ A turn commits the whole state image. It copies the state, encodes it, and
115
+ writes the row, so every message pays for the size of the state its actor
116
+ keeps. Run the scenario with:
117
+
118
+ ```bash
119
+ COUNT=300 bundle exec ruby -Ilib benchmark/state_size.rb
120
+ ```
121
+
122
+ Measured 2026-08-29 on an Apple M5 with 24 GB RAM, Ruby 4.0.5, Rails 8.1.3.1,
123
+ and SQLite 3.53.2. One hot actor received 300 messages at each state size. Each
124
+ figure is the median of five runs, and the two trees ran one after the other in
125
+ each round. The state holds many small entries, because a copy visits every
126
+ node, and one long string of the same length costs much less. The harness sets
127
+ `warn_state_bytes` to the hard limit, so neither tree pays for an event that
128
+ only one of them can emit.
129
+
130
+ | Committed state | Before | After | Change |
131
+ | ---: | ---: | ---: | ---: |
132
+ | 23 bytes | 1,268.0 messages/s | 1,252.5 messages/s | -1.2% |
133
+ | 13,662 bytes | 624.1 messages/s | 654.1 messages/s | +4.8% |
134
+ | 118,786 bytes | 169.3 messages/s | 174.6 messages/s | +3.1% |
135
+ | 1,026,356 bytes | 21.6 messages/s | 23.8 messages/s | +10.2% |
136
+
137
+ The "before" tree copied the whole state three times per committed turn and
138
+ encoded a string that it discarded whenever the caller gave no byte limit. The
139
+ "after" tree copies it twice and encodes only where a limit applies. It also
140
+ checks the encoding of every string it normalizes, which the discarded encoding
141
+ used to do, so part of the saving pays for that check. The gain grows with the
142
+ state, because the database write dominates a small turn. The empty-state row
143
+ sits inside run-to-run variance.
144
+
145
+ The curve matters more than the change. Throughput falls about 28 times between
146
+ 13 KB and 1 MB of state, and about 53 times between an empty state and 1 MB.
147
+ The `max_state_bytes` default of 5 MB is therefore a limit rather than an
148
+ operating point. `warn_state_bytes` defaults to 64 KB, and each commit above it
149
+ reports `solid_objects.state.large`. The Node package carries the same setting
150
+ as `warnStateBytes` and defaults it to 128 KB, because its measured curve falls
151
+ later: it keeps 98% of its empty-state throughput at 16 KB, where this gem
152
+ keeps 52% at 13 KB.
153
+
154
+ These are developer-laptop numbers on one adapter. They show shape and ratio,
155
+ not a capacity guarantee.
156
+
112
157
  ## Reactive delivery paths
113
158
 
114
159
  Measured 2026-08-09 on an Apple M5 with 200 iterations, for one actor mutation
data/docs/correctness.md CHANGED
@@ -78,8 +78,8 @@ Destruction is synchronous, forbidden from actor context, authorized by
78
78
 
79
79
  ## Handler idempotency
80
80
 
81
- Sequential does not mean once. A message such as `launch` still needs a durable
82
- guard:
81
+ Ordered execution does not prevent repeated execution. A message such as
82
+ `launch` still needs a durable guard:
83
83
 
84
84
  ```ruby
85
85
  def launch
data/docs/fit.md CHANGED
@@ -24,7 +24,13 @@ Solid Objects is a good candidate when most of these are true:
24
24
  asynchronous features, a Solid Objects runtime process.
25
25
 
26
26
  Typical fits include checkout state machines, collaborative rooms, device
27
- twins, durable assessments, approval workflows, and user-specific scheduling.
27
+ twins, durable assessments, approval workflows, user-specific scheduling, and
28
+ low-rate quotas that a reminder refills.
29
+
30
+ A workflow fits when one entity owns the mutable state and its mailbox holds
31
+ the step order. A durable execution engine that replays named steps from a step
32
+ log is a different tool: Solid Objects redelivers an ordered message and
33
+ retries it, and does not replay a handler from a step log.
28
34
 
29
35
  ## Poor fit and anti-patterns
30
36
 
@@ -46,10 +52,21 @@ when any of these dominate:
46
52
  - State that is clearer as a normal record with database constraints and direct
47
53
  service methods.
48
54
 
49
- A rate limiter is usually a poor actor: it is hot, request-critical, and often
50
- expires rather than requiring permanent message history. An impressions
51
- pipeline is also a poor actor: its value is high-throughput append and
52
- aggregation, not serialized mutable state.
55
+ A request-path rate limiter is usually a poor actor: it is hot,
56
+ request-critical, and often expires rather than requiring permanent message
57
+ history. A low-rate quota is the case that does fit, such as five password
58
+ resets an hour for one account, where a reminder refills the bucket and each
59
+ check is one durable ordered message. An impressions pipeline is also a poor
60
+ actor, because its value comes from high-throughput append and aggregation. It
61
+ does not need serialized mutable state.
62
+
63
+ [Solid Objects Pro](https://solidobjects.pro/) is the commercial scaling layer
64
+ for the high-QPS cases in this section. Grouped operations coalesce concurrent
65
+ calls into one bulk insert. Ephemeral operations hold a loss-tolerant call in
66
+ process memory and write no journal row, which is the mode for an abuse limiter,
67
+ a presence signal, or a view count. Reactive projections materialize a read
68
+ model from the durable broadcast outbox, so request-path reads stop competing
69
+ with mailbox work.
53
70
 
54
71
  ## Cost model
55
72
 
@@ -94,5 +111,5 @@ Before adopting an actor, answer:
94
111
  10. How will existing state be cut over and rolled back?
95
112
 
96
113
  Benchmark the actual host database and deployment topology before committing a
97
- latency-sensitive surface. Local benchmark results are evidence about query
98
- shape, not universal capacity guarantees.
114
+ latency-sensitive surface. Local benchmark results show query shape. They do
115
+ not guarantee capacity.
@@ -24,9 +24,9 @@ SOLID_OBJECTS_DATABASE_URL=postgresql://solid_objects:solid_objects@127.0.0.1:54
24
24
  bundle exec rake test
25
25
  ```
26
26
 
27
- Running this locally is worth the setup: it is what caught the PostgreSQL
28
- version comparison reading a packed integer, where `170010` compared greater
29
- than any minimum and made the check useless on the adapter it mattered most for.
27
+ The setup is worth the effort. This local suite caught a PostgreSQL version
28
+ comparison that read a packed integer, where `170010` compared greater than any
29
+ minimum and made the check useless on the adapter that needed it most.
30
30
 
31
31
  ## MySQL and Redis in Docker
32
32
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Moving an existing Redis, cache, or key-value state machine into Solid Objects
4
4
  is a data migration and a coordination cutover. Treat it as a staged production
5
- change, not a rewrite that switches storage in one deploy.
5
+ change. Do not switch the storage in one deploy.
6
6
 
7
7
  ## 1. Write down the existing contract
8
8
 
data/docs/operations.md CHANGED
@@ -23,6 +23,103 @@ process, its activations, and its claimed messages untouched, including when an
23
23
  application call overlaps the probe. A database busy enough to block cleanup
24
24
  reports a failed or warned check rather than raising out of the command.
25
25
 
26
+ ## Installing and upgrading
27
+
28
+ Review [CHANGELOG.md](CHANGELOG.md) for compatibility and deployment-order
29
+ notes, then update the gem:
30
+
31
+ ```bash
32
+ bundle update solid_objects
33
+ ```
34
+
35
+ If the `Gemfile` pins an exact version, update that constraint first and run
36
+ `bundle install`. Commit both `Gemfile.lock` and the copied Solid Objects
37
+ migrations.
38
+
39
+ Copy only migrations that the newer gem has added, migrate, and verify the
40
+ installation:
41
+
42
+ ```bash
43
+ bin/rails solid_objects:install:migrations
44
+ bin/rails db:migrate
45
+ bin/rails solid_objects:doctor
46
+ ```
47
+
48
+ The migration task skips engine migrations already present in the application
49
+ and gives new migrations host-specific timestamps. Inspect the resulting
50
+ `db/migrate/*.solid_objects.rb` files before applying them. Do not rerun
51
+ `generate solid_objects:install` during an upgrade because that also attempts
52
+ to regenerate the application initializer.
53
+
54
+ When Solid Objects uses a separate database configuration named `actors`, copy
55
+ and run migrations through that database's configured migration path:
56
+
57
+ ```bash
58
+ DATABASE=actors bin/rails solid_objects:install:migrations
59
+ bin/rails db:migrate:actors
60
+ bin/rails solid_objects:doctor
61
+ ```
62
+
63
+ For production, back up the actor database and run new migrations before
64
+ starting application or Solid Objects worker processes that require the new
65
+ schema. Restart the web and Solid Objects worker fleet after the bundle and
66
+ schema are current. For releases that change actor state versions, also follow
67
+ the [state migration and rolling-deployment guide](docs/state-migrations.md);
68
+ Rails schema migrations and actor state migrations are separate concerns.
69
+
70
+ ### Host application tooling
71
+
72
+ Installed engine migrations are copied as
73
+ `db/migrate/*_create_solid_objects_tables.solid_objects.rb`. If the host enables
74
+ `Rails/CreateTableWithTimestamps`, exclude engine-owned migrations rather than
75
+ editing their intentionally specialized hot tables:
76
+
77
+ ```yaml
78
+ Rails/CreateTableWithTimestamps:
79
+ Exclude:
80
+ - "db/migrate/*.solid_objects.rb"
81
+ ```
82
+
83
+ Solid Objects ships inline RBS signatures, not RBI files. Sorbet applications
84
+ can generate the gem RBI with:
85
+
86
+ ```bash
87
+ bundle exec tapioca gem solid_objects
88
+ ```
89
+
90
+ ### Running an extension in the same process
91
+
92
+ An extension gem can register its own long-running component, and
93
+ `solid_objects start` runs it beside the built-in roles. The component joins the
94
+ same supervision, the same replacement after a crash, and the same shutdown
95
+ timeout, so an operator deploys and monitors one process instead of two:
96
+
97
+ ```ruby
98
+ SolidObjects.configure do |configuration|
99
+ configuration.register_component { MyExtension::FlushEngine.new }
100
+ end
101
+ ```
102
+
103
+ Pass `count:` for more than one instance. The block runs once for each instance,
104
+ and again when the supervisor replaces a crashed one, so no two components share
105
+ an object.
106
+
107
+ A registered component answers four methods, the contract the built-in roles
108
+ already keep:
109
+
110
+ | Method | Purpose |
111
+ | --- | --- |
112
+ | `run` | Runs the loop. The supervisor calls it in its own thread |
113
+ | `request_shutdown` | Asks the loop to finish. It must make `run` return |
114
+ | `stopped?` | Reports whether the component already finished |
115
+ | `stop` | Forces cleanup when the shutdown timeout expires first |
116
+
117
+ The supervisor checks that contract when it builds the component, and a missing
118
+ method raises `ArgumentError` as the supervisor starts, rather than hanging a
119
+ shutdown later. Registration itself never calls the block, so a component is
120
+ free to need a database connection that the application does not have while it
121
+ boots.
122
+
26
123
  ## Runtime
27
124
 
28
125
  Start all configured roles:
@@ -46,9 +143,19 @@ loader participates in Rails preparation callbacks so a development reload can
46
143
  replace a registered actor class without loading unrelated application code.
47
144
 
48
145
  An actor registers itself as its class loads, and a web process resolves
49
- actors by name for Cable subscriptions and component renders. Loading them in
50
- every process is what lets a freshly booted web process serve a live card for
51
- an actor no request in that process has rendered yet.
146
+ actors by name for Cable subscriptions and component renders. Solid Objects
147
+ loads the actors in every process, so a freshly booted web process can serve a
148
+ live card for an actor that no request in that process has rendered yet.
149
+
150
+ Worker and outbox counts can be overridden on the command line:
151
+
152
+ ```bash
153
+ bundle exec solid_objects start \
154
+ --workers 4 \
155
+ --effect-workers 2 \
156
+ --broadcast-workers 2 \
157
+ --reminder-schedulers 1
158
+ ```
52
159
 
53
160
  Inspect process records and clean stale ownership:
54
161
 
@@ -70,26 +177,55 @@ bundle exec solid_objects retry_dead_letter 123
70
177
 
71
178
  ## Configuration
72
179
 
73
- Important controls include:
74
-
75
- - `worker_count`
76
- - `effect_worker_count`
77
- - `broadcast_worker_count`
78
- - `reminder_scheduler_count`
79
- - `max_messages_per_activation_pass`
80
- - `max_activation_duration`
81
- - `idle_deactivation_timeout`
82
- - `lease_duration`
83
- - `lease_renewal_interval`
84
- - `polling_interval`
85
- - `idle_polling_interval`
86
- - `max_mailbox_length`
87
- - payload, state, and result byte limits
88
- - retry attempts and delay
89
- - heartbeat interval and alive threshold
90
- - message retention and per-actor-type overrides
91
- - opt-in actor-instance retention by actor type
92
- - stopped-process retention and prune batch size
180
+ Configure Solid Objects in `config/initializers/solid_objects.rb`:
181
+
182
+ ```ruby
183
+ SolidObjects.configure do |configuration|
184
+ configuration.worker_count = 4
185
+ configuration.lease_duration = 30.seconds
186
+ configuration.lease_renewal_interval = 10.seconds
187
+ configuration.max_messages_per_activation_pass = 50
188
+ configuration.max_activation_duration = 5.seconds
189
+ end
190
+ ```
191
+
192
+ | Setting | Default |
193
+ | --- | ---: |
194
+ | `polling_interval` | 0.1 seconds |
195
+ | `idle_polling_interval` | 1 second |
196
+ | `sync_polling_interval` | 0.05 seconds |
197
+ | `lease_duration` | 30 seconds |
198
+ | `lease_renewal_interval` | 10 seconds |
199
+ | `idle_deactivation_timeout` | 30 seconds |
200
+ | `max_messages_per_activation_pass` | 50 |
201
+ | `max_activation_duration` | 5 seconds |
202
+ | `max_mailbox_length` | 10,000 |
203
+ | `warn_state_bytes` | 64 KB |
204
+ | `max_attempts` | 5 |
205
+ | `process_heartbeat_interval` | 15 seconds |
206
+ | `process_alive_threshold` | 60 seconds |
207
+ | `message_retention` | 30 days |
208
+ | `message_retention_by_actor_type` | `{}` |
209
+ | `instance_retention_by_actor_type` | `{}`; instances never expire unless listed |
210
+ | `process_retention` | 7 days |
211
+ | `prune_batch_size` | 1,000 |
212
+ | `worker_count` | 1 |
213
+ | `effect_worker_count` | 1 |
214
+ | `broadcast_worker_count` | 1 |
215
+ | `reminder_scheduler_count` | 1 |
216
+
217
+ Payload, state, and result byte limits; retry delay; table prefix; logging;
218
+ wake-up; broadcast; database; and authorization adapters are also configurable.
219
+ Invalid lease intervals, component counts, and size limits fail fast at boot.
220
+
221
+ `max_state_bytes` defaults to 5 MB, which is a limit rather than an operating
222
+ point. A turn copies the whole state, encodes it, and writes the row, so
223
+ committed throughput falls long before that limit: measured on SQLite, about 28
224
+ times between 13 KB and 1 MB of state. See `docs/benchmarks.md` for the curve.
225
+ `warn_state_bytes` is the soft threshold, and it must not exceed
226
+ `max_state_bytes`. Each commit above it reports `solid_objects.state.large` and
227
+ nothing else changes, so an application that already keeps a large state keeps
228
+ working while its operator learns the cost.
93
229
 
94
230
  Keep lease duration comfortably above renewal interval and expected database
95
231
  pause time. A handler can exceed the pass-duration budget because Ruby code is
@@ -152,7 +288,7 @@ Use:
152
288
 
153
289
  Spread large repairs with `available_at:`. Report at least bootstrapped,
154
290
  reconfigured, revived, suspended, and orphaned counts. A nonzero revived count
155
- is evidence that alarms are being lost.
291
+ shows that alarms are lost.
156
292
 
157
293
  Never bulk-update actor state. That bypasses lease ownership and fencing.
158
294
 
@@ -182,6 +318,7 @@ Alert on:
182
318
  - ready and claimed membership counts;
183
319
  - mailbox-full rejections;
184
320
  - actor turn duration and failures;
321
+ - committed state above `warn_state_bytes`;
185
322
  - lost-activation rate;
186
323
  - dead-letter creation;
187
324
  - actor destruction rate;
@@ -218,6 +355,23 @@ per queued item keeps only the last, and the earlier wake-up never happens.
218
355
  Watch this event if your actors schedule from a loop or from a handler that can
219
356
  run more than once. Rescheduling to the same time reports nothing.
220
357
 
358
+ `solid_objects.state.large` reports a committed turn whose state exceeded
359
+ `warn_state_bytes`. The payload carries the actor identity, the `byte_count`
360
+ the commit wrote, and the `threshold_bytes` it passed. It never carries the
361
+ state. The event reports after the commit, so a turn that rolled back reports
362
+ nothing. Every commit above the threshold reports, including a synchronous
363
+ query and a turn that changed nothing, so a hot actor reports once per message.
364
+ Aggregate by actor rather than alert on each event, and watch the reported size
365
+ rather than the event rate: a state that grows without a bound is what this
366
+ event exists to find. `solid-objects-js` emits the same event under the same
367
+ name and payload.
368
+
369
+ `solid_objects.instrumentation.failed` reports a subscriber that raised while
370
+ the runtime reported a committed turn. The payload carries the
371
+ `instrumentation_event` that failed and the `error_class`. The turn itself is
372
+ unaffected, because it already committed. Watch this event to find a broken
373
+ subscriber, which would otherwise be silent.
374
+
221
375
  `solid_objects.component.refreshed` covers every authorized component refresh
222
376
  request. Its payload carries the actor identity, `component_name`,
223
377
  `component_key`, declared `dependencies`, `refresh_method`, the rendered
data/docs/realtime.md CHANGED
@@ -421,8 +421,8 @@ configuration.component_authorization_context = ->(controller:) { controller.cur
421
421
  configuration.payload_authorization_context = ->(connection:) { connection.current_account }
422
422
  ```
423
423
 
424
- The resolved value is what the payload block receives as its second argument and
425
- what `authorize_query` receives as `authorization_context`. A resolver may also
424
+ The payload block receives the resolved value as its second argument, and
425
+ `authorize_query` receives it as `authorization_context`. A resolver may also
426
426
  accept `payload_name:` when the subject depends on which payload was requested.
427
427
  The default returns the connection unchanged, so an application that has not
428
428
  configured one is unaffected.