bensheldon / good_job

Multithreaded, Postgres-based, Active Job backend for Ruby on Rails.
https://goodjob-demo.herokuapp.com/
MIT License
2.65k stars 195 forks source link

Use rails enum for `error_event` and `lock_type` #1420

Closed Earlopain closed 2 months ago

Earlopain commented 2 months ago

A bit more cleanup now that v4 is released.

Rails 7.2 will deprecate the legacy enum notation but the new one was only introduced in Rails 7.0 so a bit of version introspection is needed here.

I also had to notice that proper validations are only available in rails 7.1. I think that's fine, the test matrix will take care of this but its not as nice as I expected it would be.

There was a duplicate table_name in process.rb, I've removed that in the process of this.

bensheldon commented 2 months ago

I also had to notice that proper validations are only available in rails 7.1. I think that's fine, the test matrix will take care of this but its not as nice as I expected it would be.

In older versions it should raise an ArgumentError right? I'm sorta mixed on whether removing the constants in favor of strings+validations is equivalent in protection against fat fingering it, but it's probably ok 👍🏻

Earlopain commented 2 months ago

Yeah, that's right. You would get an ArgumentError on 6.1 at assign time (i.e. execution.error_type = :fiscarded). With the validate option on newer rails you get a proper RecordInvalid error.