From 3e3e577eeeb5e3d79912d61ce7af55da9a9eb4ba Mon Sep 17 00:00:00 2001 From: priyeshmashelkar Date: Mon, 2 Jul 2018 12:29:05 +0100 Subject: [PATCH 1/3] Deleted file from evaluation --- .../com/baeldung/reactive/model/Stock.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java deleted file mode 100644 index 6743de064e..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.reactive.model; - -import java.math.BigDecimal; - -public class Stock { - - private String code; - - private BigDecimal price; - - public Stock(String code, BigDecimal price) { - this.code = code; - this.price = price; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - -} From c7d58f3e583beefa6af3d4f83bd6756d92f51b4f Mon Sep 17 00:00:00 2001 From: priyeshmashelkar Date: Mon, 2 Jul 2018 12:29:42 +0100 Subject: [PATCH 2/3] Delete file from evaluation --- .../controller/StockReactiveController.java | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockReactiveController.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockReactiveController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockReactiveController.java deleted file mode 100644 index 8f8de79561..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockReactiveController.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.reactive.controller; - -import java.math.BigDecimal; -import java.time.Duration; -import java.util.Random; -import java.util.stream.Stream; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.reactive.model.Stock; - -import reactor.core.publisher.Flux; -import reactor.util.function.Tuple2; - -@RestController -@RequestMapping("/rtes") -public class StockReactiveController { - - @GetMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE, value = "/stocks/{code}") - public Flux getStocks(@PathVariable String code) { - BigDecimal startingPrice = new BigDecimal("100"); - Flux stockFlux = Flux.fromStream(Stream.generate(() -> new Stock(code, getLatestPrice(startingPrice)))); - Flux emmitFlux = Flux.interval(Duration.ofSeconds(1)); - return Flux.zip(stockFlux, emmitFlux) - .map(Tuple2::getT1); - } - - private BigDecimal getLatestPrice(BigDecimal startingPrice) { - BigDecimal priceChange = BigDecimal.valueOf(new Random().nextDouble()); - return new Random().nextBoolean() ? startingPrice.add(priceChange) : startingPrice.subtract(priceChange); - } -} From 44caf3b868547ff83748029798ed6594b86dc32e Mon Sep 17 00:00:00 2001 From: priyeshmashelkar Date: Mon, 2 Jul 2018 12:30:59 +0100 Subject: [PATCH 3/3] Deleted file from evaluation --- .../baeldung/reactive/client/StockClient.java | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 spring-5-reactive/src/main/java/com/baeldung/reactive/client/StockClient.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/client/StockClient.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/client/StockClient.java deleted file mode 100644 index 8a65b77b37..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/client/StockClient.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.reactive.client; - -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; - -import com.baeldung.reactive.model.Stock; - -import reactor.core.publisher.Flux; - -public class StockClient { - - public Flux getStockUpdates(String stockCode) { - WebClient client = WebClient.create("localhost:8080"); - RequestHeadersSpec request = client.get() - .uri("/rtes/stocks/" + stockCode) - .accept(MediaType.TEXT_EVENT_STREAM); - return request.retrieve() - .bodyToFlux(Stock.class) - .log(); - } -}