Current section
Files
Jump to
Current section
Files
src/gabsurd@utility.erl
-module(gabsurd@utility).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/gabsurd/utility.gleam").
-export([cleanup_queue/2, get_schema_version/1]).
-export_type([cleanup_result/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(" Cleanup and utility operations for the Absurd durable workflow system.\n").
-type cleanup_result() :: {cleanup_result, binary(), integer(), integer()}.
-file("src/gabsurd/utility.gleam", 14).
?DOC(" Run cleanup for a specific queue (deletes old completed/failed tasks and processed events).\n").
-spec cleanup_queue(gabsurd@client:db(), binary()) -> {ok,
list(cleanup_result())} |
{error, gabsurd@client:gabsurd_error()}.
cleanup_queue(Db, Queue_name) ->
gleam@result:'try'(
gabsurd@client:query_many(
Db,
gabsurd@sql:cleanup_all_queues(Queue_name)
),
fun(Rows) ->
{ok,
gleam@list:map(
Rows,
fun(Row) ->
{cleanup_result,
erlang:element(2, Row),
erlang:element(3, Row),
erlang:element(4, Row)}
end
)}
end
).
-file("src/gabsurd/utility.gleam", 34).
?DOC(" Get the schema version from the database.\n").
-spec get_schema_version(gabsurd@client:db()) -> {ok, binary()} |
{error, gabsurd@client:gabsurd_error()}.
get_schema_version(Db) ->
gleam@result:'try'(
gabsurd@client:query_one(Db, gabsurd@sql:get_schema_version()),
fun(Row) -> {ok, erlang:element(2, Row)} end
).