Skip to content
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 @@ -45,9 +45,13 @@ internal open class CoroutineSchedulerConfiguration: ImportAware {

@Bean(COROUTINE_SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
open fun coroutineScheduledAnnotationBeanPostProcessor(
contextResolver: GlobalCoroutineContextResolver
contextResolver: GlobalCoroutineContextResolver,
schedulingPolicyProvider: SchedulingPolicyProvider
): ScheduledAnnotationBeanPostProcessor =
CoroutineScheduledAnnotationBeanPostProcessor(schedulerDispatcher, contextResolver, DefaultSchedulingPolicyProvider())
CoroutineScheduledAnnotationBeanPostProcessor(schedulerDispatcher, contextResolver, schedulingPolicyProvider)

@Bean
open fun defaultSchedulingPolicyProvider() = DefaultSchedulingPolicyProvider()
}

@Configuration
Expand All @@ -70,4 +74,4 @@ private class CoroutineSchedulerPostProcessor : BeanDefinitionRegistryPostProces
registry.removeBeanDefinition(COROUTINE_SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class CoroutineSchedulerSpec extends Specification {
counter <= 10

where:
configuration << [FixedDelayWithInitialDelayConfiguration, FixedDelayWithInitialDelayStringConfiguration]
configuration << [FixedDelayWithInitialDelayConfiguration, FixedDelayWithInitialDelayStringConfiguration,
FixedDelayStringWithInitialDelayStringConfiguration]
}

@Unroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.springframework.kotlin.coroutine.scheduler
import kotlinx.coroutines.delay
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.PropertySource
import org.springframework.kotlin.coroutine.EnableCoroutine
import org.springframework.kotlin.coroutine.context.DEFAULT_DISPATCHER
import org.springframework.scheduling.annotation.EnableScheduling
Expand Down Expand Up @@ -90,6 +91,15 @@ open class FixedDelayWithInitialDelayStringConfiguration : DefaultDispatcherConf
}
}

@Configuration
@PropertySource("classpath:/org/springframework/kotlin/coroutine/scheduler/app.yml")
open class FixedDelayStringWithInitialDelayStringConfiguration : DefaultDispatcherConfiguration() {
@Scheduled(initialDelayString = "\${initialDelay}", fixedDelayString = "\${fixedDelay}")
suspend open fun task() {
counter().incrementAndGet()
}
}

@Configuration
open class FixedRateConfiguration : DefaultDispatcherConfiguration() {
@Scheduled(fixedRate = 10)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
initialDelay: 1000
fixedDelay: 100