Skip to content

Commit cd9805a

Browse files
authored
local_queue_path config parameter to defined disk message queue path (#77)
* New optional parameter local_queue_path in global_client_options section * fix config processing * Update CONFIGURATION.md
1 parent 8ad5bfc commit cd9805a

4 files changed

+23
-1
lines changed

CONFIGURATION.md

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ batch_size | P | 1 .. 2147483647 | 1000000
111111
delivery_report_only_error | P | true, false | false | Only provide delivery reports for failed messages
112112
delivery_report_callback | P | module or fun/2 | undefined| A callback where delivery reports are sent (`erlkaf_producer_callbacks` behaviour)
113113
sticky_partitioning_linger_ms | P | 0 .. 900000 | 10 | Delay in milliseconds to wait to assign new sticky partitions for each topic. By default, set to double the time of linger.ms. To disable sticky behavior, set to 0. This behavior affects messages with the key NULL in all cases, and messages with key lengths of zero when the consistent_random partitioner is in use. These messages would otherwise be assigned randomly. A higher value allows for more effective batching of these messages.
114+
local_queue_path | P | | | Path to directory where local disk queue files will be paced if queue_buffering_overflow_strategy for producer set to local_disk_queue. Default value is priv directory of erlkaf application.
114115

115116
## Topic configuration properties
116117

src/erlkaf_config.erl

+6
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ is_erlkaf_config(stats_callback = K, V) ->
8282
check_callback(K, V, 2);
8383
is_erlkaf_config(oauthbearer_token_refresh_callback = K, V) ->
8484
check_callback(K, V, 1);
85+
is_erlkaf_config(local_queue_path = K, []) -> throw({error, {options, {K, []}}});
86+
is_erlkaf_config(local_queue_path = K, V) ->
87+
case io_lib:latin1_char_list(V) of
88+
true -> true;
89+
_ -> throw({error, {options, {K, V}}})
90+
end;
8591
is_erlkaf_config(queue_buffering_overflow_strategy = K, V) ->
8692
case V of
8793
local_disk_queue ->

src/erlkaf_local_queue.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
]).
1212

1313
new(ClientId) ->
14-
Path = erlkaf_utils:get_priv_path(ClientId),
14+
Path = erlkaf_utils:get_local_queue_path(ClientId),
1515
?LOG_INFO("persistent queue path: ~p", [Path]),
1616
esq:new(Path).
1717

src/erlkaf_utils.erl

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
-export([
44
get_priv_path/1,
5+
get_local_queue_path/1,
56
get_env/1,
67
get_env/2,
78
lookup/2,
@@ -15,6 +16,20 @@
1516
parralel_exec/2
1617
]).
1718

19+
-spec get_local_queue_path(string() | atom()) -> string() | undefined.
20+
get_local_queue_path(File) ->
21+
case application:get_env(erlkaf, global_client_options) of
22+
undefined ->
23+
get_priv_path(File);
24+
{ok, Val} ->
25+
case lookup(local_queue_path, Val) of
26+
undefined ->
27+
get_priv_path(File);
28+
Path ->
29+
filename:join(Path, File)
30+
end
31+
end.
32+
1833
get_priv_path(File) ->
1934
case code:priv_dir(erlkaf) of
2035
{error, bad_name} ->

0 commit comments

Comments
 (0)