Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goworker: Added 'MaxAgeRetries' option to the Goworker #9

Merged
merged 1 commit into from
Jul 19, 2021

Conversation

xescugc
Copy link
Member

@xescugc xescugc commented Jul 1, 2021

This option is useful to automatically remove retried failed jobs from the 'failed' queue that exceede that duration, this
check will be done every 1m.

Also changed the 'failed.FailedAt' and added 'failed.RetriedAt' and switched them to type string. The main reason is
that the Ruby lib is setting those values in an specific format and Ruby can read multiple formats into one, but GO
cannot and we need to actually use the same ones or the unmarshaler does not work so I decided to switch them to
'string' and add helpers to set/get the values that will directly convert them.

All the logic has more or less been ported from the Ruby version, on how to remove failed jobs and how the data
is stored, as the 'MaxAgeRetries' is something unique from this GO version

@xescugc xescugc self-assigned this Jul 1, 2021
@xescugc xescugc force-pushed the fg-retries-clean branch 2 times, most recently from 7d1458b to 616f9b2 Compare July 1, 2021 13:51
}

func cleanExpiredRetries() {
ok, err := client.SetNX(fmt.Sprintf("%s%s", workerSettings.Namespace, keyForCleaningExpiredRetries), os.Getpid(), cleaningExpiredRetriesInterval/2).Result()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly does this do? And why not log something on !ok result?

Comment on lines +250 to +254
client.LSet(fmt.Sprintf("%sfailed", workerSettings.Namespace), int64(i), hopefullyUniqueValueWeCanUseToDeleteJob)
client.LRem(fmt.Sprintf("%sfailed", workerSettings.Namespace), 1, hopefullyUniqueValueWeCanUseToDeleteJob)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic behind this is not obvious, why setting and then removing?

@@ -39,6 +39,21 @@ func newWorker(id string, queues []string) (*worker, error) {
func (w *worker) MarshalJSON() ([]byte, error) {
return json.Marshal(w.String())
}
func (w *worker) UnmarshalJSON(b []byte) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment / Test?

RetriedAt string `json:"retried_at"`
}

func (f *failure) GetRetriedAtTime() (time.Time, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment / Test?

@xescugc
Copy link
Member Author

xescugc commented Jul 2, 2021

Added comments to the missing/unclear parts.

I will not add tests yet (tested it manually) as the full lib is without any tests and I want to make an internal refactor to facilitate testing and add testing for everything.

This option is useful to automatically remove retried failed jobs from the 'failed' queue that exceede that duration, this
check will be done every 1m.

Also changed the 'failed.FailedAt' and added 'failed.RetriedAt' and switched them to type string. The main reason is
that the Ruby lib is setting those values in an specific format and Ruby can read multiple formats into one, but GO
cannot and we need to actually use the same ones or the unmarshaler does not work so I decided to switch them to
'string' and add helpers to set/get the values that will directly convert them.

All the logic has more or less been ported from the Ruby version, on how to remove failed jobs and how the data
is stored, as the 'MaxAgeRetries' is something unique from this GO version
@xescugc xescugc merged commit 46e3911 into master Jul 19, 2021
@xescugc xescugc deleted the fg-retries-clean branch July 19, 2021 13:09
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