mirror of
https://github.com/valitydev/sink-common-lib.git
synced 2024-11-06 10:25:18 +00:00
Ft/handler (#2)
This commit is contained in:
parent
d4554df3e5
commit
e0ec4d2dd1
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -1,5 +1,5 @@
|
|||||||
#!groovy
|
#!groovy
|
||||||
build('thrift-common-lib', 'docker-host') {
|
build('sink-common-lib', 'docker-host') {
|
||||||
checkoutRepo()
|
checkoutRepo()
|
||||||
loadBuildUtils()
|
loadBuildUtils()
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# thrift-common-lib
|
# sink-common-lib
|
||||||
Библиотека для переиспользования вздаимодействия с протоколами, обрабатываемые machinegun'ном:
|
Библиотека для переиспользования вздаимодействия с протоколами, обрабатываемые machinegun'ном:
|
||||||
- eventsink (hellgate)
|
- eventsink (hellgate)
|
||||||
- sinkievent (machinegun)
|
- sinkievent (machinegun)
|
||||||
|
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<artifactId>thrift-common-lib</artifactId>
|
<artifactId>sink-common-lib</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.exception;
|
package com.rbkmoney.sink.common.exception;
|
||||||
|
|
||||||
public class ParseException extends RuntimeException {
|
public class ParseException extends RuntimeException {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.exception;
|
package com.rbkmoney.sink.common.exception;
|
||||||
|
|
||||||
public class ThriftBinaryDeserializationException extends RuntimeException {
|
public class ThriftBinaryDeserializationException extends RuntimeException {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.exception;
|
package com.rbkmoney.sink.common.exception;
|
||||||
|
|
||||||
public class ThriftBinarySerializationException extends RuntimeException {
|
public class ThriftBinarySerializationException extends RuntimeException {
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle;
|
||||||
|
|
||||||
|
public interface EventHandler<E, B> {
|
||||||
|
|
||||||
|
default boolean accept(E payload) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
default void handle(E payload, B baseEvent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
default void handle(E payload, B baseEvent, Integer changeId) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent;
|
||||||
|
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.EventHandler;
|
||||||
|
|
||||||
|
public interface MachineEventHandler<T> extends EventHandler<T, MachineEvent> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface PaymentEventHandler extends MachineEventHandler<EventPayload> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface PayoutEventHandler extends MachineEventHandler<EventPayload> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.CustomerChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface CustomerChangeEventHandler extends MachineEventHandler<CustomerChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.InvoiceChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface InvoiceChangeEventHandler extends MachineEventHandler<InvoiceChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.PartyChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface PartyChangeEventHandler extends MachineEventHandler<PartyChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payout_processing.PayoutChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface PayoutChangeEventHandler extends MachineEventHandler<PayoutChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.claimeffect;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.ClaimEffect;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
|
||||||
|
public interface ClaimEffectEventHandler extends MachineEventHandler<ClaimEffect> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.ClaimEffect;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.PartyChange;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.PartyChangeEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.claimeffect.ClaimEffectEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ClaimEffectStatusAcceptedChangeMachineEventHandler implements PartyChangeEventHandler {
|
||||||
|
|
||||||
|
private final List<ClaimEffectEventHandler> eventsHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(PartyChange payload) {
|
||||||
|
return payload.isSetClaimStatusChanged()
|
||||||
|
&& payload.getClaimStatusChanged().getStatus().isSetAccepted()
|
||||||
|
&& payload.getClaimStatusChanged().getStatus().getAccepted().isSetEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PartyChange payload, MachineEvent baseEvent) {
|
||||||
|
for (int i = 0; i < payload.getClaimStatusChanged().getStatus().getAccepted().getEffects().size(); i++) {
|
||||||
|
ClaimEffect effect = payload.getClaimStatusChanged().getStatus().getAccepted().getEffects().get(i);
|
||||||
|
for (ClaimEffectEventHandler eventsHandler : eventsHandlers) {
|
||||||
|
if (eventsHandler.accept(effect)) {
|
||||||
|
eventsHandler.handle(effect, baseEvent, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.CustomerChange;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.PaymentEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.CustomerChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CustomerChangePaymentMachineEventHandler implements PaymentEventHandler {
|
||||||
|
|
||||||
|
private final List<CustomerChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(EventPayload payload) {
|
||||||
|
return payload.isSetCustomerChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EventPayload payload, MachineEvent baseEvent) {
|
||||||
|
for (CustomerChange change : payload.getCustomerChanges()) {
|
||||||
|
for (CustomerChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.InvoiceChange;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.PaymentEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.InvoiceChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class InvoiceChangePaymentMachineEventHandler implements PaymentEventHandler {
|
||||||
|
|
||||||
|
private final List<InvoiceChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(EventPayload payload) {
|
||||||
|
return payload.isSetInvoiceChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EventPayload payload, MachineEvent baseEvent) {
|
||||||
|
for (InvoiceChange change : payload.getInvoiceChanges()) {
|
||||||
|
for (InvoiceChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.PartyChange;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.PaymentEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.PartyChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PartyChangePaymentMachineEventHandler implements PaymentEventHandler {
|
||||||
|
|
||||||
|
private final List<PartyChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(EventPayload payload) {
|
||||||
|
return payload.isSetPartyChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EventPayload payload, MachineEvent baseEvent) {
|
||||||
|
for (PartyChange change : payload.getPartyChanges()) {
|
||||||
|
for (PartyChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.eventpayload.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
||||||
|
import com.rbkmoney.damsel.payout_processing.PayoutChange;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.PayoutEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.change.PayoutChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PayoutChangePayoutMachineEventHandler implements PayoutEventHandler {
|
||||||
|
|
||||||
|
private final List<PayoutChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(EventPayload payload) {
|
||||||
|
return payload.isSetPayoutChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EventPayload payload, MachineEvent baseEvent) {
|
||||||
|
for (PayoutChange change : payload.getPayoutChanges()) {
|
||||||
|
for (PayoutChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.PaymentEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentEventMachineEventHandler implements MachineEventHandler<EventPayload> {
|
||||||
|
|
||||||
|
private final List<PaymentEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EventPayload payload, MachineEvent baseEvent) {
|
||||||
|
for (PaymentEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(payload)) {
|
||||||
|
eventHandler.handle(payload, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.machineevent.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
||||||
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.MachineEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.machineevent.eventpayload.PayoutEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PayoutEventMachineEventHandler implements MachineEventHandler<EventPayload> {
|
||||||
|
|
||||||
|
private final List<PayoutEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(EventPayload payload, MachineEvent baseEvent) {
|
||||||
|
for (PayoutEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(payload)) {
|
||||||
|
eventHandler.handle(payload, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.sink.common.handle.EventHandler;
|
||||||
|
|
||||||
|
public interface StockEventHandler<T> extends EventHandler<T, StockEvent> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.Event;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface PaymentEventHandler extends StockEventHandler<Event> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payout_processing.Event;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface PayoutEventHandler extends StockEventHandler<Event> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.CustomerChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface CustomerChangeEventHandler extends StockEventHandler<CustomerChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.InvoiceChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface InvoiceChangeEventHandler extends StockEventHandler<InvoiceChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.PartyChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface PartyChangeEventHandler extends StockEventHandler<PartyChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.change;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payout_processing.PayoutChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface PayoutChangeEventHandler extends StockEventHandler<PayoutChange> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.change.claimeffect;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.payment_processing.ClaimEffect;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
|
||||||
|
public interface ClaimEffectEventHandler extends StockEventHandler<ClaimEffect> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.change.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.ClaimEffect;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.PartyChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.change.PartyChangeEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.change.claimeffect.ClaimEffectEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class ClaimEffectStatusAcceptedChangeStockEventHandler implements PartyChangeEventHandler {
|
||||||
|
|
||||||
|
private final List<ClaimEffectEventHandler> eventsHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(PartyChange payload) {
|
||||||
|
return payload.isSetClaimStatusChanged()
|
||||||
|
&& payload.getClaimStatusChanged().getStatus().isSetAccepted()
|
||||||
|
&& payload.getClaimStatusChanged().getStatus().getAccepted().isSetEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PartyChange payload, StockEvent baseEvent) {
|
||||||
|
for (int i = 0; i < payload.getClaimStatusChanged().getStatus().getAccepted().getEffects().size(); i++) {
|
||||||
|
ClaimEffect effect = payload.getClaimStatusChanged().getStatus().getAccepted().getEffects().get(i);
|
||||||
|
for (ClaimEffectEventHandler eventsHandler : eventsHandlers) {
|
||||||
|
if (eventsHandler.accept(effect)) {
|
||||||
|
eventsHandler.handle(effect, baseEvent, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.CustomerChange;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.Event;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.PaymentEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.change.CustomerChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CustomerChangePaymentStockEventHandler implements PaymentEventHandler {
|
||||||
|
|
||||||
|
private final List<CustomerChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Event payload) {
|
||||||
|
return payload.getPayload().isSetCustomerChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Event payload, StockEvent baseEvent) {
|
||||||
|
for (CustomerChange change : payload.getPayload().getCustomerChanges()) {
|
||||||
|
for (CustomerChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.Event;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.InvoiceChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.PaymentEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.change.InvoiceChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class InvoiceChangePaymentStockEventHandler implements PaymentEventHandler {
|
||||||
|
|
||||||
|
private final List<InvoiceChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Event payload) {
|
||||||
|
return payload.getPayload().isSetInvoiceChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Event payload, StockEvent baseEvent) {
|
||||||
|
for (InvoiceChange change : payload.getPayload().getInvoiceChanges()) {
|
||||||
|
for (InvoiceChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.Event;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.PartyChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.PaymentEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.change.PartyChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PartyChangePaymentStockEventHandler implements PaymentEventHandler {
|
||||||
|
|
||||||
|
private final List<PartyChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Event payload) {
|
||||||
|
return payload.getPayload().isSetPartyChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Event payload, StockEvent baseEvent) {
|
||||||
|
for (PartyChange change : payload.getPayload().getPartyChanges()) {
|
||||||
|
for (PartyChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.event.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payout_processing.Event;
|
||||||
|
import com.rbkmoney.damsel.payout_processing.PayoutChange;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.PayoutEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.change.PayoutChangeEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PayoutChangePayoutStockEventHandler implements PayoutEventHandler {
|
||||||
|
|
||||||
|
private final List<PayoutChangeEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(Event payload) {
|
||||||
|
return payload.getPayload().isSetPayoutChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Event payload, StockEvent baseEvent) {
|
||||||
|
for (PayoutChange change : payload.getPayload().getPayoutChanges()) {
|
||||||
|
for (PayoutChangeEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(change)) {
|
||||||
|
eventHandler.handle(change, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payment_processing.Event;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.PaymentEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PaymentEventStockEventHandler implements StockEventHandler<StockEvent> {
|
||||||
|
|
||||||
|
private final List<PaymentEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(StockEvent payload) {
|
||||||
|
return payload.getSourceEvent().isSetProcessingEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(StockEvent payload, StockEvent baseEvent) {
|
||||||
|
Event event = payload.getSourceEvent().getProcessingEvent();
|
||||||
|
for (PaymentEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(event)) {
|
||||||
|
eventHandler.handle(event, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.rbkmoney.sink.common.handle.stockevent.impl;
|
||||||
|
|
||||||
|
import com.rbkmoney.damsel.event_stock.StockEvent;
|
||||||
|
import com.rbkmoney.damsel.payout_processing.Event;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.StockEventHandler;
|
||||||
|
import com.rbkmoney.sink.common.handle.stockevent.event.PayoutEventHandler;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PayoutEventStockEventHandler implements StockEventHandler<StockEvent> {
|
||||||
|
|
||||||
|
private final List<PayoutEventHandler> eventHandlers;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(StockEvent payload) {
|
||||||
|
return payload.getSourceEvent().isSetPayoutEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(StockEvent payload, StockEvent baseEvent) {
|
||||||
|
Event event = payload.getSourceEvent().getPayoutEvent();
|
||||||
|
for (PayoutEventHandler eventHandler : eventHandlers) {
|
||||||
|
if (eventHandler.accept(event)) {
|
||||||
|
eventHandler.handle(event, baseEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.parser;
|
package com.rbkmoney.sink.common.parser;
|
||||||
|
|
||||||
public interface Parser<F, T> {
|
public interface Parser<F, T> {
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package com.rbkmoney.thrift.common.parser.impl;
|
package com.rbkmoney.sink.common.parser.impl;
|
||||||
|
|
||||||
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
import com.rbkmoney.thrift.common.exception.ParseException;
|
import com.rbkmoney.sink.common.exception.ParseException;
|
||||||
import com.rbkmoney.thrift.common.parser.Parser;
|
import com.rbkmoney.sink.common.parser.Parser;
|
||||||
import com.rbkmoney.thrift.common.serialization.BinaryDeserializer;
|
import com.rbkmoney.sink.common.serialization.BinaryDeserializer;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.rbkmoney.thrift.common.parser.impl;
|
package com.rbkmoney.sink.common.parser.impl;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
import com.rbkmoney.thrift.common.serialization.BinaryDeserializer;
|
import com.rbkmoney.sink.common.serialization.BinaryDeserializer;
|
||||||
|
|
||||||
public class PaymentEventPayloadMachineEventParser extends MachineEventParser<EventPayload> {
|
public class PaymentEventPayloadMachineEventParser extends MachineEventParser<EventPayload> {
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.rbkmoney.thrift.common.parser.impl;
|
package com.rbkmoney.sink.common.parser.impl;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
||||||
import com.rbkmoney.thrift.common.serialization.BinaryDeserializer;
|
import com.rbkmoney.sink.common.serialization.BinaryDeserializer;
|
||||||
|
|
||||||
public class PayoutEventPayloadMachineEventParser extends MachineEventParser<EventPayload> {
|
public class PayoutEventPayloadMachineEventParser extends MachineEventParser<EventPayload> {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization;
|
package com.rbkmoney.sink.common.serialization;
|
||||||
|
|
||||||
public interface BinaryDeserializer<T> {
|
public interface BinaryDeserializer<T> {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization;
|
package com.rbkmoney.sink.common.serialization;
|
||||||
|
|
||||||
public interface BinarySerializer<T> {
|
public interface BinarySerializer<T> {
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization.impl;
|
package com.rbkmoney.sink.common.serialization.impl;
|
||||||
|
|
||||||
import com.rbkmoney.thrift.common.exception.ThriftBinaryDeserializationException;
|
import com.rbkmoney.sink.common.exception.ThriftBinaryDeserializationException;
|
||||||
import com.rbkmoney.thrift.common.serialization.BinaryDeserializer;
|
import com.rbkmoney.sink.common.serialization.BinaryDeserializer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.thrift.TBase;
|
import org.apache.thrift.TBase;
|
||||||
import org.apache.thrift.TDeserializer;
|
import org.apache.thrift.TDeserializer;
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization.impl;
|
package com.rbkmoney.sink.common.serialization.impl;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization.impl;
|
package com.rbkmoney.sink.common.serialization.impl;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization.impl;
|
package com.rbkmoney.sink.common.serialization.impl;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
import com.rbkmoney.damsel.payout_processing.EventPayload;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization.impl;
|
package com.rbkmoney.sink.common.serialization.impl;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization.impl;
|
package com.rbkmoney.sink.common.serialization.impl;
|
||||||
|
|
||||||
import com.rbkmoney.thrift.common.exception.ThriftBinarySerializationException;
|
import com.rbkmoney.sink.common.exception.ThriftBinarySerializationException;
|
||||||
import com.rbkmoney.thrift.common.serialization.BinarySerializer;
|
import com.rbkmoney.sink.common.serialization.BinarySerializer;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.thrift.TBase;
|
import org.apache.thrift.TBase;
|
||||||
import org.apache.thrift.TException;
|
import org.apache.thrift.TException;
|
@ -1,11 +1,11 @@
|
|||||||
package com.rbkmoney.thrift.common.parser;
|
package com.rbkmoney.sink.common.parser;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
import com.rbkmoney.machinegun.eventsink.MachineEvent;
|
||||||
import com.rbkmoney.machinegun.msgpack.Value;
|
import com.rbkmoney.machinegun.msgpack.Value;
|
||||||
import com.rbkmoney.thrift.common.parser.impl.PaymentEventPayloadMachineEventParser;
|
import com.rbkmoney.sink.common.parser.impl.PaymentEventPayloadMachineEventParser;
|
||||||
import com.rbkmoney.thrift.common.serialization.impl.PaymentEventPayloadDeserializer;
|
import com.rbkmoney.sink.common.serialization.impl.PaymentEventPayloadDeserializer;
|
||||||
import com.rbkmoney.thrift.common.serialization.impl.PaymentEventPayloadSerializer;
|
import com.rbkmoney.sink.common.serialization.impl.PaymentEventPayloadSerializer;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
@ -1,8 +1,8 @@
|
|||||||
package com.rbkmoney.thrift.common.serialization;
|
package com.rbkmoney.sink.common.serialization;
|
||||||
|
|
||||||
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
import com.rbkmoney.damsel.payment_processing.EventPayload;
|
||||||
import com.rbkmoney.thrift.common.serialization.impl.PaymentEventPayloadDeserializer;
|
import com.rbkmoney.sink.common.serialization.impl.PaymentEventPayloadDeserializer;
|
||||||
import com.rbkmoney.thrift.common.serialization.impl.PaymentEventPayloadSerializer;
|
import com.rbkmoney.sink.common.serialization.impl.PaymentEventPayloadSerializer;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
Loading…
Reference in New Issue
Block a user