This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| machine("Circuit Breaker", machine -> { | |
| machine.startWith("OPEN"); | |
| machine.at("OPEN", rule -> { | |
| rule.when("connect", failOp, "OPEN", "CLOSED"); | |
| }); | |
| machine.at("CLOSED", rule -> { | |
| rule.when("connect", s -> { | |
| }, "CLOSED"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| decisionSystem("FX Transaction", tradeSchema, s -> { | |
| s.rule("High Transfer discount", condition -> { | |
| condition | |
| .gt("amount", 1000d) | |
| .eq("source", "SGD") | |
| .eq("target", "INR") | |
| .action((rule, row) -> row.setDiscount(2.0d)); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface RecordContainer<T> extends Closeable { | |
| boolean append(T message); | |
| void read(RecordConsumer<T> reader); | |
| void read(long offSet, RecordConsumer<T> reader); | |
| default void close() {} | |
| int size(); | |
| String formatName(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (Avro) -> Size 43 Bytes | |
| {"tradeId": 454442738626075203, "customerId": 1924973958993118808, "qty": 100, "tradeType": "Buy", "symbol": "GOOGL", "exchange": "NYSE"} | |
| (Avro) -> Size 43 Bytes | |
| {"tradeId": 1984810212692753661, "customerId": -7397692262047989958, "qty": 100, "tradeType": "Sell", "symbol": "AAPL", "exchange": "NYSE"} | |
| (chronicle) -> Size 35 Bytes | |
| CVCNX©ãá¶NYSEBuyGOOGLd | |
| (chronicle) -> Size 35 Bytes | |
| ý|Z_v:?ùVNYSESellAAPLd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object[][] data = new Object[][]{ | |
| {new Random().nextLong(), new Random().nextLong(), "NYSE", "Buy", "GOOGL", 100}, | |
| {new Random().nextLong(), new Random().nextLong(), "NYSE", "Sell", "AAPL", 100}, | |
| }; | |
| process("Avro", Arrays.stream(data), AvroTradeRecordBuilder::newTrade, AvroTradeRecordBuilder::toBytes, AvroTradeRecordBuilder::fromBytes); | |
| process("chronicle", Arrays.stream(data), ChronicleTradeRecordBuilder::newTrade, ChronicleTradeRecordBuilder::toBytes, ChronicleTradeRecordBuilder::fromBytes); | |
| process("sbe", Arrays.stream(data), SBETradeRecordBuilder::newTrade, SBETradeRecordBuilder::toBytes, SBETradeRecordBuilder::fromBytes); | |
| process("csv", Arrays.stream(data), CSVTradeRecordBuilder::newTrade, CSVTradeRecordBuilder::toBytes, CSVTradeRecordBuilder::fromBytes); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long tradeId , customerId; | |
| int qty; | |
| TradeType tradeType; | |
| String symbol,exchange; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List functions = asList( | |
| SerCode.f((Integer x) -> x * x), | |
| SerCode.f((String x) -> x.toUpperCase()), | |
| SerCode.p((String x) -> x.length() > 5) | |
| ); | |
| byte[] code = saveFunction(functions); | |
| ObjectInputStream fStream = codeStream(code); | |
| List rFunctions = (List) fStream.readObject(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @FunctionalInterface | |
| public interface SerFunction<T, R> extends Function<T, R>, Serializable { | |
| } | |
| @FunctionalInterface | |
| public interface SerPredicate<T> extends Predicate<T>, Serializable { | |
| } | |
| .... | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test() | |
| public void save_function_works() throws Exception { | |
| // Addtional casting allow to mark as serilized | |
| Function<String, String> upper = (Function<String, String> & Serializable) x -> x.toUpperCase(); | |
| try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
| ObjectOutputStream os = new ObjectOutputStream(bos)) { | |
| os.writeObject(upper); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void save_function() throws Exception { | |
| Function<String, String> upper = x -> x.toUpperCase(); | |
| try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
| ObjectOutputStream os = new ObjectOutputStream(bos)) { | |
| os.writeObject(upper); | |
| } | |
| } |