Skip to content

Commit 6723e86

Browse files
keynslugWWWcool
andauthored
TD-304: Transform body type into turnover specific metric (#19)
* Deprecate weakly defined limit body type. * Stop accepting body type in "legacy" configurator Co-authored-by: Артем <WWW_cool@inbox.ru>
1 parent d390910 commit 6723e86

2 files changed

Lines changed: 38 additions & 13 deletions

File tree

proto/configurator.thrift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ typedef base.ID LimitName
99
typedef limiter_config.LimitConfigID LimitConfigID
1010
typedef limiter_config.ShardSize ShardSize
1111
typedef limiter_config.LimitConfig LimitConfig
12-
typedef limiter_config.LimitBodyType LimitBodyType
1312
typedef limiter_config.OperationLimitBehaviour OperationLimitBehaviour
1413

1514
struct LimitCreateParams {
@@ -18,7 +17,6 @@ struct LimitCreateParams {
1817
/** Идентификатор набора настроек создаваемого лимата, в будущем идентификатор заменит структура конфигурации */
1918
3: optional LimitName name
2019
4: optional string description
21-
5: optional LimitBodyType body_type
2220
6: optional OperationLimitBehaviour op_behaviour
2321
}
2422

proto/limiter_config.thrift

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ typedef base.CurrencySymbolicCode CurrencySymbolicCode
1717

1818
struct LimitConfigParams {
1919
1: required LimitConfigID id
20-
2: required LimitBodyType body_type
2120
3: required Timestamp started_at
2221
4: required ShardSize shard_size
2322
5: required time_range.TimeRangeType time_range_type
@@ -32,7 +31,6 @@ struct LimitConfig {
3231
1: required LimitConfigID id
3332
2: required string processor_type
3433
3: required Timestamp created_at
35-
4: required LimitBodyType body_type
3634
5: required Timestamp started_at
3735
6: required ShardSize shard_size
3836
7: required time_range.TimeRangeType time_range_type
@@ -41,6 +39,9 @@ struct LimitConfig {
4139
9: optional LimitScope scope
4240
10: optional string description
4341
12: optional OperationLimitBehaviour op_behaviour
42+
43+
// deprecated
44+
4: optional LimitBodyType body_type_deprecated
4445
}
4546

4647
struct OperationLimitBehaviour {
@@ -55,22 +56,38 @@ union OperationBehaviour {
5556
struct Subtraction {}
5657
struct Addition {}
5758

58-
union LimitBodyType {
59-
1: LimitBodyTypeAmount amount
60-
2: LimitBodyTypeCash cash
59+
union LimitType {
60+
1: LimitTypeTurnover turnover
6161
}
6262

63-
struct LimitBodyTypeAmount {}
64-
struct LimitBodyTypeCash {
65-
1: required CurrencySymbolicCode currency
63+
struct LimitTypeTurnover {
64+
/**
65+
* Metric to account turnover with.
66+
* If undefined, equivalent to specifying `LimitTurnoverNumber`.
67+
*/
68+
1: optional LimitTurnoverMetric metric
6669
}
6770

71+
union LimitTurnoverMetric {
72+
73+
/**
74+
* Measure turnover over number of operations.
75+
*/
76+
1: LimitTurnoverNumber number
77+
78+
/**
79+
* Measure turnover over aggregate amount of operations denominated in a single currency.
80+
* In the event operation's currency differs from limit's currency operation will be accounted
81+
* with appropriate exchange rate fixed against operation's timestamp.
82+
*/
83+
2: LimitTurnoverAmount amount
6884

69-
union LimitType {
70-
1: LimitTypeTurnover turnover
7185
}
7286

73-
struct LimitTypeTurnover {}
87+
struct LimitTurnoverNumber {}
88+
struct LimitTurnoverAmount {
89+
1: required CurrencySymbolicCode currency
90+
}
7491

7592
union LimitScope {
7693

@@ -134,3 +151,13 @@ union Change {
134151
struct CreatedChange {
135152
1: required LimitConfig limit_config
136153
}
154+
155+
/// Deprecated definitions
156+
157+
union LimitBodyType {
158+
2: LimitBodyTypeCash cash
159+
}
160+
161+
struct LimitBodyTypeCash {
162+
1: required CurrencySymbolicCode currency
163+
}

0 commit comments

Comments
 (0)