File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## Unreleased
44
5+ - State where ` async ` waits when no worker runs. The ` async ` section of the
6+ README and the runtime section of ` docs/operations.md ` now say that the
7+ generator and the migrations start no role, so an application that serves
8+ web requests alone leaves the message ready until
9+ ` bundle exec solid_objects start ` runs the roles. The message is durable
10+ and waits; it is not lost. ` test/integration/background_pickup_test.rb `
11+ pins it: the message reads ` ready ` and the actor state stays empty until a
12+ worker runs. This matches solid-objects-js #22 , which reported the same gap
13+ for ` runtime.run(signal) ` in the Node package.
14+
515- Add ` examples/at_least_once ` and ` bundle exec rake at_least_once ` , an
616 executable proof that the at-least-once clause fires and that the
717 documented remedy absorbs it. One actor turn stages an effect that writes
Original file line number Diff line number Diff line change @@ -662,6 +662,12 @@ message = order.async(
662662).submit
663663```
664664
665+ ` async ` needs a running actor worker. Installing the engine and migrating the
666+ schema starts no role, so a process that only serves web requests leaves the
667+ message ready. Nothing is lost. The message waits until
668+ ` bundle exec solid_objects start ` runs the roles. See
669+ [ Worker requirements] ( #worker-requirements ) for the feature-by-role table.
670+
665671Use ` available_at: ` to spread bulk work or delay one message:
666672
667673``` ruby
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ Start all configured roles:
3131bundle exec solid_objects start
3232```
3333
34+ The generator and the migrations prepare the database and start nothing. A
35+ process claims ready messages only after this command starts its roles, so an
36+ application that serves web requests alone leaves every ` async ` message ready.
37+ The message is durable and waits for the first process that runs the roles. A
38+ direct call or an explicit ` sync ` needs no running role, because the caller's
39+ own path executes it.
40+
3441The command loads the host application's ` app/actors ` directories before
3542starting any runtime role, even when Rails eager loading is disabled. Actors in
3643the conventional directory do not need initializer references. The targeted
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require "database_test_helper"
4+
5+ class BackgroundPickupTest < ActiveSupport ::TestCase
6+ class MailboxActor < SolidObjects ::Actor
7+ actor_type "background-pickup-mailbox"
8+
9+ attribute :delivered , default : 0
10+
11+ def receive
12+ self . delivered += 1
13+ end
14+ end
15+
16+ test "leaves an async message ready until a worker runs the roles" do
17+ message = MailboxActor . ref ( "inbox" ) . async . receive
18+
19+ assert_equal "ready" , message . status
20+ assert_empty SolidObjects ::Instance . find_by! (
21+ actor_type : "background-pickup-mailbox" , actor_id : "inbox"
22+ ) . state
23+
24+ worker = SolidObjects ::Worker . new
25+ begin
26+ worker . run_until_idle
27+ ensure
28+ worker . stop
29+ end
30+
31+ assert_equal "completed" , message . status
32+ assert_equal (
33+ { "delivered" => 1 } ,
34+ SolidObjects ::Instance . find_by! ( actor_type : "background-pickup-mailbox" , actor_id : "inbox" ) . state
35+ )
36+ end
37+ end
You can’t perform that action at this time.
0 commit comments