Skip to content

Conversation

@alexandru
Copy link
Member

@alexandru alexandru commented Feb 8, 2026

The plan is to wrap DelayedQueue JVM in a Scala-friendly API powered by Cats-Effect and functional programming.

@alexandru alexandru changed the title [WIP] DelayedQueue for Scala [WIP] DelayedQueue for Scala (sub-project) Feb 8, 2026
alexandru and others added 8 commits February 8, 2026 11:41
* Initial plan

* Add Scala data structures for DelayedQueue

- Created all configuration types (RetryConfig, JdbcDatabasePoolConfig, DelayedQueueTimeConfig, JdbcConnectionConfig, DelayedQueueJDBCConfig)
- Created message and envelope types (ScheduledMessage, BatchedMessage, BatchedReply, AckEnvelope, MessageId, DeliveryType)
- Created cron/scheduling types (CronMessage, CronConfigHash, CronDailySchedule, CronMessageGenerator)
- Created return/outcome types (OfferOutcome, ResourceUnavailableException, JdbcDriver)
- Added asJava and asScala conversion extensions for all types
- All code compiles and is formatted

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Add tests for Scala data structures

- Created test suites for RetryConfig, ScheduledMessage, JdbcDriver, and Cron types
- All tests verify conversions (asJava/asScala), validation, and basic functionality
- All 23 tests pass

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Address PR feedback: use Scala types, opaque MessageId, fix implementations

- Replace java.time.Duration with scala.concurrent.duration.FiniteDuration
- Make MessageId an opaque type instead of case class
- Fix OfferOutcome pattern matching to use instanceof checks
- Add covariance (+In, +A) to BatchedMessage and BatchedReply
- Port CronConfigHash, CronDailySchedule implementations exactly from JVM
- Add ScalaCheck and munit-scalacheck dependencies for property-based testing
- Remove unused imports

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Add property-based testing with ScalaCheck

- Add comprehensive property-based tests for all data structures
- Test roundtrip conversions (asJava/asScala)
- Test covariance for BatchedMessage and BatchedReply
- Test validation for RetryConfig and CronDailySchedule
- Test CronMessage key uniqueness
- All 35 tests pass (23 unit + 12 property-based)

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Refactor: delegate implementations to JVM, use idiomatic Scala patterns

Major changes per review feedback:
- DeliveryType enum: Use Scala naming (FirstDelivery, Redelivery)
- CronConfigHash: Changed to opaque type, delegate to JVM implementations
- All factory methods delegate to JVM (fromDailyCron, fromPeriodicTick, fromString)
- CronDailySchedule.getNextTimes delegates to JVM
- CronMessage.key and staticPayload delegate to JVM
- DelayedQueueTimeConfig defaults use JVM constants
- JdbcConnectionConfig: username/password now Option
- JdbcDatabasePoolConfig: Removed default parameters, added DEFAULT value
- JdbcDriver: Private constructor, use JVM as source of truth with jvmEntries map
- Test generators moved to common Generators.scala file
- Removed fromClassName test as requested
- All 34 tests pass

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Remove default parameters and delegate to JVM defaults

- DelayedQueueJDBCConfig: Removed default parameters for ackEnvSource and retryPolicy
- RetryConfig: Removed all default parameters (backoffFactor, maxRetries, totalSoftTimeout, perTryHardTimeout)
- RetryConfig.DEFAULT and NO_RETRIES now delegate to JVM constants via asScala
- Updated tests to provide all required parameters
- All 34 tests pass

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>
alexandru and others added 3 commits February 8, 2026 19:55
* Initial plan

* Implement DelayedQueueInMemory Scala wrapper with tests

- Created DelayedQueueInMemory.scala wrapping JVM implementation
- Implemented all DelayedQueue trait methods with proper type conversions
- Added CronService wrapper for cron functionality
- Created comprehensive test suite (19 tests, all passing)
- Follows existing patterns (asScala/asJava conversions)
- Uses Cats Effect IO for side effects management

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Change to F[_]

* Fix API again

* Reformatting

* Remove junk

* Add concurrency test

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>
Co-authored-by: Alexandru Nedelcu <noreply@alexn.org>
)

* Initial plan

* Add DelayedQueueJDBC Scala wrapper and tests

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Fix compilation and test issues, format code

- Added missing imports (cats.syntax.functor.*)
- Fixed runMigrations signature (doesn't need serializer)
- Added JDBC driver test dependencies to build.sbt
- Fixed test isolation by using unique table names
- Fixed database configuration for H2 and HSQLDB
- Formatted code with scalafmt
- All H2 and HSQLDB tests passing (36/36)

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Refactor to use PayloadCodec type-class and shared wrappers

- Renamed MessageSerializer to PayloadCodec as a proper type-class
- Changed deserialize to return Either[IllegalArgumentException, A]
- Made forStrings a given instance based on JVM MessageSerializer.forStrings
- Extracted shared DelayedQueueWrapper and CronServiceWrapper to internal.scala
- Updated DelayedQueueJDBC to use implicit PayloadCodec parameter
- Use Resource.fromAutoCloseable instead of Resource.make
- Inject JavaClock like in DelayedQueueInMemory using Dispatcher
- Use IO.interruptible for runMigrations
- Added concurrency test (reduced to 100 messages for JDBC performance)
- All 38 H2 and HSQLDB tests passing

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Fix compilation warnings and refactor internal wrappers

- Moved wrappers from object internal to top-level private[scala] classes
- Renamed getTypeName to typeName (remove Java-ism)
- Removed all unused imports in DelayedQueueInMemory and DelayedQueueJDBC
- All compilation warnings fixed
- All 38 H2/HSQLDB tests passing

Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>

* Fix compilation errors

* Remove SQLite

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alexandru <11753+alexandru@users.noreply.github.com>
Co-authored-by: Alexandru Nedelcu <noreply@alexn.org>
@alexandru alexandru changed the title [WIP] DelayedQueue for Scala (sub-project) DelayedQueue for Scala (sub-project) Feb 10, 2026
@alexandru alexandru merged commit 579cf20 into main Feb 10, 2026
4 checks passed
@alexandru alexandru deleted the scala branch February 10, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants