Skip to content

Commit

Permalink
temporal: add state config
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed May 31, 2023
1 parent 26c4411 commit f9d5bea
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
7 changes: 6 additions & 1 deletion examples/temporal/devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

namespaces = [ "mynamespace" ];

ephemeral = false;
state = {
ephemeral = false;
sqlite-pragma = {
journal_mode = "wal";
};
};
};
}
43 changes: 30 additions & 13 deletions src/modules/services/temporal.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let
"--ui-port=${toString cfg.ui.port}"
] ++
(lib.forEach cfg.namespaces (namespace: "--namespace=${namespace}")) ++
(lib.optionals (!cfg.ephemeral) [ "--db-filename=${databaseFile}" ]);
(lib.optionals (!cfg.state.ephemeral) [ "--db-filename=${databaseFile}" ]) ++
(lib.mapAttrsToList (name: value: "--sqlite-pragma ${name}=${value}") cfg.state.sqlite-pragma);
in
{
options.services.temporal = {
Expand Down Expand Up @@ -67,22 +68,38 @@ in
description = "UI configuration.";
};

ephemeral = lib.mkOption {
type = types.bool;
default = true;
description = "When enabled, the Temporal state gets lost when the process exists.";
};

namespaces = lib.mkOption {
type = types.listOf types.str;
default = [ ];
description = "Specify namespaces that should be pre-created (namespace \"default\" is always created).";
example = lib.literalExpression ''
[
"my-namespace"
"my-other-namespace"
]
'';
example = [
"my-namespace"
"my-other-namespace"
];
};

state = lib.mkOption {
type = types.submodule {
options = {
ephemeral = lib.mkOption {
type = types.bool;
default = true;
description = "When enabled, the Temporal state gets lost when the process exists.";
};

sqlite-pragma = lib.mkOption {
type = types.attrsOf types.str;
default = { };
description = "Sqlite pragma statements";
example = {
journal_mode = "wal";
synchronous = "2";
};
};
};
};
default = { };
description = "State configuration.";
};
};

Expand Down

0 comments on commit f9d5bea

Please sign in to comment.