tisonkun / cronexpr

Calculate the next timestamp matching a given crontab pattern
https://docs.rs/cronexpr
Apache License 2.0
47 stars 2 forks source link

Support `H` as hash value #15

Open tisonkun opened 1 week ago

tisonkun commented 1 week ago

Coming from https://news.ycombinator.com/item?id=41657134

This could be built-in or enabled by an option (I'm considering adding a ParseOption and a new parse_crontab_with method anyway).

@tisonkun: This can be optionally supported. To be clear, does it mean almost "RANDOM at construction" and the parser will assign a value by a hash/random function and then the crontab struct has an immutable value of that field?

@epage (the same ID, not sure if the same person): The way jenkins did it is they took the job name and hashed that. This gives you good staggering while still being consistent from run to run (compared to using a random number). This does mean it is immutable, not just at construction but ideally across separate constructions so long as the seed is the same. For an API, I could see either taking in something that is hashable or just taking in a number and letting the caller choose their hashing. From the person's perspective writing cron syntax, they shouldn't care so long as they get the intended affect.

epage commented 1 week ago

Yes, thats me.