Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public BinaryDeserializer<TimestampedChange> withdrawalTimestampedChangeBinaryDe
return new AbstractThriftBinaryDeserializer<>() {
@Override
public TimestampedChange deserialize(byte[] bytes) {
return Geck.msgPackToTBase(bytes, TimestampedChange.class);
return deserialize(bytes, new TimestampedChange());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,7 @@ private WithdrawalStateSnapshot getState(String withdrawalId, Map<String, Withdr
}

private TimestampedChange parse(MachineEvent machineEvent) {
try {
return withdrawalTimestampedChangeMachineEventParser.parse(machineEvent);
} catch (Exception e) {
log.warn("Failed to parse withdrawal event, sourceId={}, eventId={}",
machineEvent.getSourceId(), machineEvent.getEventId(), e);
return null;
}
return withdrawalTimestampedChangeMachineEventParser.parse(machineEvent);
}

private String resolveWithdrawalId(MachineEvent machineEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import dev.vality.fistful.withdrawal.status.Status;
import dev.vality.fistful.withdrawal.status.Succeeded;
import dev.vality.geck.common.util.TypeUtil;
import dev.vality.geck.serializer.Geck;
import dev.vality.machinegun.eventsink.MachineEvent;
import dev.vality.machinegun.eventsink.SinkEvent;
import org.apache.thrift.TBase;
import org.apache.thrift.TException;
import org.apache.thrift.TSerializer;
import org.apache.thrift.protocol.TBinaryProtocol;

import java.time.Instant;
import java.util.List;
Expand Down Expand Up @@ -117,7 +119,7 @@ public static MachineEvent machineEvent(long eventId, TimestampedChange timestam
.setSourceId(WITHDRAWAL_ID)
.setEventId(eventId)
.setCreatedAt(TypeUtil.temporalToString(Instant.parse(OCCURRED_AT)))
.setData(dev.vality.machinegun.msgpack.Value.bin(Geck.toMsgPack(timestampedChange)));
.setData(dev.vality.machinegun.msgpack.Value.bin(serialize(timestampedChange)));
}

public static SinkEvent sinkEvent(long eventId, TimestampedChange timestampedChange) {
Expand Down Expand Up @@ -173,4 +175,12 @@ private static FinalCashFlowPosting posting(CashFlowAccount source, CashFlowAcco
.setDestination(new FinalCashFlowAccount().setAccountType(destination))
.setVolume(new Cash().setAmount(amount).setCurrency(new CurrencyRef(CURRENCY)));
}

private static byte[] serialize(TBase<?, ?> thriftValue) {
try {
return new TSerializer(new TBinaryProtocol.Factory()).serialize(thriftValue);
} catch (TException e) {
throw new IllegalStateException("Failed to serialize withdrawal test event", e);
}
}
}
Loading