Skip to content

Added Scheduling DB module - #668

Open
GoodforGod wants to merge 14 commits into
masterfrom
feature/scheduling-db-module
Open

Added Scheduling DB module#668
GoodforGod wants to merge 14 commits into
masterfrom
feature/scheduling-db-module

Conversation

@GoodforGod

@GoodforGod GoodforGod commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Added Scheduling DB module

Merge after #667

@GoodforGod GoodforGod added this to the v2.0.0 milestone Jun 13, 2026
@GoodforGod GoodforGod added new module Feature where new module is added module: scheduling Related to Scheduling module labels Jun 13, 2026
@github-actions

github-actions Bot commented Jun 13, 2026

Copy link
Copy Markdown

Test Results

727 tests   718 ✅  27m 56s ⏱️
 99 suites    9 💤
 99 files      0 ❌

Results for commit f4ba9e7.

♻️ This comment has been updated with latest results.

@GoodforGod
GoodforGod marked this pull request as draft June 30, 2026 19:27
@GoodforGod GoodforGod changed the title Added Scheduling DB module [Draft] Added Scheduling DB module Jun 30, 2026
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.
@GoodforGod
GoodforGod force-pushed the feature/scheduling-db-module branch from 34da7ae to 12dae0a Compare July 13, 2026 10:08
@GoodforGod
GoodforGod requested a review from strelchm July 13, 2026 10:56
@GoodforGod

Copy link
Copy Markdown
Contributor Author

Привет @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.
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Dependency Update Report

Update level: patch

Found 3 dependency updates.

gradle/libs.versions.toml

  • s3client-aws (software.amazon.awssdk:s3, inline:249): 2.47.5 -> 2.47.6
  • zeebe: 8.9.12 -> 8.9.13
  • kotlin-stdlib: 2.4.0 -> 2.4.10

@GoodforGod
GoodforGod requested a review from Squiry July 17, 2026 23:18
@GoodforGod GoodforGod changed the title [Draft] Added Scheduling DB module Added Scheduling DB module Jul 20, 2026
@GoodforGod
GoodforGod marked this pull request as ready for review July 20, 2026 00:46
@GoodforGod

Copy link
Copy Markdown
Contributor Author

EN

Added explicit JSON payload codec registration for dynamic db-scheduler jobs. Payload types annotated with @Json and @SchedulingDbJsonCodec now get generated SchedulingDbCodec<T> components, while unknown payloads keep using the default Java serializer and built-in Void/null jobs avoid fallback serialization.


RU

Добавлена явная регистрация JSON-кодеков для payload-типов динамических задач db-scheduler. Типы с @Json и @SchedulingDbJsonCodec получают сгенерированный компонент SchedulingDbCodec<T>, неизвестные payload-типы продолжают использовать стандартный Java-сериализатор, а встроенные задачи с Void/null не дергают fallback-сериализацию.


  • Added neutral SchedulingDbCodec<T> payload serialization abstraction discovered by SchedulingDbSerializer.
  • Added @SchedulingDbJsonCodec for JSON-backed dynamic job payloads with generated SchedulingDbCodec<T> components.
  • Added serializer fallback behavior for unknown payload types via db-scheduler's default Java serializer.
  • Added hardcoded Void/null payload handling so built-in Kora scheduling jobs avoid fallback serialization.
  • Added dedicated Java AP and KSP processors for @SchedulingDbJsonCodec.

SchedulingDbJsonCodec

A 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 SchedulingDbCodec<EmailJobData> using TypeRef<EmailJobData>, JsonReader<EmailJobData>, and JsonWriter<EmailJobData>.

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 Scheduler and schedule task instances with typed payload data:

@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 SchedulingDbCodec<EmailJobData>. If no codec is registered for a payload type, SchedulingDbSerializer falls back to db-scheduler's default Java serializer. Built-in Kora jobs use Void/null payloads and are handled by a small sentinel path without invoking fallback serialization.

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.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: scheduling Related to Scheduling module new module Feature where new module is added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants