-
Notifications
You must be signed in to change notification settings - Fork 21
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
ISO8601 Support #13
ISO8601 Support #13
Conversation
Getting current time from database, calculating in program code, then updating the record is going to add one more round trip to each job execution, hence reduce throughput but I am not sure how much the impact going to be. I didn't do any benchmarks on Dalga before. I think this is not important anymore because more Dalga instances may be added to mitigate this. |
Got it, yeah I agree it will reduce performance a little but should be fine with horizontal scaling. Okay, I'm pretty much happy with this, here's a few specific points:
Daylight Savings(This point is rather involved so it gets its own heading.) As a side effect of using UTC time for everything, ISO8601 intervals may not behave exactly as intended. Specifically, there will be no recognition or compensation for daylight savings. For example, let's say I schedule a job at 3pm with interval However, Dalga uses UTC for all of its time tracking! This means that it's unaware of what timezone it's in, and when daylight savings occurs—it doesn't care. So Now, this isn't wrong, it's just...different than I first expected. I had to adjust my battery of tests to compensate for this behavior, but as I think about it, it seems fine, and possibly even superior. For example, here's what Google has to say about DST in the Cloud Scheduler docs:
Now, this isn't exactly the same scenario since we're not running on wall clock time, but it illustrates the fact that timezones are generally problematic. ...As I continue to think about it, one thing we could do is give each job an optional timezone. When we Questions, comments? If you like everything so far, it can be merged, or you can wait for me to add the timezone stuff. |
(As a note, I will likely ask to change the schema at least once more in this series of PRs. Food for thought in terms of when you want to merge things or do version bumps, etc.) |
@cenkalti any thoughts you have would be appreciated. In the meantime, I'm going to add timezone support. |
You can now provide a Note that this is different than providing a start time; the start time may have a time offset associated with it, but not a location. |
@@ -8,7 +8,8 @@ import ( | |||
|
|||
var DefaultConfig = Config{ | |||
Jobs: jobsConfig{ | |||
RetryInterval: 60, | |||
RetryInterval: "PT1M", |
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.
Is there a specific reason to change RetryInterval
to ISO duration? If not, I would like to keep it as seconds for simplicity. A user can start to use Dalga without knowing about ISO durations?
While we are doing a major version bump, I would also like to change the config file format to TOML, it is more common nowadays. github.com/BurntSushi/toml
library has also ability to unmarshal time.Duration
values. Do you have any comments on this?
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.
Is there a specific reason to change RetryInterval to ISO duration?
It had something to do with how the data was being passed and compared between functions and so on. Ah yes, I was changing Table.UpdateNextRun()
to take an ISO8601 duration, but I found that the same code path was used for a successful and a failed execution, so RetryInterval would need to feed into the same argument.
It just seemed silly to have Table.UpdateNextRun()
have both an ISO8601 and regular time.Duration
and use one or the other. I suppose I could do a conversion from time.Duration
into ISO8601 before passing it in?
A user can start to use Dalga without knowing about ISO durations?
Separate from the above, I'm not sure I understand. Won't he need to know ISO8601 durations now because that's how you schedule regular intervals? Unless you're thinking of one-off jobs specifically.
While we are doing a major version bump, I would also like to change the config file format to TOML, it is more common nowadays. github.com/BurntSushi/toml library has also ability to unmarshal time.Duration values. Do you have any comments on this?
Heh, personally I don't like TOML. Every time I go to read up on the documentation, I get to the part of how you can use [[something]]
or something.something
and they're basically the same except they're not, and I get confused and abandon the attempt.
I am a YAML fan, if you're into that. I find it's intuitive and easy to use that config format, as long as I'm not the one writing the parser for it 😉
I have used spf13/viper pretty extensively in the past and like it, although it has a lot of dependencies. I would probably only go that way if you considered switching to spf13/cobra for the CLI framework, since they integrate very well. But then, I have seen very minimal dependencies and mostly stdlib in Dalga so I doubt you want to go that route.
Something like knadh/koanf might do, or even just a straight YAML parser. But that depends on how you feel about YAML. I am also a fan of HJSON 😄
@@ -35,7 +39,8 @@ func (t *Table) Create(ctx context.Context) error { | |||
"CREATE TABLE `%s` (" + | |||
" `path` VARCHAR(255) NOT NULL," + | |||
" `body` VARCHAR(255) NOT NULL," + | |||
" `interval` INT UNSIGNED NOT NULL," + | |||
" `interval` VARCHAR(255) NOT NULL," + | |||
" `location` VARCHAR(255) NOT NULL," + |
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.
Can we allow NULL values and interpret them as UTC?
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.
Not sure if you're aware, but empty strings are currently interpreted as UTC. I can switch it to NULL if you prefer? Please confirm and I'll make the change.
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.
@tooolbox Sorry, I was away from computer this weekand. Thank you for this PR. I have a couple questions. We can merge this afterwards.
No problem! Looks like I have a little more work to do in general, we can finish hashing out exactly what's left to tweak and I will tackle it at some point over the next couple of days as my schedule allows. Cheers! |
Awesome! You're very welcome. |
As per #2
Depends on #11
Not done yet obviously, but since we're on different timezones if you could start reviewing and asking any questions, I'd appreciate it.
I'm having to change a lot more than I anticipated, but the subject is tricky. For example:
UTC_TIMESTAMP()
, do the math and put it back in.table
package.Anyway, here be dragons, but I hope to wrap this up tomorrow.