-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sql source provider and vendor updates.
- Loading branch information
Showing
302 changed files
with
268,418 additions
and
9,160 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
[meta] | ||
debug = true | ||
logging-enabled = true | ||
log-level = "debug" | ||
|
||
[metrics] | ||
enable-metrics = false | ||
[metrics.slack] | ||
enabled = false | ||
webhook-url = "" | ||
message-format = "" | ||
reporting-interval = "24h0m0s" | ||
[metrics.console] | ||
enabled = false | ||
reporting-interval = "24h0m0s" | ||
[metrics.cloudwatch] | ||
enabled = false | ||
webook-url = "" | ||
message-format = "" | ||
reporting-interval = "24h0m0s" | ||
namespace = "" | ||
reset-counters-after-report = false | ||
[metrics.cloudwatch.static-dimensions] | ||
|
||
[scheduler] | ||
enabled = true | ||
tick-duration = "1s" | ||
log-task-detection = false | ||
num-workers = 10 | ||
[scheduler.executor-http] | ||
enabled = true | ||
debug-response = false | ||
log-http-status = false | ||
use-jwt-signing = true | ||
jwt-issuer = "issuer" | ||
jwt-expires = "10m0s" | ||
jwt-subject = "0" | ||
jwt-secret = "" | ||
[scheduler.provider-crontab] | ||
enabled = false | ||
source = "/etc/asparagus/crontab" | ||
[scheduler.executor-local] | ||
enabled = true | ||
enable-output = true | ||
[scheduler.provider-etcd] | ||
enabled = false | ||
registry-url = ["http://127.0.0.1:4001"] | ||
discovery-enabled = false | ||
discovery-domain = "example.com" | ||
connect-ca-cert = "" | ||
source-folder = "/cron/Jobs" | ||
json-single-depth = true | ||
[scheduler.provider-sql] | ||
enabled = false | ||
uri = "/tmp/test.db" | ||
driver = "sqlite3" | ||
# uri = "root:password@tcp(127.0.0.1:3306)/database?parseTime=true" | ||
# driver = "mysql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# SQL Source Provider | ||
|
||
Asparagus may be used alongside a database service. Supported databases are: | ||
|
||
- sqlite3 | ||
- mysql | ||
|
||
Asparagus will create a database table for you, providing you specify a correct database. | ||
|
||
## Installation | ||
|
||
This module is included in the core of asparagus. As such, you can just go to your | ||
`asparagus.conf` and enable it. | ||
|
||
```toml | ||
[scheduler.provider-sql] | ||
# Required: Enable the SQL provider. | ||
enabled = true | ||
|
||
# for sqlite3 | ||
driver = "sqlite3" | ||
uri = "/tmp/test.db" | ||
|
||
# for mysql | ||
driver = "mysql" | ||
|
||
# make sure to suffix ?parseTime=true otherwise asparagus will complain about string to time conversion. | ||
uri = "root:pass@tcp(127.0.0.1:3306)/database?parseTime=true" | ||
``` | ||
|
||
## Job Configuration | ||
|
||
All jobs must be stored under an unique name inside the database. | ||
|
||
|
||
### Example | ||
|
||
```bash | ||
insert into cronjobs values ('test', 'test', '0', '* * * * *', NOW(), '', 'http', '{\"URL\": \"https://httpbin.org/get\", \"Method\": \"GET\"}', '', '10', '0'); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sql | ||
|
||
const ( | ||
// DefaultEnabled defines a state for default config | ||
DefaultEnabled = false | ||
|
||
// DefaultDatabaseURI defines the default contact point towards the mysql server instance | ||
DefaultDatabaseURI = "/tmp/asparagus.db" | ||
|
||
// DefaultDriver defines a default driver for the sql package | ||
DefaultDriver = "sqlite3" | ||
) | ||
|
||
// Config represents a configuration for a HTTP service. | ||
type Config struct { | ||
Enabled bool `toml:"enabled"` | ||
DatabaseURI string `toml:"uri"` | ||
DatabaseDriver string `toml:"driver"` | ||
} | ||
|
||
// NewConfig returns a new Config with default settings. | ||
func NewConfig() Config { | ||
return Config{ | ||
Enabled: DefaultEnabled, | ||
DatabaseURI: DefaultDatabaseURI, | ||
DatabaseDriver: DefaultDriver, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package sql_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/BurntSushi/toml" | ||
"github.com/nirnanaaa/asparagus/scheduler/provider/sql" | ||
) | ||
|
||
func TestConfig_Parse(t *testing.T) { | ||
// Parse configuration. | ||
c := sql.NewConfig() | ||
if _, err := toml.Decode(` | ||
enabled = false | ||
uri = "/tmp/test.db" | ||
driver = "test" | ||
`, &c); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Validate configuration. | ||
if c.Enabled { | ||
t.Fatalf("unexpected enabled: %v", c.Enabled) | ||
} else if c.DatabaseURI != "/tmp/test.db" { | ||
t.Fatalf("unexpected database uri: %v", c.DatabaseURI) | ||
} else if c.DatabaseDriver != "test" { | ||
t.Fatalf("unexpected database driver: %v", c.DatabaseDriver) | ||
} | ||
} |
Oops, something went wrong.