TD-305: Add domain dep and payer (#18)

* added domain dep and payer

* removed base to fix dialyzer

* bump pom

* returned to limiter payer

* added payproc context

* upgrade namespaces

* readded capture cost

* fixed

Co-authored-by: Anatoly Karlov <karleowne@gmail.com>
This commit is contained in:
Артем 2022-06-14 15:53:59 +03:00 committed by GitHub
parent 6723e86215
commit 136e891337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 118 additions and 125 deletions

14
pom.xml
View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.vality</groupId>
<artifactId>library-parent-pom</artifactId>
<version>1.0.0</version>
<version>1.0.2</version>
</parent>
<artifactId>limiter-proto</artifactId>
@ -49,7 +49,7 @@
<dependency>
<groupId>dev.vality.woody</groupId>
<artifactId>woody-thrift</artifactId>
<version>1.0.0</version>
<version>1.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -57,6 +57,12 @@
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>damsel</artifactId>
<version>1.563-d384c12</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
@ -105,8 +111,8 @@
<configuration>
<relocations>
<relocation>
<pattern>dev.vality.damsel</pattern>
<shadedPattern>dev.vality.damsel.v${commit.number}</shadedPattern>
<pattern>dev.vality</pattern>
<shadedPattern>dev.vality.v${commit.number}</shadedPattern>
</relocation>
</relocations>
<shadedArtifactAttached>true</shadedArtifactAttached>

View File

@ -1,85 +0,0 @@
namespace java dev.vality.limiter.base
namespace erlang limiter_base
/**
* Отметка во времени согласно RFC 3339.
*
* Строка должна содержать дату и время в UTC в следующем формате:
* `2016-03-22T06:12:27Z`.
*/
typedef string Timestamp
/** Идентификатор объекта */
typedef string ID
typedef i32 ObjectID
/** Идентификатор аккаунта */
typedef i64 AccountID
/** Идентификатор некоторого события */
typedef i64 EventID
struct EventRange {
1: optional EventID after
2: optional i32 limit
}
/** ISO 4217 */
typedef string CurrencySymbolicCode
/** Сумма в минимальных денежных единицах. */
typedef i64 Amount
/** Значение ассоциации */
typedef string Tag
/** Внешний идентификатор (идентификатор в системе клиента) для сущностей системы. */
typedef ID ExternalID
typedef i64 DataRevision
typedef i64 PartyRevision
/** Непрозрачный для участника общения набор данных */
typedef binary Opaque
/**
* Идентификатор валюты
*/
struct CurrencyRef { 1: required CurrencySymbolicCode symbolic_code }
/**
* Объём денежных средств
*/
struct Cash {
1: required Amount amount
2: required CurrencyRef currency
}
struct CashRange {
1: required CashBound upper
2: required CashBound lower
}
union CashBound {
1: Cash inclusive
2: Cash exclusive
}
struct AmountRange {
1: required AmountBound upper
2: required AmountBound lower
}
union AmountBound {
1: Amount inclusive
2: Amount exclusive
}
/**
* Исключение, сигнализирующее о непригодных с точки зрения бизнес-логики входных данных
*/
exception InvalidRequest {
/** Список пригодных для восприятия человеком ошибок во входных данных */
1: required list<string> errors
}

View File

@ -1,11 +1,11 @@
include "base.thrift"
include "proto/base.thrift"
include "limiter.thrift"
include "limiter_config.thrift"
namespace java dev.vality.limiter.configurator
namespace erlang limiter_cfg
namespace erlang limiter.configurator
typedef base.ID LimitName
typedef string LimitName
typedef limiter_config.LimitConfigID LimitConfigID
typedef limiter_config.ShardSize ShardSize
typedef limiter_config.LimitConfig LimitConfig

View File

@ -1,16 +1,19 @@
include "base.thrift"
include "proto/base.thrift"
include "proto/domain.thrift"
include "limiter_base.thrift"
include "limiter_context.thrift"
namespace java dev.vality.limiter
namespace erlang limiter
typedef base.ID LimitChangeID
typedef base.ID LimitID
typedef string LimitChangeID
typedef string LimitID
typedef base.ID PartyID
typedef base.ID ShopID
typedef base.ID WalletID
typedef base.ID IdentityID
typedef limiter_context.LimitContext LimitContext
typedef limiter_base.AmountRange AmountRange
/**
* https://en.wikipedia.org/wiki/Vector_clock
@ -31,7 +34,7 @@ union Clock {
struct Limit {
1: required LimitID id
2: required base.Amount amount
2: required domain.Amount amount
3: optional base.Timestamp creation_time
4: optional string description
}
@ -44,8 +47,8 @@ struct LimitChange {
exception LimitNotFound {}
exception LimitChangeNotFound {}
exception ForbiddenOperationAmount {
1: required base.Amount amount
2: required base.AmountRange allowed_range
1: required domain.Amount amount
2: required AmountRange allowed_range
}
service Limiter {

14
proto/limiter_base.thrift Normal file
View File

@ -0,0 +1,14 @@
include "proto/domain.thrift"
namespace java dev.vality.limiter.base
namespace erlang limiter.base
struct AmountRange {
1: required AmountBound upper
2: required AmountBound lower
}
union AmountBound {
1: domain.Amount inclusive
2: domain.Amount exclusive
}

View File

@ -3,17 +3,18 @@
*/
namespace java dev.vality.limiter.config
namespace erlang limiter_config
namespace erlang limiter.config
include "base.thrift"
include "proto/base.thrift"
include "proto/domain.thrift"
include "time_range.thrift"
/// Domain
typedef base.ID LimitConfigID
typedef string LimitConfigID
typedef base.Timestamp Timestamp
typedef base.Amount ShardSize
typedef base.CurrencySymbolicCode CurrencySymbolicCode
typedef i64 ShardSize
typedef domain.CurrencySymbolicCode CurrencySymbolicCode
struct LimitConfigParams {
1: required LimitConfigID id

View File

@ -1,12 +1,15 @@
include "base.thrift"
include "proto/base.thrift"
include "proto/domain.thrift"
include "limiter_payproc_context.thrift"
namespace java dev.vality.limiter.context
namespace erlang limiter_context
namespace erlang limiter.context
typedef base.ID ID
struct LimitContext {
1: optional ContextPaymentProcessing payment_processing
1: optional ContextPaymentProcessing limiter_payment_processing
2: optional limiter_payproc_context.Context payment_processing
}
/**
@ -38,7 +41,7 @@ struct Invoice {
1: optional ID id
2: optional ID owner_id
3: optional ID shop_id
4: optional base.Cash cost
4: optional domain.Cash cost
5: optional base.Timestamp created_at
6: optional InvoicePayment effective_payment
7: optional InvoiceAdjustment effective_adjustment
@ -52,8 +55,8 @@ struct InvoicePayment {
1: optional ID id
2: optional ID owner_id
3: optional ID shop_id
4: optional base.Cash cost
11: optional base.Cash capture_cost
4: optional domain.Cash cost
11: optional domain.Cash capture_cost
5: optional base.Timestamp created_at
6: optional InvoicePaymentFlow flow
7: optional Payer payer
@ -90,13 +93,13 @@ struct InvoicePaymentAdjustment {
struct InvoicePaymentRefund {
1: optional ID id
2: optional base.Cash cost
2: optional domain.Cash cost
3: optional base.Timestamp created_at
}
struct InvoicePaymentChargeback {
1: optional ID id
2: optional base.Timestamp created_at
3: optional base.Cash levy
4: optional base.Cash body
3: optional domain.Cash levy
4: optional domain.Cash body
}

View File

@ -0,0 +1,43 @@
include "proto/base.thrift"
include "proto/domain.thrift"
namespace java dev.vality.limiter.payproc.context
namespace erlang limiter.context.payproc
/**
* Контекст, получаемый из сервисов, реализующих один из интерфейсов протокола
* (например invoicing в hellgate)
*/
struct Context {
1: optional Operation op
2: optional Invoice invoice
}
union Operation {
1: OperationInvoice invoice
2: OperationInvoiceAdjustment invoice_adjustment
3: OperationInvoicePayment invoice_payment
4: OperationInvoicePaymentAdjustment invoice_payment_adjustment
5: OperationInvoicePaymentRefund invoice_payment_refund
6: OperationInvoicePaymentChargeback invoice_payment_chargeback
}
struct OperationInvoice {}
struct OperationInvoiceAdjustment {}
struct OperationInvoicePayment {}
struct OperationInvoicePaymentAdjustment {}
struct OperationInvoicePaymentRefund {}
struct OperationInvoicePaymentChargeback {}
struct Invoice {
1: optional domain.Invoice invoice
2: optional domain.InvoicePayment payment
3: optional domain.InvoiceAdjustment adjustment
}
struct InvoicePayment {
1: optional domain.InvoicePayment payment
2: optional domain.InvoicePaymentAdjustment adjustment
3: optional domain.InvoicePaymentRefund refund
4: optional domain.InvoicePaymentChargeback chargeback
}

View File

@ -3,21 +3,22 @@
*/
namespace java dev.vality.limiter.range
namespace erlang limiter_range
namespace erlang limiter.range
include "base.thrift"
include "proto/base.thrift"
include "proto/domain.thrift"
include "time_range.thrift"
/// Domain
typedef base.ID LimitRangeID
typedef string LimitRangeID
typedef base.Timestamp Timestamp
struct LimitRange {
1: required LimitRangeID id
2: required time_range.TimeRangeType type
3: required Timestamp created_at
4: optional base.CurrencySymbolicCode currency
4: optional domain.CurrencySymbolicCode currency
}
struct LimitRangeState {
@ -25,7 +26,7 @@ struct LimitRangeState {
2: required time_range.TimeRangeType type
3: required Timestamp created_at
4: optional list<time_range.TimeRange> ranges
5: optional base.CurrencySymbolicCode currency
5: optional domain.CurrencySymbolicCode currency
}
/// LimitRange events

View File

@ -3,16 +3,16 @@
*/
namespace java dev.vality.limiter.range.time
namespace erlang time_range
namespace erlang limiter.time.range
include "base.thrift"
include "proto/base.thrift"
include "proto/domain.thrift"
/// Domain
typedef base.ID LimitRangeID
typedef base.AccountID AccountID
typedef domain.AccountID AccountID
typedef base.Timestamp Timestamp
typedef base.Amount IntervalAmount
typedef domain.Amount IntervalAmount
union TimeRangeType {
1: TimeRangeTypeCalendar calendar

View File

@ -25,7 +25,11 @@
warn_missing_spec_all
]}.
{deps, []}.
{deps, [
{damsel,
{git, "https://github.com/valitydev/damsel.git", {branch, "master"}}
}
]}.
%% XRef checks
{xref_checks, [
@ -41,7 +45,6 @@
% mandatory
unmatched_returns,
error_handling,
race_conditions,
unknown
]},
{plt_apps, all_deps}
@ -61,5 +64,6 @@
{thrift_compiler_opts, [
{in_dir, "proto"},
{in_files, all},
{gen, "erlang:scoped_typenames,app_prefix=lim"}
]}.

View File

@ -1 +1,4 @@
[].
[{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"d384c125d16c0204e23b0d96a6ef791244a72315"}},
0}].