Skip to content

Commit d390910

Browse files
authored
TD-303: Add scope over payment tool (#17)
* Drop global scope as a special case of empty case, given it's not used in existing data. * Reduce amount of empty struct declarations. * Sprinkle more comments.
1 parent 03dad08 commit d390910

1 file changed

Lines changed: 37 additions & 17 deletions

File tree

proto/limiter_config.thrift

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct LimitConfigParams {
2323
5: required time_range.TimeRangeType time_range_type
2424
6: required LimitContextType context_type
2525
7: required LimitType type
26-
8: required LimitScope scopes
26+
8: required LimitScope scope
2727
9: optional string description
2828
10: required OperationLimitBehaviour op_behaviour
2929
}
@@ -38,7 +38,7 @@ struct LimitConfig {
3838
7: required time_range.TimeRangeType time_range_type
3939
11: required LimitContextType context_type
4040
8: optional LimitType type
41-
9: optional LimitScope scopes
41+
9: optional LimitScope scope
4242
10: optional string description
4343
12: optional OperationLimitBehaviour op_behaviour
4444
}
@@ -73,26 +73,46 @@ union LimitType {
7373
struct LimitTypeTurnover {}
7474

7575
union LimitScope {
76-
1: LimitScopeGlobal scope_global
77-
// Возможно, это поле так и останется т.к. конфиги создаются разово, и
78-
// помимо machinegun попадает и в kafka
79-
2: LimitScopeType scope_deprecated
80-
3: set<LimitScopeType> scopes
81-
}
8276

83-
struct LimitScopeGlobal {}
77+
/**
78+
* Set of scopes.
79+
* Each additional scope increases specificity of a limit. Each possible set describes unique
80+
* limit, e.g. limit with scope { party } and limit with scope { party, shop } are completely
81+
* different limits. Empty set is equivalent to a limit having global scope.
82+
*/
83+
3: set<LimitScopeType> multi
84+
85+
/**
86+
* Single scope.
87+
* Equivalent to the set of scopes containing exactly one scope.
88+
* Kept to preserve backward compatibility with existing data.
89+
*/
90+
2: LimitScopeType single
91+
92+
// Reserved
93+
// 1
94+
95+
}
8496

8597
union LimitScopeType {
86-
1: LimitScopeTypeParty party
87-
2: LimitScopeTypeShop shop
88-
3: LimitScopeTypeWallet wallet
89-
4: LimitScopeTypeIdentity identity
98+
99+
1: LimitScopeEmptyDetails party
100+
2: LimitScopeEmptyDetails shop
101+
3: LimitScopeEmptyDetails wallet
102+
4: LimitScopeEmptyDetails identity
103+
104+
/**
105+
* Scope over data which uniquely identifies payment tool used in a payment.
106+
* E.g. `domain.BankCard.token` + `domain.BankCard.exp_date` when bank card is being used as
107+
* payment tool.
108+
*
109+
* See: https://github.com/valitydev/damsel/blob/2e1dbc1a/proto/domain.thrift#L1824-L1830
110+
*/
111+
5: LimitScopeEmptyDetails payment_tool
112+
90113
}
91114

92-
struct LimitScopeTypeParty {}
93-
struct LimitScopeTypeShop {}
94-
struct LimitScopeTypeWallet {}
95-
struct LimitScopeTypeIdentity {}
115+
struct LimitScopeEmptyDetails {}
96116

97117
union LimitContextType {
98118
1: LimitContextTypePaymentProcessing payment_processing

0 commit comments

Comments
 (0)