feat(ds): Implement format_status callback

Reduce volume of logs and crash reports from DS
This commit is contained in:
ieQu1 2024-05-19 09:20:16 +02:00
parent 1526c527d0
commit e4a73f003a
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
2 changed files with 27 additions and 2 deletions

View File

@ -33,7 +33,7 @@
-export([start_link/2, store_batch/3]). -export([start_link/2, store_batch/3]).
%% behavior callbacks: %% behavior callbacks:
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). -export([init/1, format_status/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
%% internal exports: %% internal exports:
-export([]). -export([]).
@ -129,6 +129,13 @@ init([DB, Shard]) ->
}, },
{ok, S}. {ok, S}.
format_status(#s{db = DB, shard = Shard, queue = Q}) ->
#{
db => DB,
shard => Shard,
queue => queue:len(Q)
}.
handle_call( handle_call(
#enqueue_req{ #enqueue_req{
messages = Msgs, messages = Msgs,

View File

@ -52,7 +52,7 @@
]). ]).
%% gen_server %% gen_server
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). -export([init/1, format_status/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
%% internal exports: %% internal exports:
-export([db_dir/1]). -export([db_dir/1]).
@ -586,6 +586,24 @@ init({ShardId, Options}) ->
commit_metadata(S), commit_metadata(S),
{ok, S}. {ok, S}.
format_status(#s{shard_id = ShardId, db = DB, cf_refs = CFRefs, schema = Schema, shard = Shard}) ->
#{
id => ShardId,
db => DB,
cf_refs => CFRefs,
schema => Schema,
shard =>
maps:map(
fun
(?GEN_KEY(_), _Schema) ->
'...';
(_K, Val) ->
Val
end,
Shard
)
}.
handle_call(#call_update_config{since = Since, options = Options}, _From, S0) -> handle_call(#call_update_config{since = Since, options = Options}, _From, S0) ->
case handle_update_config(S0, Since, Options) of case handle_update_config(S0, Since, Options) of
S = #s{} -> S = #s{} ->