-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
7d1458b
to
616f9b2
Compare
} | ||
|
||
func cleanExpiredRetries() { | ||
ok, err := client.SetNX(fmt.Sprintf("%s%s", workerSettings.Namespace, keyForCleaningExpiredRetries), os.Getpid(), cleaningExpiredRetriesInterval/2).Result() |
There was a problem hiding this comment.
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?
client.LSet(fmt.Sprintf("%sfailed", workerSettings.Namespace), int64(i), hopefullyUniqueValueWeCanUseToDeleteJob) | ||
client.LRem(fmt.Sprintf("%sfailed", workerSettings.Namespace), 1, hopefullyUniqueValueWeCanUseToDeleteJob) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment / Test?
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
3debefc
to
f213a0e
Compare
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