Skip to content

Commit

Permalink
Remove scheduler. Add request and connection timeouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Nov 25, 2023
1 parent 26ff786 commit a1fdf7f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package io.github.reactivecircus.kstreamlined.backend

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.scheduling.annotation.EnableScheduling

@SpringBootApplication
@EnableScheduling
class KSBackendApplication

fun main(args: Array<String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.github.reactivecircus.kstreamlined.backend.client.dto.TalkingKotlinRss
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
Expand Down Expand Up @@ -63,6 +64,10 @@ class RealFeedClient(
xml(format, ContentType.Application.Xml)
xml(format, ContentType.Text.Xml)
}
install(HttpTimeout) {
connectTimeoutMillis = HttpTimeoutMillis
requestTimeoutMillis = HttpTimeoutMillis
}
}

context(CacheContext<KotlinBlogItem>)
Expand Down Expand Up @@ -91,6 +96,10 @@ class RealFeedClient(
override suspend fun loadKotlinWeeklyFeed(): List<KotlinWeeklyItem> = getFromCacheOrFetch {
httpClient.get(clientConfigs.kotlinWeeklyFeedUrl).body<KotlinWeeklyRss>().channel.items
}

companion object {
private const val HttpTimeoutMillis = 30_000L
}
}

context(CacheContext<T>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ object Namespace {
const val media = "http://search.yahoo.com/mrss/"
const val content = "http://purl.org/rss/1.0/modules/content/"
const val yt = "http://www.youtube.com/xml/schemas/2015"
const val dc = "http://purl.org/dc/elements/1.1/"
}

@Serializable
Expand Down

This file was deleted.

0 comments on commit a1fdf7f

Please sign in to comment.