Skip to content

Commit 5813829

Browse files
Set managed service container name. Fixes #7.
1 parent a13d319 commit 5813829

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

lib/async/service/managed/environment.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def health_check_timeout
3636
# @returns [Hash] The options for the container.
3737
def container_options
3838
{
39+
name: self.name,
3940
restart: true,
4041
count: self.count,
4142
startup_timeout: self.startup_timeout,

test/async/service/managed/environment.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
it "provides default container options" do
2424
options = evaluator.container_options
2525

26+
expect(options[:name]).to be == "test-managed"
2627
expect(options[:restart]).to be == true
2728
expect(options[:count]).to be == 3
2829
expect(options[:health_check_timeout]).to be == 10

test/async/service/managed/service.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,40 @@
5757

5858
# Verify the container options were passed correctly
5959
expect(options_captured).not.to be_nil
60+
expect(options_captured[:name]).to be == "test-container"
6061
expect(options_captured[:count]).to be == 2
6162
expect(options_captured[:health_check_timeout]).to be == 5
6263
expect(options_captured[:restart]).to be == true
6364
end
6465

66+
it "allows container options to override the process name" do
67+
configuration = Async::Service::Configuration.build do
68+
service "test-container" do
69+
service_class Async::Service::Managed::Service
70+
include Async::Service::Managed::Environment
71+
72+
container_options do
73+
super().merge(name: "custom-process-name")
74+
end
75+
end
76+
end
77+
78+
service = configuration.services.first
79+
container = Async::Container.new
80+
options_captured = nil
81+
82+
mock(container) do |mock|
83+
mock.replace(:run) do |**options, &block|
84+
options_captured = options
85+
nil
86+
end
87+
end
88+
89+
service.setup(container)
90+
91+
expect(options_captured[:name]).to be == "custom-process-name"
92+
end
93+
6594
with "integration test" do
6695
include Sus::Fixtures::Async::SchedulerContext
6796

0 commit comments

Comments
 (0)