lucas34 / SwiftQueue

Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more
MIT License
409 stars 42 forks source link

Get additional info for a job #409

Closed ivan-kolesov closed 2 years ago

ivan-kolesov commented 2 years ago

Is it possible to get additional information about a running task: scheduled start time, number of iterations, task status (pending, running, completed)? If it were possible to obtain an instance of SqOperation publicly, then this question would not exist.

lucas34 commented 2 years ago

You can use JobListener and react based on different events

ivan-kolesov commented 2 years ago

You can use JobListener and react based on different events

Tried to play with JobListener, but can't get nextRunSchedule that handles SqOperation only.

lucas34 commented 2 years ago

What does nextRunSchedule means ?

ivan-kolesov commented 2 years ago

nextRunSchedule

This means when the next time job will start based on scheduled time. Because retry delay might be linear or exponential and no any way to determine the delay inside a job.

lucas34 commented 2 years ago

If you want the info in the internal logger I think we can add it.

Otherwise I suggest you implement your custom Retry Constraint using

 JobBuilder(type: type)
                .add(constraint: MyCustomRetryConstraint())
                .schedule(manager: manager)

If your job require serialisation make sure your MyCustomRetryConstraint implement CodableConstraint. And in your deserialiser you need to inject the MyCustomRetryConstraint inside the constraint factory from DecodableSerializer

DecodableSerializer(maker: MyCustomConstraintMaker())
ivan-kolesov commented 2 years ago

Thanks, I want to see the info not in internal logger, but somewhere as you offered, in JobListener. If I implement a custom constraint will the constraint persist in the storage where job saves?

lucas34 commented 2 years ago

Yes if your custom constraint extends CodableConstraint. Also you will need a custom ConstraintMaker to re-add the custom constraint when deserialiser.

All internal constraints Are also created using this mechanism

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ivan-kolesov commented 2 years ago

Retry Constraint is marked as final, and it's not a good idea cloning the constraint for modifying a few lines

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.