nickva commented on code in PR #5309: URL: https://github.com/apache/couchdb/pull/5309#discussion_r1806693780
########## src/dreyfus/src/clouseau_rpc.erl: ########## @@ -24,32 +24,138 @@ -export([set_purge_seq/2, get_purge_seq/1, get_root_dir/0]). -export([connected/0]). +%% string represented as binary +-type string_as_binary(_Value) :: binary(). + +-type shard() :: string_as_binary(_). +-type path() :: string_as_binary(_). + +-type error() :: any(). + +-type analyzer_name() :: string_as_binary(_). + +-type field_name() :: string_as_binary(_). + +-type seq() :: non_neg_integer(). +-type commit_seq() :: seq(). +-type purge_seq() :: seq(). +-type committed_seq() :: seq(). +-type pending_seq() :: seq(). +-type update_seq() :: seq(). + +-type analyzer_fields() :: [{field_name(), analyzer_name() | [analyzer_name()]}]. + +-type indexer_pid() :: pid(). + +%% Example of the message +%% {[ +%% {<<"name">>,<<"perfield">>}, +%% {<<"default">>,<<"keyword">>}, +%% {<<"fields">>,{[ +%% {<<"$default">>,<<"standard">>} +%% ]}} +%% ]} +-type analyzer() :: + analyzer_name() + | [ + {string_as_binary(name), analyzer_name()} + | {string_as_binary(default), analyzer()} + | {string_as_binary(fields), {analyzer_fields()}} + | {string_as_binary(stopwords), [field_name()]} + ]. + +-spec open_index(Peer :: pid(), Path :: shard(), Analyzer :: analyzer()) -> + {ok, indexer_pid()} | error(). open_index(Peer, Path, Analyzer) -> rpc({main, clouseau()}, {open, Peer, Path, Analyzer}). +-spec disk_size(Path :: shard()) -> + {ok, {disk_size, non_neg_integer()}} | error(). + disk_size(Path) -> rpc({main, clouseau()}, {disk_size, Path}). + +-spec get_root_dir() -> + {ok, path()} | error(). + get_root_dir() -> rpc({main, clouseau()}, {get_root_dir}). +%% not used ??? +-spec await(Ref :: indexer_pid(), MinSeq :: commit_seq()) -> + ok | error(). + await(Ref, MinSeq) -> rpc(Ref, {await, MinSeq}). +%% deprecated +-spec commit(Ref :: indexer_pid(), NewCommitSeq :: commit_seq()) -> + ok | error(). + commit(Ref, NewCommitSeq) -> rpc(Ref, {commit, NewCommitSeq}). +-type info_result_item() :: + {'disk_size', non_neg_integer()} + | {'doc_count', non_neg_integer()} + | {'doc_del_count', non_neg_integer()} + | {'pending_seq', pending_seq()} + | {'committed_seq', committed_seq()} + | {'purge_seq', purge_seq()}. + +-spec info(Ref :: indexer_pid()) -> + {ok, [info_result_item()]} | error(). + info(Ref) -> rpc(Ref, info). +-spec get_update_seq(Ref :: indexer_pid()) -> + {ok, update_seq()} | error(). + get_update_seq(Ref) -> rpc(Ref, get_update_seq). +-spec set_purge_seq(Ref :: indexer_pid(), Seq :: purge_seq()) -> + ok | error(). + set_purge_seq(Ref, Seq) -> rpc(Ref, {set_purge_seq, Seq}). +-spec get_purge_seq(Ref :: indexer_pid()) -> + {ok, purge_seq()} | error(). + get_purge_seq(Ref) -> rpc(Ref, get_purge_seq). +-type query() :: string_as_binary(_). +-type range_name() :: string_as_binary(_). +-type range_label() :: string_as_binary(_). +-type range_query() :: string_as_binary(_). +-type partition() :: string_as_binary(_). + +-type limit() :: non_neg_integer(). +-type bookmark() :: string_as_binary(_). + +-type search_arg() :: + {'query', query()} + | {'partition', partition()} + | {'limit', limit()} + | {'refresh', boolean()} + | {'after', bookmark()} + | {'sort', group_sort()} + | {'include_fields', [field_name()]} + | {'counts', [field_name()]} + | {'ranges', [{range_name(), [{range_label(), range_query()}]}]} + | {'highlight_fields', [field_name()]} + | {'highlight_pre_tag', string_as_binary(_)} + | {'highlight_post_tag', string_as_binary(_)} + | {'highlight_number', pos_integer()} + | {'highlight_size', pos_integer()} + | {'legacy', boolean()}. Review Comment: Let's not use quotes unless we have to. I don't think we quote atoms in any other types in the code-base so having one place stand-out looks odd. For instance: https://github.com/apache/couchdb/blob/main/src/mem3/src/mem3_reshard.hrl#L22-L44 https://github.com/apache/couchdb/blob/main/src/fabric/include/fabric.hrl#L40-L47 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org