Skip to content

[WIP] DelayedQueue for Scala (sub-project)#17

Open
alexandru wants to merge 13 commits intomainfrom
scala
Open

[WIP] DelayedQueue for Scala (sub-project)#17
alexandru wants to merge 13 commits intomainfrom
scala

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 2 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>
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