Skip to content

Commit

Permalink
Add frequency to cron scripts
Browse files Browse the repository at this point in the history
Summary:
Originally I made cron scripts support only a cron expression to designate how frequently as script should be run. However, cron expressions look like they dont support second granularity.
Instead, we can have cronscripts support two modes: cron expression (probably unsupported for now, as this is more difficult), and hardcoded seconds.

Test Plan: This diff just adds some fields, but doesn't use them yet.

Reviewers: vihang, nserrino

Reviewed By: vihang

Signed-off-by: Michelle Nguyen <michellenguyen@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D11030

GitOrigin-RevId: 1580e3a
  • Loading branch information
aimichelle authored and copybaranaut committed Mar 23, 2022
1 parent b96594e commit fc863b6
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 207 deletions.
249 changes: 199 additions & 50 deletions src/cloud/cron_script/cronscriptpb/service.pb.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/cloud/cron_script/cronscriptpb/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ message CronScript {
string token = 7;
// Whether the cron script is enabled.
bool enabled = 8;
// How frequently a script should be run, if not specified via cron.
int64 frequency_s = 9;
}

// GetScriptRequest is a request to fetch information about a script in the cron script service.
Expand Down Expand Up @@ -96,6 +98,8 @@ message CreateScriptRequest {
string configs = 4;
// Token for the user/org for which this script is run on behalf of.
string token = 5;
// How frequently a script should be run, if not specified via cron.
int64 frequency_s = 6;
}

// CreateScriptResponse is a response to a CreateScriptRequest.
Expand All @@ -113,6 +117,8 @@ message UpdateScriptRequest {
google.protobuf.StringValue configs = 4;
// Whether the cron script should be enabled.
google.protobuf.BoolValue enabled = 5;
// How frequently a script should be run, if not specified via cron.
google.protobuf.Int64Value frequency_s = 6;
}

// UpdateScriptResponse is a response to an UpdateScriptRequest.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE cron_scripts
DROP COLUMN frequency_s;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE cron_scripts
ADD COLUMN frequency_s integer;
54 changes: 50 additions & 4 deletions src/cloud/cron_script/schema/bindata.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fc863b6

Please sign in to comment.