-module(lightspeed@integration@stack).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/lightspeed/integration/stack.gleam").
-export([commerce_stack/0, collaboration_stack/0, mixed_runtime_stack/0, valid/1, signature/1, setup_step_label/1, setup_signature/1, teardown_step_label/1, teardown_signature/1, lifecycle_signature/1, name/1, setup_steps/1, teardown_steps/1]).
-export_type([setup_step/0, teardown_step/0, reference_stack/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Reference integration stacks with reproducible setup/teardown (M26).\n").
-type setup_step() :: prepare_data_layer |
start_job_workers |
start_mailer |
enable_telemetry_pipelines |
seed_reference_data.
-type teardown_step() :: drain_jobs |
flush_outbox |
disable_telemetry_pipelines |
cleanup_data_fixtures.
-type reference_stack() :: {reference_stack,
binary(),
lightspeed@integration@data:pattern(),
lightspeed@integration@jobs:pattern(),
lightspeed@integration@mail:pattern(),
lightspeed@integration@ops:pattern(),
list(setup_step()),
list(teardown_step())}.
-file("src/lightspeed/integration/stack.gleam", 175).
-spec default_teardown_steps() -> list(teardown_step()).
default_teardown_steps() ->
[drain_jobs,
flush_outbox,
disable_telemetry_pipelines,
cleanup_data_fixtures].
-file("src/lightspeed/integration/stack.gleam", 165).
-spec default_setup_steps() -> list(setup_step()).
default_setup_steps() ->
[prepare_data_layer,
start_job_workers,
start_mailer,
enable_telemetry_pipelines,
seed_reference_data].
-file("src/lightspeed/integration/stack.gleam", 40).
?DOC(" Commerce-oriented stack.\n").
-spec commerce_stack() -> reference_stack().
commerce_stack() ->
{reference_stack,
<<"commerce_stack"/utf8>>,
lightspeed@integration@data:crud_pattern(),
lightspeed@integration@jobs:critical_path_pattern(),
lightspeed@integration@mail:transactional_pattern(),
lightspeed@integration@ops:production_pattern(),
default_setup_steps(),
default_teardown_steps()}.
-file("src/lightspeed/integration/stack.gleam", 53).
?DOC(" Collaboration/chat-oriented stack.\n").
-spec collaboration_stack() -> reference_stack().
collaboration_stack() ->
{reference_stack,
<<"collaboration_stack"/utf8>>,
lightspeed@integration@data:event_stream_pattern(),
lightspeed@integration@jobs:mixed_runtime_pattern(),
lightspeed@integration@mail:digest_pattern(),
lightspeed@integration@ops:mixed_runtime_pattern(),
default_setup_steps(),
default_teardown_steps()}.
-file("src/lightspeed/integration/stack.gleam", 66).
?DOC(" Mixed-runtime baseline stack.\n").
-spec mixed_runtime_stack() -> reference_stack().
mixed_runtime_stack() ->
{reference_stack,
<<"mixed_runtime_stack"/utf8>>,
lightspeed@integration@data:crud_pattern(),
lightspeed@integration@jobs:mixed_runtime_pattern(),
lightspeed@integration@mail:digest_pattern(),
lightspeed@integration@ops:mixed_runtime_pattern(),
default_setup_steps(),
default_teardown_steps()}.
-file("src/lightspeed/integration/stack.gleam", 190).
-spec contains_teardown(list(teardown_step()), teardown_step()) -> boolean().
contains_teardown(Steps, Expected) ->
case Steps of
[] ->
false;
[Step | Rest] ->
case Step =:= Expected of
true ->
true;
false ->
contains_teardown(Rest, Expected)
end
end.
-file("src/lightspeed/integration/stack.gleam", 179).
-spec contains_setup(list(setup_step()), setup_step()) -> boolean().
contains_setup(Steps, Expected) ->
case Steps of
[] ->
false;
[Step | Rest] ->
case Step =:= Expected of
true ->
true;
false ->
contains_setup(Rest, Expected)
end
end.
-file("src/lightspeed/integration/stack.gleam", 79).
?DOC(" Validate stack-level integration constraints.\n").
-spec valid(reference_stack()) -> boolean().
valid(Stack) ->
(((((((((((lightspeed@integration@data:valid(erlang:element(3, Stack))
andalso lightspeed@integration@jobs:valid(erlang:element(4, Stack)))
andalso lightspeed@integration@mail:valid(erlang:element(5, Stack)))
andalso lightspeed@integration@ops:valid(erlang:element(6, Stack)))
andalso contains_setup(erlang:element(7, Stack), prepare_data_layer))
andalso contains_setup(erlang:element(7, Stack), start_job_workers))
andalso contains_setup(erlang:element(7, Stack), start_mailer))
andalso contains_setup(erlang:element(7, Stack), enable_telemetry_pipelines))
andalso contains_setup(erlang:element(7, Stack), seed_reference_data))
andalso contains_teardown(erlang:element(8, Stack), drain_jobs))
andalso contains_teardown(erlang:element(8, Stack), flush_outbox))
andalso contains_teardown(
erlang:element(8, Stack),
disable_telemetry_pipelines
))
andalso contains_teardown(erlang:element(8, Stack), cleanup_data_fixtures).
-file("src/lightspeed/integration/stack.gleam", 96).
?DOC(" Stable stack signature for fixtures and docs.\n").
-spec signature(reference_stack()) -> binary().
signature(Stack) ->
<<<<<<<<<<<<<<<<<<"stack:"/utf8, (erlang:element(2, Stack))/binary>>/binary,
"|"/utf8>>/binary,
(lightspeed@integration@data:signature(
erlang:element(3, Stack)
))/binary>>/binary,
"|"/utf8>>/binary,
(lightspeed@integration@jobs:signature(
erlang:element(4, Stack)
))/binary>>/binary,
"|"/utf8>>/binary,
(lightspeed@integration@mail:signature(erlang:element(5, Stack)))/binary>>/binary,
"|"/utf8>>/binary,
(lightspeed@integration@ops:signature(erlang:element(6, Stack)))/binary>>.
-file("src/lightspeed/integration/stack.gleam", 135).
?DOC(" Setup-step label.\n").
-spec setup_step_label(setup_step()) -> binary().
setup_step_label(Step) ->
case Step of
prepare_data_layer ->
<<"prepare_data_layer"/utf8>>;
start_job_workers ->
<<"start_job_workers"/utf8>>;
start_mailer ->
<<"start_mailer"/utf8>>;
enable_telemetry_pipelines ->
<<"enable_telemetry_pipelines"/utf8>>;
seed_reference_data ->
<<"seed_reference_data"/utf8>>
end.
-file("src/lightspeed/integration/stack.gleam", 204).
-spec join_with(binary(), list(binary())) -> binary().
join_with(Separator, Values) ->
case Values of
[] ->
<<""/utf8>>;
[Value] ->
Value;
[Value@1 | Rest] ->
<<<<Value@1/binary, Separator/binary>>/binary,
(join_with(Separator, Rest))/binary>>
end.
-file("src/lightspeed/integration/stack.gleam", 110).
?DOC(" Stable setup signature.\n").
-spec setup_signature(reference_stack()) -> binary().
setup_signature(Stack) ->
<<"setup="/utf8,
(join_with(
<<","/utf8>>,
gleam@list:map(erlang:element(7, Stack), fun setup_step_label/1)
))/binary>>.
-file("src/lightspeed/integration/stack.gleam", 146).
?DOC(" Teardown-step label.\n").
-spec teardown_step_label(teardown_step()) -> binary().
teardown_step_label(Step) ->
case Step of
drain_jobs ->
<<"drain_jobs"/utf8>>;
flush_outbox ->
<<"flush_outbox"/utf8>>;
disable_telemetry_pipelines ->
<<"disable_telemetry_pipelines"/utf8>>;
cleanup_data_fixtures ->
<<"cleanup_data_fixtures"/utf8>>
end.
-file("src/lightspeed/integration/stack.gleam", 115).
?DOC(" Stable teardown signature.\n").
-spec teardown_signature(reference_stack()) -> binary().
teardown_signature(Stack) ->
<<"teardown="/utf8,
(join_with(
<<","/utf8>>,
gleam@list:map(erlang:element(8, Stack), fun teardown_step_label/1)
))/binary>>.
-file("src/lightspeed/integration/stack.gleam", 121).
?DOC(" Stable lifecycle signature.\n").
-spec lifecycle_signature(reference_stack()) -> binary().
lifecycle_signature(Stack) ->
<<<<<<<<(signature(Stack))/binary, "|"/utf8>>/binary,
(setup_signature(Stack))/binary>>/binary,
"|"/utf8>>/binary,
(teardown_signature(Stack))/binary>>.
-file("src/lightspeed/integration/stack.gleam", 130).
?DOC(" Stack name.\n").
-spec name(reference_stack()) -> binary().
name(Stack) ->
erlang:element(2, Stack).
-file("src/lightspeed/integration/stack.gleam", 156).
?DOC(" Setup steps.\n").
-spec setup_steps(reference_stack()) -> list(setup_step()).
setup_steps(Stack) ->
erlang:element(7, Stack).
-file("src/lightspeed/integration/stack.gleam", 161).
?DOC(" Teardown steps.\n").
-spec teardown_steps(reference_stack()) -> list(teardown_step()).
teardown_steps(Stack) ->
erlang:element(8, Stack).