Skip to content

Commit

Permalink
Merge pull request #108 from Netflix/feature/use-init-bean
Browse files Browse the repository at this point in the history
Move away from using PostConstruct
  • Loading branch information
srinivasankavitha authored Feb 9, 2023
2 parents f7a5a20 + 52b4474 commit dac8da6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/kotlin/com/example/demo/services/ReviewsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import java.time.ZoneId
import java.time.ZoneOffset
import java.util.concurrent.TimeUnit
import java.util.stream.IntStream
import jakarta.annotation.PostConstruct
import kotlin.streams.toList
import org.springframework.beans.factory.InitializingBean

interface ReviewsService {
fun reviewsForShow(showId: Int): List<Review>?
Expand All @@ -46,15 +45,14 @@ interface ReviewsService {
* If this was indeed backed by a database, it would be very important to avoid the N+1 problem, which means we need to use a DataLoader to call this class.
*/
@Service
class DefaultReviewsService(private val showsService: ShowsService): ReviewsService {
class DefaultReviewsService(private val showsService: ShowsService): ReviewsService, InitializingBean {
private val logger = LoggerFactory.getLogger(ReviewsService::class.java)

private val reviews = mutableMapOf<Int, MutableList<Review>>()
private lateinit var reviewsStream : FluxSink<Review>
private lateinit var reviewsPublisher: ConnectableFlux<Review>

@PostConstruct
fun createReviews() {
override fun afterPropertiesSet() {
val faker = Faker()

//For each show we generate a random set of reviews.
Expand Down

0 comments on commit dac8da6

Please sign in to comment.