Created
November 16, 2018 13:34
-
-
Save jeffscottbrown/f3f5e0b1e79457babf6fa5b04a35ba4e to your computer and use it in GitHub Desktop.
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
| private Function<String, Mono<? extends Orders>> keyToOrder(RedisReactiveCommands<String, String> commands) { | |
| return { key -> | |
| Flux<KeyValue<String, String>> values = commands.hmget(key, "price", "description") | |
| Map map = [:] | |
| return values.reduce(map, (all, keyValue)= {all.put(keyValue.getKey(), keyValue.getValue()) | |
| return all | |
| }).map({entries -> ConvertibleValues.of(entries)}) | |
| .flatMap({entries -> | |
| String description = entries.get("description", String.class).orElseThrow({ new IllegalStateException("No description")}) | |
| BigDecimal price = entries.get("price", BigDecimal.class).orElseThrow({new IllegalStateException("No price")}) | |
| Flowable<Item> findItemFlowable = itemClient.find(key).toFlowable() | |
| return Mono.from(findItemFlowable).map({item -> new Orders(item, description, price)}) | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment