Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/async/service/supervisor/supervised.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def supervisor_worker(state: nil)
def prepare!(instance, state: nil)
super(instance)

supervisor_worker(state: state).run
return supervisor_worker(state: state).tap(&:run)
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions test/async/service/supervised.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ def setup(container)
worker_task&.stop
end

it "returns the worker from prepare!" do
environment = Async::Service::Environment.build(root: @root) do
name "simple-service"

service_class {SimpleService}

include Async::Service::Managed::Environment
include Async::Service::Supervisor::Supervised
end

worker = environment.evaluator.prepare!(nil)
expect(worker).to be_a(Async::Service::Supervisor::Worker)

# Wait for the worker to register with the supervisor:
event = registration_monitor.pop
expect(event.supervisor_controller.process_id).to be == ::Process.pid
end

it "can register explicit worker state" do
environment = Async::Service::Environment.build(root: @root) do
name "simple-service"
Expand Down
Loading