2022-06-14 12:53:59 +00:00
|
|
|
|
include "proto/base.thrift"
|
|
|
|
|
include "proto/domain.thrift"
|
2023-04-04 13:05:46 +00:00
|
|
|
|
include "proto/limiter_config.thrift"
|
2022-06-14 12:53:59 +00:00
|
|
|
|
include "limiter_base.thrift"
|
2022-06-28 15:29:54 +00:00
|
|
|
|
include "limiter_payproc_context.thrift"
|
|
|
|
|
include "limiter_withdrawal_context.thrift"
|
2021-04-29 09:00:46 +00:00
|
|
|
|
|
2022-01-15 13:10:35 +00:00
|
|
|
|
namespace java dev.vality.limiter
|
2022-06-23 11:32:58 +00:00
|
|
|
|
namespace erlang limproto.limiter
|
2019-09-20 09:24:41 +00:00
|
|
|
|
|
2022-06-14 12:53:59 +00:00
|
|
|
|
typedef string LimitChangeID
|
|
|
|
|
typedef string LimitID
|
2021-04-29 09:00:46 +00:00
|
|
|
|
typedef base.ID PartyID
|
|
|
|
|
typedef base.ID ShopID
|
|
|
|
|
typedef base.ID WalletID
|
|
|
|
|
typedef base.ID IdentityID
|
2022-06-14 12:53:59 +00:00
|
|
|
|
typedef limiter_base.AmountRange AmountRange
|
2023-03-01 11:25:59 +00:00
|
|
|
|
typedef domain.DataRevision Version
|
2023-04-04 13:05:46 +00:00
|
|
|
|
typedef limiter_config.LimitContextType LimitContextType
|
2019-09-24 12:22:23 +00:00
|
|
|
|
|
2022-06-28 15:29:54 +00:00
|
|
|
|
struct LimitContext {
|
|
|
|
|
1: optional limiter_withdrawal_context.Context withdrawal_processing
|
|
|
|
|
2: optional limiter_payproc_context.Context payment_processing
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-24 12:35:30 +00:00
|
|
|
|
/**
|
2021-04-29 09:00:46 +00:00
|
|
|
|
* https://en.wikipedia.org/wiki/Vector_clock
|
|
|
|
|
**/
|
|
|
|
|
struct VectorClock {
|
|
|
|
|
1: required base.Opaque state
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-31 12:18:23 +00:00
|
|
|
|
struct LatestClock {}
|
|
|
|
|
|
2019-09-24 12:35:30 +00:00
|
|
|
|
/**
|
2021-04-29 09:00:46 +00:00
|
|
|
|
* Структура, позволяющая установить причинно-следственную связь операций внутри сервиса
|
|
|
|
|
**/
|
|
|
|
|
union Clock {
|
|
|
|
|
1: VectorClock vector
|
2021-05-31 12:18:23 +00:00
|
|
|
|
2: LatestClock latest
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Limit {
|
|
|
|
|
1: required LimitID id
|
2022-06-14 12:53:59 +00:00
|
|
|
|
2: required domain.Amount amount
|
2021-04-29 09:00:46 +00:00
|
|
|
|
3: optional base.Timestamp creation_time
|
|
|
|
|
4: optional string description
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
struct LimitChange {
|
|
|
|
|
1: required LimitID id
|
|
|
|
|
2: required LimitChangeID change_id
|
2023-03-01 11:25:59 +00:00
|
|
|
|
3: optional Version version
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
exception LimitNotFound {}
|
|
|
|
|
exception LimitChangeNotFound {}
|
|
|
|
|
exception ForbiddenOperationAmount {
|
2022-06-14 12:53:59 +00:00
|
|
|
|
1: required domain.Amount amount
|
|
|
|
|
2: required AmountRange allowed_range
|
2021-04-29 09:00:46 +00:00
|
|
|
|
}
|
2023-04-04 13:05:46 +00:00
|
|
|
|
exception InvalidOperationCurrency {
|
|
|
|
|
1: required domain.CurrencySymbolicCode currency
|
|
|
|
|
2: required domain.CurrencySymbolicCode expected_currency
|
|
|
|
|
}
|
|
|
|
|
exception OperationContextNotSupported {
|
|
|
|
|
1: required LimitContextType context_type
|
|
|
|
|
}
|
|
|
|
|
exception PaymentToolNotSupported {
|
|
|
|
|
1: required string payment_tool
|
|
|
|
|
}
|
2021-04-29 09:00:46 +00:00
|
|
|
|
|
|
|
|
|
service Limiter {
|
2022-07-05 16:27:18 +00:00
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
Limit Get(1: LimitID id, 2: Clock clock, 3: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
2: base.InvalidRequest e2
|
|
|
|
|
)
|
2022-07-05 16:27:18 +00:00
|
|
|
|
|
2023-03-01 11:25:59 +00:00
|
|
|
|
Limit GetVersioned(1: LimitID id, 2: Version version, 3: Clock clock, 4: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
2: base.InvalidRequest e2
|
|
|
|
|
)
|
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
Clock Hold(1: LimitChange change, 2: Clock clock, 3: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
3: base.InvalidRequest e2
|
2023-04-04 13:05:46 +00:00
|
|
|
|
4: InvalidOperationCurrency e3
|
|
|
|
|
5: OperationContextNotSupported e4
|
|
|
|
|
6: PaymentToolNotSupported e5
|
2021-04-29 09:00:46 +00:00
|
|
|
|
)
|
2022-07-05 16:27:18 +00:00
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
Clock Commit(1: LimitChange change, 2: Clock clock, 3: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
2: LimitChangeNotFound e2,
|
|
|
|
|
3: base.InvalidRequest e3,
|
|
|
|
|
4: ForbiddenOperationAmount e4
|
|
|
|
|
)
|
2022-07-05 16:27:18 +00:00
|
|
|
|
|
|
|
|
|
Clock Rollback(1: LimitChange change, 2: Clock clock, 3: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
2: LimitChangeNotFound e2,
|
|
|
|
|
3: base.InvalidRequest e3
|
|
|
|
|
)
|
|
|
|
|
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|