2021-04-29 09:00:46 +00:00
|
|
|
|
include "base.thrift"
|
|
|
|
|
include "limiter_context.thrift"
|
|
|
|
|
|
2019-09-20 09:24:41 +00:00
|
|
|
|
namespace java com.rbkmoney.limiter
|
|
|
|
|
namespace erlang limiter
|
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
typedef base.ID LimitChangeID
|
|
|
|
|
typedef base.ID LimitID
|
|
|
|
|
typedef base.ID PartyID
|
|
|
|
|
typedef base.ID ShopID
|
|
|
|
|
typedef base.ID WalletID
|
|
|
|
|
typedef base.ID IdentityID
|
|
|
|
|
typedef limiter_context.LimitContext LimitContext
|
2019-09-24 12:22:23 +00:00
|
|
|
|
|
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
|
2021-04-29 09:00:46 +00:00
|
|
|
|
2: required base.Amount amount
|
|
|
|
|
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
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 09:00:46 +00:00
|
|
|
|
exception LimitNotFound {}
|
|
|
|
|
exception LimitChangeNotFound {}
|
|
|
|
|
exception ForbiddenOperationAmount {
|
2019-09-24 12:22:23 +00:00
|
|
|
|
1: required base.Amount amount
|
2021-04-29 09:00:46 +00:00
|
|
|
|
2: required base.AmountRange allowed_range
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
service Limiter {
|
|
|
|
|
Limit Get(1: LimitID id, 2: Clock clock, 3: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
2: base.InvalidRequest e2
|
|
|
|
|
)
|
|
|
|
|
Clock Hold(1: LimitChange change, 2: Clock clock, 3: LimitContext context) throws (
|
|
|
|
|
1: LimitNotFound e1,
|
|
|
|
|
3: base.InvalidRequest e2
|
|
|
|
|
)
|
|
|
|
|
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
|
|
|
|
|
)
|
2019-09-24 12:22:23 +00:00
|
|
|
|
}
|