gouda 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0be474cea3bc87b9c0a41c9c654a31e4dc865e46876249a1db615bf56e494a40
4
- data.tar.gz: '048574e736404c6c76f437fdfded93d7e810a23c83bb4f28ede8dffe9761a215'
3
+ metadata.gz: ec67da4c5d0dc236c02b65c770e87fe4a0a967eef8df50f0cb4ae452077f3bdb
4
+ data.tar.gz: 6089a03c99a944fcfedbe623810c72b513c52e2fe9afd698904ccab1f7cc3aa3
5
5
  SHA512:
6
- metadata.gz: 00e687d2fc384484cf2c07bf6c661e8d5ff1287a96f4e4f0abd98df2933538d7d81946ee51fe8e7abd6f2e5b285b6762aba231d359926ba5ee09d07a8b7e526c
7
- data.tar.gz: cbd09ad83be4b9e6b9b35e20b2c80b7c8a5b8de1e20f8adfa6d0701d1aa31be7e5ea8edd2e64fab8f67e69cdc9757d1bcf79908fac9a81e9eccf9497f0a1c073
6
+ metadata.gz: bb445a3c45a28d47f29124775f8f2f8c2cc9be8c6fb1069c8c3f1d00eca8269ca53d897c2cb069962bec90ee6b8b9916af133558b0692a3a64d46e3666fbb6f4
7
+ data.tar.gz: 3e82a95cf5f6107a8f9f7874a93d4bbbc58ac9a6badb2f684edca870cf6fbd3512be37299b192dcbb7a68a4be9fb638ea89af88625ae70459f1334a03b541407
data/CHANGELOG.md CHANGED
@@ -27,3 +27,12 @@
27
27
 
28
28
  - Update documentation
29
29
  - Don't pass on scheduler keys to retries
30
+
31
+ ## [0.1.6] - 2023-06-18
32
+
33
+ - Fix: don't upsert workloads twice when starting Gouda.
34
+ - Add back in Appsignal calls
35
+
36
+ ## [0.1.7] - 2023-06-21
37
+
38
+ - Separate all instrumentation to use ActiveSupport::Notification
data/lib/gouda/adapter.rb CHANGED
@@ -83,7 +83,7 @@ class Gouda::Adapter
83
83
  # Use batches of 500 so that we do not exceed the maximum statement size or do not create a transaction for the
84
84
  # insert which times out
85
85
  inserted_ids_and_positions = bulk_insert_attributes.each_slice(500).flat_map do |chunk|
86
- ActiveSupport::Notifications.instrument("insert_all.gouda", {n_rows: chunk.size}) do |payload|
86
+ Gouda.instrument(:insert_all, n_rows: chunk.size) do |payload|
87
87
  rows = Gouda::Workload.insert_all(chunk, returning: [:id, :position_in_bulk])
88
88
  payload[:inserted_jobs] = rows.length
89
89
  payload[:rejected_jobs] = chunk.size - rows.length
data/lib/gouda/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gouda
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.7"
5
5
  end
data/lib/gouda/worker.rb CHANGED
@@ -163,7 +163,8 @@ module Gouda
163
163
  # Find jobs which just hung and clean them up (mark them as "finished" and enqueue replacement workloads if possible)
164
164
  Gouda::Workload.reap_zombie_workloads
165
165
  rescue => e
166
- # Appsignal.add_exception(e)
166
+ Gouda.instrument(:exception, exception: e)
167
+
167
168
  warn "Uncaught exception during housekeeping (#{e.class} - #{e}"
168
169
  end
169
170
 
@@ -63,7 +63,7 @@ class Gouda::Workload < ActiveRecord::Base
63
63
  workload.with_lock("FOR UPDATE SKIP LOCKED") do
64
64
  Gouda.logger.info { "Reviving (re-enqueueing) Gouda workload #{workload.id} after interruption" }
65
65
 
66
- # Appsignal.increment_counter("gouda_workloads_revived", 1, job_class: workload.active_job_class_name)
66
+ Gouda.instrument(:workloads_revived_counter, size: 1, job_class: workload.active_job_class_name)
67
67
 
68
68
  interrupted_at = workload.last_execution_heartbeat_at
69
69
  workload.update!(state: "finished", interrupted_at: interrupted_at, last_execution_heartbeat_at: Time.now.utc, execution_finished_at: Time.now.utc)
@@ -110,7 +110,7 @@ class Gouda::Workload < ActiveRecord::Base
110
110
  .lock("FOR UPDATE SKIP LOCKED")
111
111
  .limit(1)
112
112
 
113
- _first_available_workload = ActiveSupport::Notifications.instrument("checkout_and_lock_one.gouda", {queue_constraint: queue_constraint.to_sql}) do |payload|
113
+ _first_available_workload = Gouda.instrument(:checkout_and_lock_one, queue_constraint: queue_constraint.to_sql) do |payload|
114
114
  payload[:condition_sql] = jobs.to_sql
115
115
  payload[:retried_checkouts_due_to_concurrent_exec] = 0
116
116
  uncached do # Necessary because we SELECT with a clock_timestamp() which otherwise gets cached by ActiveRecord query cache
data/lib/gouda.rb CHANGED
@@ -46,8 +46,6 @@ module Gouda
46
46
  end
47
47
 
48
48
  def self.start
49
- Gouda::Scheduler.upsert_workloads_from_entries_list!
50
-
51
49
  queue_constraint = if ENV["GOUDA_QUEUES"]
52
50
  Gouda.parse_queue_constraint(ENV["GOUDA_QUEUES"])
53
51
  else
@@ -72,6 +70,11 @@ module Gouda
72
70
  Gouda.config.logger
73
71
  end
74
72
 
73
+ def self.instrument(channel, **options, &block)
74
+ ActiveSupport::Notifications.instrument("#{channel}.gouda", **options, &block)
75
+ end
76
+
77
+
75
78
  def self.create_tables(active_record_schema)
76
79
  active_record_schema.create_enum :gouda_workload_state, %w[enqueued executing finished]
77
80
  active_record_schema.create_table :gouda_workloads, id: :uuid do |t|
@@ -645,6 +645,15 @@ class GoudaTest < ActiveSupport::TestCase
645
645
  assert_equal ["did-run"], Thread.current[:gouda_test_side_effects]
646
646
  end
647
647
 
648
+ test "instrumentation" do
649
+ payload = subscribed_notification_for("workloads_revived_counter.gouda") do
650
+ Gouda.instrument(:workloads_revived_counter, size: 1, job_class: "test_class")
651
+ end
652
+
653
+ assert_equal "test_class", payload[:job_class]
654
+ assert_equal 1, payload[:size]
655
+ end
656
+
648
657
  def sample_description(sample)
649
658
  values = sample.map(&:to_f).sort
650
659
 
@@ -67,4 +67,17 @@ class ActiveSupport::TestCase
67
67
  end
68
68
  end
69
69
  end
70
+
71
+ def subscribed_notification_for(notification)
72
+ payload = nil
73
+ subscription = ActiveSupport::Notifications.subscribe notification do |name, start, finish, id, _payload|
74
+ payload = _payload
75
+ end
76
+
77
+ yield
78
+
79
+ ActiveSupport::Notifications.unsubscribe(subscription)
80
+
81
+ return payload
82
+ end
70
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gouda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian van Hesteren
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-06-18 00:00:00.000000000 Z
12
+ date: 2024-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.5.11
191
+ rubygems_version: 3.5.13
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Job Scheduler