Skip to content

Commit a91d512

Browse files
author
steve.brazier
committed
add allowed killing day config
1 parent 61b45ee commit a91d512

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

config/dev.exs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config :chaos_spawn, :fake_fixed_now, true
55
#config :chaos_spawn, :kill_tick, 1000
66
#config :chaos_spawn, :kill_probability, 0.1
77
#config :chaos_spawn, :only_kill_between, {{10, 00, 00}, {16, 00, 00}}
8+
#config :chaos_spawn, :only_kill_on_days, [:mon, :tue, :wed, :thu, :fri]
89
# config :chaos_spawn, :skip_worker_modules, [
910
# Chaotic.WorkerTest.Example
1011
# ]

lib/chaos_spawn/config.ex

+18-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ defmodule ChaosSpawn.Config do
66
@default_kill_tick 1000 # 1 second
77
@default_kill_prob 0.015 # Kill about 1 process a minute
88
@default_kill_window :anytime
9+
@default_kill_days :anyday
910
@default_skipped_workers [] # Nothing skipped by default
1011

1112
def kill_config do
12-
case get_setting(:only_kill_between, @default_kill_window) do
13-
:anytime -> []
14-
time_window -> [{:only_kill_between, time_window}]
15-
end
13+
[]
14+
|> add_kill_window
15+
|> add_allowed_killing_days
1616
end
1717

1818
def kill_tick, do: get_setting(:kill_tick, @default_kill_tick)
@@ -26,4 +26,18 @@ defmodule ChaosSpawn.Config do
2626
Application.get_env(:chaos_spawn, setting, default)
2727
end
2828

29+
defp add_kill_window(config) do
30+
case get_setting(:only_kill_between, @default_kill_window) do
31+
:anytime -> config
32+
time_window -> [{:only_kill_between, time_window} | config]
33+
end
34+
end
35+
36+
defp add_allowed_killing_days(config) do
37+
case get_setting(:only_kill_on_days, @default_kill_days) do
38+
:anyday -> config
39+
days -> [{:only_kill_on_days, days} | config]
40+
end
41+
end
42+
2943
end

0 commit comments

Comments
 (0)