2021-04-29 09:00:46 +00:00
/ * *
* М а ш и н а х р а н я щ а я к о н ф и г у р а ц и ю л и м и т а
* /
2022-01-15 13:10:35 +00:00
namespace java dev.vality.limiter.config
2022-06-23 11:32:58 +00:00
namespace erlang limproto.config
2021-04-29 09:00:46 +00:00
2022-06-14 12:53:59 +00:00
include " proto/base.thrift "
include " proto/domain.thrift "
2021-04-29 09:00:46 +00:00
include " time_range.thrift "
/// Domain
2022-06-14 12:53:59 +00:00
typedef string LimitConfigID
2021-04-29 09:00:46 +00:00
typedef base.Timestamp Timestamp
2022-06-14 12:53:59 +00:00
typedef i64 ShardSize
typedef domain.CurrencySymbolicCode CurrencySymbolicCode
2021-04-29 09:00:46 +00:00
2021-10-11 12:36:17 +00:00
struct LimitConfigParams {
1 : required LimitConfigID id
3 : required Timestamp started_at
4 : required ShardSize shard_size
5 : required time_range.TimeRangeType time_range_type
6 : required LimitContextType context_type
7 : required LimitType type
2022-06-02 08:15:41 +00:00
8 : required LimitScope scope
2021-10-11 12:36:17 +00:00
9 : optional string description
10 : required OperationLimitBehaviour op_behaviour
2024-05-28 11:33:00 +00:00
11 : optional CurrencyConversion currency_conversion
2021-10-11 12:36:17 +00:00
}
2021-04-29 09:00:46 +00:00
struct LimitConfig {
1 : required LimitConfigID id
2 : required string processor_type
3 : required Timestamp created_at
5 : required Timestamp started_at
6 : required ShardSize shard_size
7 : required time_range.TimeRangeType time_range_type
11 : required LimitContextType context_type
8 : optional LimitType type
2022-06-02 08:15:41 +00:00
9 : optional LimitScope scope
2021-04-29 09:00:46 +00:00
10 : optional string description
2021-06-22 05:39:55 +00:00
12 : optional OperationLimitBehaviour op_behaviour
2024-05-28 11:33:00 +00:00
/ * *
* Convert operation ' s amount if its context currency differs from
* limit - turnover metric ( see ` LimitTurnoverAmount ` ) .
*
* If undefined and currency codes do not match , then limiter
* throws ` InvalidOperationCurrency ` exception ( see
* limiter - proto ) .
* /
13 : optional CurrencyConversion currency_conversion
2022-06-08 14:57:49 +00:00
// deprecated
4 : optional LimitBodyType body_type_deprecated
2021-04-29 09:00:46 +00:00
}
2024-05-28 11:33:00 +00:00
struct CurrencyConversion { }
2021-06-22 05:39:55 +00:00
struct OperationLimitBehaviour {
1 : optional OperationBehaviour invoice_payment_refund
}
union OperationBehaviour {
1 : Subtraction subtraction
2 : Addition addition
}
struct Subtraction { }
struct Addition { }
2022-06-08 14:57:49 +00:00
union LimitType {
1 : LimitTypeTurnover turnover
2021-04-29 09:00:46 +00:00
}
2022-06-08 14:57:49 +00:00
struct LimitTypeTurnover {
/ * *
* Metric to account turnover with .
* If undefined , equivalent to specifying ` LimitTurnoverNumber ` .
* /
1 : optional LimitTurnoverMetric metric
2021-04-29 09:00:46 +00:00
}
2022-06-08 14:57:49 +00:00
union LimitTurnoverMetric {
/ * *
* Measure turnover over number of operations .
* /
1 : LimitTurnoverNumber number
/ * *
* Measure turnover over aggregate amount of operations denominated in a single currency .
* In the event operation ' s currency differs from limit ' s currency operation will be accounted
* with appropriate exchange rate fixed against operation ' s timestamp.
* /
2 : LimitTurnoverAmount amount
2021-04-29 09:00:46 +00:00
}
2022-06-08 14:57:49 +00:00
struct LimitTurnoverNumber { }
struct LimitTurnoverAmount {
1 : required CurrencySymbolicCode currency
}
2021-04-29 09:00:46 +00:00
union LimitScope {
2022-06-02 08:15:41 +00:00
/ * *
* Set of scopes .
* Each additional scope increases specificity of a limit . Each possible set describes unique
* limit , e.g . limit with scope { party } and limit with scope { party , shop } are completely
* different limits . Empty set is equivalent to a limit having global scope .
* /
3 : set < LimitScopeType > multi
/ * *
* Single scope .
* Equivalent to the set of scopes containing exactly one scope .
* Kept to preserve backward compatibility with existing data .
* /
2 : LimitScopeType single
// Reserved
// 1
}
2021-04-29 09:00:46 +00:00
union LimitScopeType {
2022-06-02 08:15:41 +00:00
1 : LimitScopeEmptyDetails party
2 : LimitScopeEmptyDetails shop
3 : LimitScopeEmptyDetails wallet
4 : LimitScopeEmptyDetails identity
/ * *
* Scope over data which uniquely identifies payment tool used in a payment .
* E.g . ` domain.BankCard.token ` + ` domain.BankCard.exp_date ` when bank card is being used as
* payment tool .
*
* See : https : //github.com/valitydev/damsel/blob/2e1dbc1a/proto/domain.thrift#L1824-L1830
* /
5 : LimitScopeEmptyDetails payment_tool
2022-09-15 15:41:20 +00:00
6 : LimitScopeEmptyDetails provider
7 : LimitScopeEmptyDetails terminal
8 : LimitScopeEmptyDetails payer_contact_email
2024-06-04 09:08:21 +00:00
/ * *
* Scopes for operation ' s according destination ' s sender or receiver
* tokens .
* /
9 : LimitScopeEmptyDetails sender
10 : LimitScopeEmptyDetails receiver
2024-10-29 10:57:38 +00:00
/ * *
* Scope for operations with destination ' s generic resource fields.
* See damsel ' s "base.Content" https://github.com/valitydev/damsel/blob/ad715bd647bc5cfa822e2b09b1329dab6a2bf295/proto/base.thrift#L20-L25
* and it ' s example with generic payment tool https://github.com/valitydev/damsel/blob/ad715bd647bc5cfa822e2b09b1329dab6a2bf295/proto/domain.thrift#L1816-L1836
* /
11 : LimitScopeDestinationFieldDetails destination_field
2021-04-29 09:00:46 +00:00
}
2022-06-02 08:15:41 +00:00
struct LimitScopeEmptyDetails { }
2021-04-29 09:00:46 +00:00
2024-10-29 10:57:38 +00:00
/ * *
* TODO Support universal context - based field selector
* /
struct LimitScopeDestinationFieldDetails {
1 : required list < string > field_path
}
2021-04-29 09:00:46 +00:00
union LimitContextType {
1 : LimitContextTypePaymentProcessing payment_processing
2022-06-28 15:29:54 +00:00
2 : LimitContextTypeWithdrawalProcessing withdrawal_processing
2021-04-29 09:00:46 +00:00
}
struct LimitContextTypePaymentProcessing { }
2022-06-28 15:29:54 +00:00
struct LimitContextTypeWithdrawalProcessing { }
2021-04-29 09:00:46 +00:00
/// LimitConfig events
struct TimestampedChange {
1 : required base.Timestamp occured_at
2 : required Change change
}
union Change {
1 : CreatedChange created
}
struct CreatedChange {
1 : required LimitConfig limit_config
}
2022-06-08 14:57:49 +00:00
/// Deprecated definitions
union LimitBodyType {
2 : LimitBodyTypeCash cash
}
struct LimitBodyTypeCash {
1 : required CurrencySymbolicCode currency
}