saurabhnanda / odd-jobs

Haskell job queue with admin UI and loads of other features.
https://www.haskelltutorials.com/odd-jobs/
BSD 3-Clause "New" or "Revised" License
75 stars 29 forks source link

Make job deletion configurable #104

Closed saurabhnanda closed 1 year ago

saurabhnanda commented 1 year ago

Currently there are only two options here:

I propose something like the following:

data Config = Config
  { -- | This function will be evaluated every time a job is attempted (at the __end__ of the attempt)
   cfgImmediateJobDeletion :: Job -> IO Bool 

   -- | Another polling thread will be setup to run every 'cfgPollingInterval' seconds to execute this query
  , cfgDelayedJobDeletionSql :: PGS.Query
  , ...
  } 

defaultImmediateJobDeletion :: Job -> IO Bool
defaultImmedateJobDeletion Job{jobStatus} = 
  pure $ jobStatus == Success

defaultDeleayedJobDeletionSql :: PGS.Query
defaultDeleayedJobDeletionSql = 
  "DELETE FROM jobs WHERE status in ('success', 'failed') AND run_at < current_timestamp - '7 days'::interval"

Use cases

saurabhnanda commented 1 year ago

Folks, if anyone has a strong objection to the above proposal, please let me know.

@ivb-supercede @tfausak @jappeace @tchoutri

Please tag any other active users of odd-jobs as well.

tchoutri commented 1 year ago

LGTM :+1:

jappeace commented 1 year ago

would be nice this could be changed without breaking existing code

saurabhnanda commented 1 year ago

@jappeace if the fields of Config are changed but the type-signature of OddJobs.ConfigBuilder.mkConfig is maintained, even , would that work for you?

cc: @tfausak

jappeace commented 1 year ago

I think that's fine.