Skip to content

Commit 2edd17f

Browse files
author
Michael Kipper
committed
Review comments
1 parent 07035fb commit 2edd17f

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,10 @@ You should run a simulation with your workloads to determine an efficient
471471
scaling factor that will produce a time-to-open reduction but isn't too
472472
sensitive.
473473

474-
To disable host-based circuits, set the environment variable
475-
`SEMIAN_CIRCUIT_BREAKER_IMPL` to `ruby`.
474+
The circuit breaker implementation is based on the environment variable
475+
`SEMIAN_CIRCUIT_BREAKER_IMPL`. Set it to `worker` to disable sharing circuit
476+
state and `host` to enable host-based circuits. The default is `worker` for
477+
backward compatibility.
476478

477479
### Bulkheading
478480

ext/semian/semian.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ use_c_circuits() {
8181
fprintf(stderr, "Warning: Defaulting to worker-based circuit breaker implementation\n");
8282
return 0;
8383
} else {
84-
if (!strcmp(circuit_impl, "ruby") || !strcmp(circuit_impl, "worker")) {
84+
if (!strcmp(circuit_impl, "worker")) {
8585
return 0;
86-
} else if (!strcmp(circuit_impl, "c") || !strcmp(circuit_impl, "host")) {
86+
} else if (!strcmp(circuit_impl, "host")) {
8787
return 1;
8888
} else {
8989
fprintf(stderr, "Warning: Unknown circuit breaker implementation: '%s'\n", circuit_impl);

test/simple_integer_test.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,24 @@ def test_reset
4343
assert_equal(0, @integer.value)
4444
end
4545

46-
if ENV['SEMIAN_CIRCUIT_BREAKER_IMPL'] != 'ruby'
47-
# Without locks, this only passes around 1 in every 5 runs
48-
def test_increment_race
49-
process_count = 255
50-
100.times do
51-
process_count.times do
52-
fork do
53-
value = @integer.increment(1)
54-
exit!(value)
55-
end
46+
# Without locks, this only passes around 1 in every 5 runs
47+
def test_increment_race
48+
process_count = 255
49+
100.times do
50+
process_count.times do
51+
fork do
52+
value = @integer.increment(1)
53+
exit!(value)
5654
end
57-
exit_codes = Process.waitall.map { |_, status| status.exitstatus }
58-
# No two processes should exit with the same exit code
55+
end
56+
exit_codes = Process.waitall.map { |_, status| status.exitstatus }
57+
58+
if ENV['SEMIAN_CIRCUIT_BREAKER_IMPL'] == 'host'
59+
# Host-based circuits: No two processes should exit with the same exit code
5960
assert_equal(process_count, exit_codes.uniq.length)
61+
else
62+
# Worker-based circuits: All the processes should exit with the same code
63+
assert_equal(1, exit_codes.uniq.length)
6064
end
6165
end
6266
end

test/simple_sliding_window_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_sliding_window_reject
5252
end
5353

5454
def test_sliding_window_reject_failure
55-
skip if ENV['SEMIAN_CIRCUIT_BREAKER_IMPL'] == 'ruby'
55+
skip if ENV['SEMIAN_CIRCUIT_BREAKER_IMPL'] == 'worker'
5656
@sliding_window << 0 << 1 << 2 << 3 << 4 << 5 << 6 << 7
5757
assert_equal(6, @sliding_window.size)
5858
assert_sliding_window(@sliding_window, [2, 3, 4, 5, 6, 7], 6)

0 commit comments

Comments
 (0)