clockwork icon indicating copy to clipboard operation
clockwork copied to clipboard

Question: Multiple At

Open limoli opened this issue 5 years ago • 5 comments

I am new into this library and I would know if there is the possibility to implement multiple scheduled hours using At method.

Example

sched.Schedule().Every(2).Days().At("9:30").At("11:30").Do(something)

Or

sched.Schedule().Every(2).Days().At([]string{"12:32", "11:30"}).Do(something)

limoli avatar Mar 19 '19 15:03 limoli

Looks cool, shouldn't be too hard to implement, you can try it and open a PR if you want :)

sbrki avatar Apr 08 '19 17:04 sbrki

Is this issue still open?

unishubh avatar Jul 30 '19 02:07 unishubh

@unishubh it is tagged as open, are you working on a pr or waiting for whiteshtef to add it in?

pizzalord22 avatar Oct 31 '19 20:10 pizzalord22

@pizzalord22 it is still open. Is use of multiple At statements really that useful? I could implement it if you find it easier to use.

I personally use

sched.Schedule().Every().Day().At("xxx").Do(foo)
sched.Schedule().Every().Day().At("yyy").Do(foo)

because it seems more readable than

sched.Schedule().Every().Day().At("xxx").At("yyy").Do(foo)

If you really want it as a one-liner, it shouldn't be too hard to implement, but it will ad some complexity to the scheduleNextRun() method which is already horrible as it is.

sbrki avatar Nov 05 '19 10:11 sbrki

@whiteShtef i would go for readability, since keeping things readable and as simple as possible makes it easier to implement new things.

that being said it might be nice to have multiple function ran in the same row in a certrain order.

pizzalord22 avatar Nov 05 '19 13:11 pizzalord22