stampeded 0.3.1-x86_64-linux-gnu → 0.4.0-x86_64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/stampeded/daemon.rb +3 -2
- data/lib/stampeded/schema.rb +3 -2
- data/lib/stampeded/tasks/stampeded.rake +4 -4
- data/lib/stampeded/version.rb +1 -1
- data/lib/stampeded.rb +8 -3
- data/libexec/libstampeded_ffi.so +0 -0
- data/libexec/stampeded +0 -0
- data/schema/schema.sql +21 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cad7f788cd761495c62f13f696e9a8b6a278fe20cddaf2973deed5fc58e1fb1f
|
|
4
|
+
data.tar.gz: 28788406522070a1ed14f54d8b855e26c7c3c0501c4b69bf6c4466d66f575807
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47083a221b84efec03e9693cd4cc543307c9c59f35aad9772a8d43b8de48c99fb31b0a770e5ee178ba693c2505b1afba9f0a30a08018528fb51a2d0f46ee9d1e
|
|
7
|
+
data.tar.gz: bb24cac65641ca47c82780535a3325bfab125306a7d14a9ed0536d0bcabbbe77c93c76aa97335fea0820a67a8be71ffc35bd971776d57034fcdd7035432e4ede
|
data/README.md
CHANGED
|
@@ -25,6 +25,14 @@ scheduler, reaper, pruner, expirer, health checks, HTTP API and dashboard. It
|
|
|
25
25
|
never runs a job itself. Without the daemon, jobs still run, but there is no
|
|
26
26
|
cron, no recovery of jobs from dead workers, no retention and no dashboard.
|
|
27
27
|
|
|
28
|
+
The daemon gets the database URL through its environment, never its command
|
|
29
|
+
line. Extra flags go in `STAMPEDED_ARGS`, which `ps` shows to everyone on the
|
|
30
|
+
host, so the dashboard token goes in `STAMPEDED_DASHBOARD_TOKEN` instead:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
STAMPEDED_DASHBOARD_TOKEN=... STAMPEDED_ARGS="--http 127.0.0.1:7878" bin/rails stampeded:daemon
|
|
34
|
+
```
|
|
35
|
+
|
|
28
36
|
## Transactional enqueue
|
|
29
37
|
|
|
30
38
|
```ruby
|
data/lib/stampeded/daemon.rb
CHANGED
data/lib/stampeded/schema.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Stampeded
|
|
|
9
9
|
def root
|
|
10
10
|
candidates = [
|
|
11
11
|
File.expand_path("../../schema", __dir__),
|
|
12
|
-
File.expand_path("../../../schema", __dir__)
|
|
12
|
+
File.expand_path("../../../crates/stampeded/schema", __dir__)
|
|
13
13
|
]
|
|
14
14
|
candidates.find { |d| File.directory?(d) } ||
|
|
15
15
|
raise(Error, "cannot find schema/*.sql (looked in #{candidates.join(", ")})")
|
|
@@ -39,7 +39,8 @@ module Stampeded
|
|
|
39
39
|
c.exec(<<~SQL)
|
|
40
40
|
DROP TABLE IF EXISTS stampeded_cron_occurrences, stampeded_schedules,
|
|
41
41
|
stampeded_queue_policies, stampeded_queue_counts,
|
|
42
|
-
stampeded_jobs, stampeded_workers
|
|
42
|
+
stampeded_jobs, stampeded_workers,
|
|
43
|
+
stampeded_schema CASCADE;
|
|
43
44
|
DO $$
|
|
44
45
|
DECLARE r record;
|
|
45
46
|
BEGIN
|
|
@@ -22,11 +22,11 @@ namespace :stampeded do
|
|
|
22
22
|
worker.run
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
desc "Run the daemon (scheduler, reaper, pruner, dashboard). Not the worker."
|
|
25
|
+
desc "Run the daemon (scheduler, reaper, pruner, dashboard). Not the worker. Upgrades the schema first."
|
|
26
26
|
task daemon: :environment do
|
|
27
27
|
require "stampeded/daemon"
|
|
28
|
-
|
|
29
|
-
args
|
|
30
|
-
Stampeded::Daemon.exec!(*args)
|
|
28
|
+
# --migrate is safe on every start: it upgrades an older schema in place.
|
|
29
|
+
args = ["--no-worker", "--migrate", *ENV["STAMPEDED_ARGS"].to_s.split]
|
|
30
|
+
Stampeded::Daemon.exec!(*args, env: { "STAMPEDED_DATABASE_URL" => Stampeded.database_url_for_daemon })
|
|
31
31
|
end
|
|
32
32
|
end
|
data/lib/stampeded/version.rb
CHANGED
data/lib/stampeded.rb
CHANGED
|
@@ -50,9 +50,14 @@ module Stampeded
|
|
|
50
50
|
params = Connection.connection_params
|
|
51
51
|
return params if params.is_a?(String)
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
userinfo = URI.encode_uri_component(params[:user].to_s)
|
|
54
|
+
userinfo += ":#{URI.encode_uri_component(params[:password].to_s)}" if params[:password]
|
|
55
|
+
host = params[:host].to_s
|
|
56
|
+
host = host.include?(":") ? "[#{host}]" : URI.encode_uri_component(host)
|
|
57
|
+
host += ":#{params[:port]}" if params[:port]
|
|
58
|
+
url = "postgres://#{userinfo}#{"@" unless userinfo.empty?}#{host}/#{URI.encode_uri_component(params[:dbname].to_s)}"
|
|
59
|
+
tls = params.slice(*Connection::TLS_KEYS).map { |key, value| "#{key}=#{URI.encode_uri_component(value.to_s)}" }
|
|
60
|
+
tls.empty? ? url : "#{url}?#{tls.join("&")}"
|
|
56
61
|
end
|
|
57
62
|
|
|
58
63
|
def create_queue(name)
|
data/libexec/libstampeded_ffi.so
CHANGED
|
Binary file
|
data/libexec/stampeded
CHANGED
|
Binary file
|
data/schema/schema.sql
CHANGED
|
@@ -65,15 +65,20 @@ CREATE TABLE stampeded_jobs (
|
|
|
65
65
|
dedup_period text CHECK (dedup_period IN
|
|
66
66
|
('minute','hour','day','week','month')),
|
|
67
67
|
|
|
68
|
+
-- Scope, period and bucket: buckets of two periods start together (an
|
|
69
|
+
-- hour and its day at midnight UTC), so the period keeps them apart.
|
|
70
|
+
-- Joined as bytea with a raw zero byte: no `text` value can ever decode
|
|
71
|
+
-- to one (chr(0) itself is refused), so a crafted dedup_scope can never
|
|
72
|
+
-- forge the separator and so never forge another row's key.
|
|
68
73
|
dedup_key bytea GENERATED ALWAYS AS (
|
|
69
|
-
sha256(
|
|
70
|
-
dedup_scope || coalesce(
|
|
71
|
-
'
|
|
74
|
+
sha256(
|
|
75
|
+
dedup_scope::bytea || '\x00'::bytea || coalesce(
|
|
76
|
+
dedup_period::bytea || '\x00'::bytea || extract(
|
|
72
77
|
epoch FROM (date_trunc(dedup_period, inserted_at, 'UTC') - to_timestamp(0))
|
|
73
|
-
)::bigint::text,
|
|
74
|
-
''
|
|
78
|
+
)::bigint::text::bytea,
|
|
79
|
+
''::bytea
|
|
75
80
|
)
|
|
76
|
-
)
|
|
81
|
+
)
|
|
77
82
|
) STORED,
|
|
78
83
|
|
|
79
84
|
failure_kind text,
|
|
@@ -1047,3 +1052,13 @@ CREATE TABLE stampeded_queue_policies (
|
|
|
1047
1052
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
1048
1053
|
updated_at timestamptz NOT NULL DEFAULT now()
|
|
1049
1054
|
);
|
|
1055
|
+
|
|
1056
|
+
-- Which schema this database holds, one row: `stampeded::schema::migrate`
|
|
1057
|
+
-- upgrades from it and refuses one newer than itself. Raised by each upgrade.
|
|
1058
|
+
CREATE TABLE stampeded_schema (
|
|
1059
|
+
version integer NOT NULL CHECK (version > 0),
|
|
1060
|
+
changed_at timestamptz NOT NULL DEFAULT now()
|
|
1061
|
+
);
|
|
1062
|
+
CREATE UNIQUE INDEX stampeded_schema_one_row ON stampeded_schema ((true));
|
|
1063
|
+
-- Must match schema::VERSION.
|
|
1064
|
+
INSERT INTO stampeded_schema (version) VALUES (3);
|