stampeded 0.3.2-aarch64-linux-gnu → 0.4.0-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30ba29fba7862a8c5b8877e8ab64babbc1c39868440dbb9f06d2d15cfd97412f
4
- data.tar.gz: 948af6558ab6a9480dd147f3c75d242e4965cd0ff22589e7b3d5afab4ce3aa2b
3
+ metadata.gz: 53c8e66093c59882f07b074dfcc3a9d30393bb51b5160c9305ed22c428ca7343
4
+ data.tar.gz: a2fa7d27e65b2b88c10e1bb1038c57f3eb016e2884c5cf98e3b3d2951f3d4a9b
5
5
  SHA512:
6
- metadata.gz: 8afb5700428b6820fc2e7f04e0c9662cfa25603fea90978684395993d5ac643e28c7a68e3bb53a347cdb6edd11e4ce68462210b9e4cac06f7561e70040e2fdff
7
- data.tar.gz: 21c220abe7c5167325ae2d1b95ced35686152804498706b5fe965c09aab19128abf5068cd5600939aaad74aaa91d49e63d2b73cf4666ff9456af95d491419628
6
+ metadata.gz: 61a4441b68ab539839b444cc43d087efcd2e55e5112076f90a3e02de846092fee9faedf4b3bd72da8c1ddf6cd3d65d25b790dc0ae2e6b0a107b3d2c65bac3ff9
7
+ data.tar.gz: 633f344ffe8f783892f92ddee0e8c8f6a92882608c3be81de1e991d016ff7d425a12af87a0b8767833350625277945d767507dc8e28a8fda7f9edc9a647322ae
@@ -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 CASCADE;
42
+ stampeded_jobs, stampeded_workers,
43
+ stampeded_schema CASCADE;
43
44
  DO $$
44
45
  DECLARE r record;
45
46
  BEGIN
@@ -22,10 +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
- args = ["--no-worker", *ENV["STAMPEDED_ARGS"].to_s.split]
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]
29
30
  Stampeded::Daemon.exec!(*args, env: { "STAMPEDED_DATABASE_URL" => Stampeded.database_url_for_daemon })
30
31
  end
31
32
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stampeded
4
- VERSION = "0.3.2" # x-release-please-version
4
+ VERSION = "0.4.0" # x-release-please-version
5
5
  end
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
- ':' || extract(
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
- )::bytea)
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);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stampeded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: aarch64-linux-gnu
6
6
  authors:
7
7
  - Abdelkader Boudih