Skip to content

Conversation

@utterstep
Copy link
Contributor

@utterstep utterstep commented Oct 16, 2023

This is useful for users who are already working with sqlx and time, bc sqlx doesn't allow you to use chrono and time together (I have such a case, for example :)).

This PR proposes non-breaking change to allow such users specify that they need time, not chrono

  • leaves the default as chrono but allows users to opt-in to using time instead
  • adds a time feature to apalis-core, apalis-sql and apalis-redis
  • enabling both cron and time features now triggers a compile error because apalis-cron uses cron and cron depends on chrono
  • adds time to the CI matrix
  • (subjective) use datetime - duration instead of datetime.sub(duration)

I'd gladly accept any input from your side on how to make my proposal work for you to include it to the upstream :)

This is useful for users who are already working with `sqlx` and `time`,
bc `sqlx` doesn't allow you to use `chrono` and `time` together.

* leaves the default as `chrono` but allows users to opt-in to using
  `time` instead
* adds a `time` feature to `apalis-core`, `apalis-sql` and
  `apalis-redis`
* enabling both `cron` and `time` features now triggers a compile error
  because `apalis-cron` uses `cron` and `cron` depends on `chrono`
* adds `time` to the CI matrix
* (subjective) use `datetime - duration` instead of
  `datetime.sub(duration)`
@utterstep
Copy link
Contributor Author

Hi! Thanks for your attention to this PR!

I've updated tests, can you restart CI at some point? :)

@utterstep
Copy link
Contributor Author

Fixed rustfmt errors (🤦)

@utterstep
Copy link
Contributor Author

@geofmureithi all checks are passing now, what would you say about merging this PR?

Just to clarify – I'm absolutely OK to make any adjustments you'd like, regarding API/docs/examples/... :)

@geofmureithi geofmureithi self-requested a review October 24, 2023 03:04
@geofmureithi
Copy link
Member

what would you say about merging this PR?

The main reason this is pending is that I have been trying to move away from feature flags towards using traits.
Traits allow someone to decide what crate to use instead of hardcoding.
While I appreciate the PR, I wish we had discussed it before you did all this work.

Would you be ok if this PR is worked on into v0.5? We can start making those changes and start a 0.5-alpha branch.

@utterstep
Copy link
Contributor Author

Would you be ok if this PR is worked on into v0.5? We can start making those changes and start a 0.5-alpha branch.

Sure, no problem!

The main reason this is pending is that I have been trying to move away from feature flags towards using traits.
Traits allow someone to decide what crate to use instead of hardcoding.

Makes a lot of sense to me! However, there is one catch, as I see it now: sqlx supports time/chrono via mutually exclusive features currently (to be more precise, if both features are 'on' the chrono takes precedence silently, breaking all time
-expecting usage).
So apalis need to allow selection of sqlx features at least, and I don't know if that's possible using the traits only, seems like it's not currently :(

@geofmureithi
Copy link
Member

So apalis need to allow selection of sqlx features at least, and I don't know if that's possible using the traits only, seems like it's not currently :(

I am actually thinking of dropping sqlx for rbatis

@geofmureithi geofmureithi merged commit 7a4afee into apalis-dev:master Nov 9, 2023
@utterstep
Copy link
Contributor Author

@geofmureithi thank you so much for your collaboration! :)

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