Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix function modifiers order #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import org.springframework.stereotype.Component
@Component
open class CoroutineListener {
@EventListener
suspend open fun handle(event: SimpleEvent) {
open suspend fun handle(event: SimpleEvent) {
delay(10)
logger.info ("Received event $event")
}

@EventListener
suspend open fun handleDemoEvent(event: DemoApplicationEvent) {
open suspend fun handleDemoEvent(event: DemoApplicationEvent) {
delay(10)
logger.info ("Received demoEvent $event")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import org.springframework.stereotype.Component
@Component
open class DemoService {
@Scheduled(cron = "0 0 0 1 1 *")
suspend open fun newYear() {
open suspend fun newYear() {
logger.info("Happy New Year!")
}

@Scheduled(fixedRate = 60_000)
suspend open fun everyMinute() {
open suspend fun everyMinute() {
logger.info("I'm still alive...")
}

suspend open fun delayedReturn(s: String, delayMillis: Long): String {
open suspend fun delayedReturn(s: String, delayMillis: Long): String {
logger.info ("Before delay in [delayedReturn]")
delay(delayMillis)
logger.info ("After delay in [delayedReturn]")
Expand All @@ -45,14 +45,14 @@ open class DemoService {
}

@Coroutine(DEFAULT_DISPATCHER)
suspend open fun defaultDispatcherReturn(s: String): String {
open suspend fun defaultDispatcherReturn(s: String): String {
logger.info ("In [defaultDispatcher]")

return s
}

@Cacheable("cache1")
suspend open fun cachedDelayedReturn(s: String, delayMillis: Long): String {
open suspend fun cachedDelayedReturn(s: String, delayMillis: Long): String {
logger.info ("Before delay in [cachedDelayedReturn]")
delay(delayMillis)
logger.info ("After delay in [cachedDelayedReturn]")
Expand All @@ -62,7 +62,7 @@ open class DemoService {

@Cacheable("cache2")
@Coroutine(DEFAULT_DISPATCHER)
suspend open fun cachedDefaultDispatcherDelayedReturn(s: String, delayMillis: Long): String {
open suspend fun cachedDefaultDispatcherDelayedReturn(s: String, delayMillis: Long): String {
logger.info ("Before delay in [cachedDefaultDispatcherDelayedReturn]")
delay(delayMillis)
logger.info ("After delay in [cachedDefaultDispatcherDelayedReturn]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ open class DemoController(
private val restOperations = CoroutineRestOperations()

@GetMapping("/delayed")
suspend open fun delayedReturn(): String {
open suspend fun delayedReturn(): String {
logger.info ("Before call to [demoService.delayed]")
val result = demoService.delayedReturn("delayed", 1000)
logger.info ("After call to [demoService.delayed]")
Expand All @@ -46,7 +46,7 @@ open class DemoController(
}

@GetMapping("/defaultDispatcher")
suspend open fun defaultDispatcherReturn(): String {
open suspend fun defaultDispatcherReturn(): String {
logger.info ("Before call to [demoService.defaultDispatcherReturn]")
val result = demoService.defaultDispatcherReturn("defaultDispatcher")
logger.info ("After call to [demoService.defaultDispatcherReturn]")
Expand All @@ -55,7 +55,7 @@ open class DemoController(
}

@GetMapping("/cachedDelayed")
suspend open fun cachedDelayedReturn(): String {
open suspend fun cachedDelayedReturn(): String {
logger.info ("Before call to [demoService.cachedDelayedReturn]")
val result = demoService.cachedDelayedReturn("cachedDelayed", 500)
logger.info ("After call to [demoService.cachedDelayedReturn]")
Expand All @@ -64,7 +64,7 @@ open class DemoController(
}

@GetMapping("/cachedDefaultDispatcherDelayed")
suspend open fun cachedDefaultDispatcherDelayed(): String {
open suspend fun cachedDefaultDispatcherDelayed(): String {
logger.info ("Before call to [demoService.cachedDefaultDispatcherDelayedReturn]")
val result = demoService.cachedDefaultDispatcherDelayedReturn("cachedDefaultDsipatcherDelayed", 1500)
logger.info ("After call to [demoService.cachedDefaultDeispatcherDelayedReturn]")
Expand All @@ -74,14 +74,14 @@ open class DemoController(

@GetMapping("/defaultDispatcherController")
@Coroutine(DEFAULT_DISPATCHER)
suspend open fun defaultDispatcherController(): String {
open suspend fun defaultDispatcherController(): String {
logger.info ("In [defaultDispatcherController]")

return "defaultDispatcherController"
}

@GetMapping("/event")
suspend open fun event(): String {
open suspend fun event(): String {
publisher.publishEvent(SimpleEvent("Hello"))
publisher.publishEvent(DemoApplicationEvent(this, "Hello"))
coroutinePublisher.publishEvent(SimpleEvent("Hello-coroutine"))
Expand All @@ -91,7 +91,7 @@ open class DemoController(
}

@GetMapping("/rest")
suspend open fun rest(request: HttpServletRequest): String {
open suspend fun rest(request: HttpServletRequest): String {
logger.info ("Before call to [restOperations.getForEntity]")
val result = restOperations.getForEntity(request.requestURL.toString().replace("rest", "delayed"), String::class.java)
logger.info ("After call to [restOperations.getForEntity]")
Expand All @@ -108,7 +108,7 @@ open class DemoController(

open class DemoApplicationEvent(
source: Any,
val message: String
private val message: String
): ApplicationEvent(source) {

override fun toString(): String = "DemoApplicationEvent(source=$source, message=$message)"
Expand Down