mirror of
https://github.com/valitydev/limiter.git
synced 2024-11-06 00:55:22 +00:00
fix bug calc shard id(same usec); add in config day limit
This commit is contained in:
parent
c1aa30005f
commit
d6561f9ddf
@ -415,8 +415,8 @@ marshal_timestamp(DateTime) ->
|
||||
calculate_shard_id(Timestamp, Config) ->
|
||||
StartedAt = started_at(Config),
|
||||
ShardSize = shard_size(Config),
|
||||
{StartDateTime, USec} = lim_range_codec:parse_timestamp(StartedAt),
|
||||
{CurrentDateTime, USec} = lim_range_codec:parse_timestamp(Timestamp),
|
||||
{StartDateTime, _USec0} = lim_range_codec:parse_timestamp(StartedAt),
|
||||
{CurrentDateTime, _USec1} = lim_range_codec:parse_timestamp(Timestamp),
|
||||
case time_range_type(Config) of
|
||||
{calendar, Range} ->
|
||||
Units = calculate_time_units(Range, CurrentDateTime, StartDateTime),
|
||||
|
@ -62,6 +62,15 @@ handle_function_('Get', {LimitID}, LimitContext, _Opts) ->
|
||||
woody_error:raise(business, #limiter_cfg_LimitConfigNotFound{})
|
||||
end.
|
||||
|
||||
mk_limit_config(<<"ShopDayTurnover">>) ->
|
||||
{ok, #{
|
||||
processor_type => <<"TurnoverProcessor">>,
|
||||
type => turnover,
|
||||
scope => {scope, shop},
|
||||
shard_size => 12,
|
||||
context_type => payment_processing,
|
||||
time_range_type => {calendar, day}
|
||||
}};
|
||||
mk_limit_config(<<"ShopMonthTurnover">>) ->
|
||||
{ok, #{
|
||||
processor_type => <<"TurnoverProcessor">>,
|
||||
|
Loading…
Reference in New Issue
Block a user