Added Scheduling DB module - #668
Conversation
Test Results727 tests 718 ✅ 27m 56s ⏱️ Results for commit f4ba9e7. ♻️ This comment has been updated with latest results. |
Standardized scheduling telemetry
- Added `BoundedVirtualThreadPerTaskExecutor` for scheduled DB job execution: - runs each accepted task in a fresh virtual thread; - limits concurrent execution by `scheduling.db.executionParallelism`; - keeps queued tasks FIFO instead of creating an unbounded number of running virtual threads; - supports normal `ExecutorService` lifecycle: graceful `shutdown()`, interrupting `shutdownNow()`, and `awaitTermination(...)`. - Added `SchedulingDbScheduler` lifecycle component backed by `db-scheduler`. - Added bounded virtual-thread execution for scheduled DB jobs. - Added configurable polling: - `FETCH` - `LOCK_AND_FETCH` - default / bounded / buffered prefetch modes - Split regular tasks from startup recurring tasks to avoid duplicate task registration. - Added DB job abstractions for cron, fixed-delay, and run-once jobs. - Added table initialization support with Flyway/Liquibase-compatible SQL resources. - Updated Java annotation processor and KSP generator for DB scheduling annotations. - Migrated scheduling DB config to `@ConfigMapper` / `ConfigValueMapper`. - Added and updated tests for config mapping, task behavior, table initialization, and generated scheduling code.
34da7ae to
12dae0a
Compare
|
Привет @strelchm спасибо за обзор, можешь еще повторно взглядом пройтись |
…erits the default infinite retry every five minutes. * Refactored module name from `scheduling-db` to `scheduling-db-scheduler` * Migrated `RunOnceJob` to `Tasks.custom(...).scheduleOnStartup(...)`. * On failure, it now calls `executionOperations.remove()`, meaning `@ScheduleOnce` is truly “run once, with no retries.” * Removed `scheduleOnStart` from `SchedulingDbJob`. * Removed the manual `resolvedJobs` loop from `SchedulingDbScheduler`. * `SchedulingDbScheduler` now adds every task implementing `OnStartup` to `startTasks`, as requested during the review.
- Added neutral `SchedulingDbCodec<T>` abstraction for db-scheduler payload serialization. - Added `@SchedulingDbJsonCodec` marker for JSON-backed payload codecs. - Added `SchedulingDbSerializer` that discovers `SchedulingDbCodec<?>` components and uses them for matching payload types. - Kept fallback to db-scheduler’s default Java serializer for unknown payload types. - Added a hardcoded `Void/null` payload path so built-in Kora scheduling jobs do not invoke fallback serialization. - Added dedicated Java annotation processor for `@SchedulingDbJsonCodec`. - Added dedicated KSP processor for `@SchedulingDbJsonCodec`. - Registered the new processors in service metadata. - Updated Gradle incremental annotation processor metadata. - Added tests for registered codec serialization, fallback serialization, `Void/null` payload handling, and generated codec modules.
Dependency Update ReportUpdate level: Found
|
ENAdded explicit JSON payload codec registration for dynamic RUДобавлена явная регистрация JSON-кодеков для payload-типов динамических задач
SchedulingDbJsonCodecA dynamic job payload can opt into JSON serialization: @Json
@SchedulingDbJsonCodec
public record EmailJobData(String email, String subject) {}The scheduling processors generate a Kora module that provides A user job can then use this payload type in a db-scheduler task descriptor: @Module
public interface EmailSchedulingModule {
TaskDescriptor<EmailJobData> EMAIL_TASK =
TaskDescriptor.of("email", EmailJobData.class);
@DefaultComponent
default SchedulingDbJob emailSchedulingJob(EmailSender sender) {
var task = Tasks.custom(EMAIL_TASK)
.execute((instance, context) -> {
var data = instance.getData();
sender.send(data.email(), data.subject());
return new CompletionHandler.OnCompleteRemove<>();
});
return () -> task;
}
}Application code can inject the exposed @Component
public final class EmailJobScheduler {
private final Scheduler scheduler;
public EmailJobScheduler(Scheduler scheduler) {
this.scheduler = scheduler;
}
public void scheduleEmail(String email, String subject, Instant runAt) {
var data = new EmailJobData(email, subject);
var instance = EmailSchedulingModule.EMAIL_TASK
.instance("email-" + email)
.data(data);
this.scheduler.schedule(instance, runAt);
}
}The payload is serialized through the generated |
Added named bounded virtual thread executors for scheduler execution Added constructor overloads that allow bounded virtual-thread-per-task executors to be configured with a thread pool name while preserving the existing builder-based customization path. - Improved scheduling-db default executor setup to use the named queued virtual thread executor directly. - Added support for queued, running, and blocking bounded virtual thread executor variants. ```
Added Scheduling DB module
Merge after #667