gouda 0.1.7 → 0.1.9

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: ec67da4c5d0dc236c02b65c770e87fe4a0a967eef8df50f0cb4ae452077f3bdb
4
- data.tar.gz: 6089a03c99a944fcfedbe623810c72b513c52e2fe9afd698904ccab1f7cc3aa3
3
+ metadata.gz: '068482a6e09e7964085e1640542cff5ce00a8c536c20b1225f21e998b5ea1d26'
4
+ data.tar.gz: 279759ccb7b9f19c4563839ba6c21f1b2fb1366e066e3534ce85d2220facfc07
5
5
  SHA512:
6
- metadata.gz: bb445a3c45a28d47f29124775f8f2f8c2cc9be8c6fb1069c8c3f1d00eca8269ca53d897c2cb069962bec90ee6b8b9916af133558b0692a3a64d46e3666fbb6f4
7
- data.tar.gz: 3e82a95cf5f6107a8f9f7874a93d4bbbc58ac9a6badb2f684edca870cf6fbd3512be37299b192dcbb7a68a4be9fb638ea89af88625ae70459f1334a03b541407
6
+ metadata.gz: 6c88fea153e08fa57f0a63cc72e3cc708d83eb5a67fb06d99587fba07d56ced9082ceecf2892e59872d1c8d09e0ee0a3b0e0bb462768270cdb799b8dc998ab9a
7
+ data.tar.gz: c1fd707147f85b7a9769fb1889015299e881ebb94cd79317207fcb24512e0e72b64bf303c2eb69a5079be1035087f37dbe045166791adf805daa10a90a73ecf9
data/CHANGELOG.md CHANGED
@@ -36,3 +36,11 @@
36
36
  ## [0.1.7] - 2023-06-21
37
37
 
38
38
  - Separate all instrumentation to use ActiveSupport::Notification
39
+
40
+ ## [0.1.8] - 2023-06-21
41
+
42
+ - Move some missed instrumentations to Gouda.instrument
43
+
44
+ ## [0.1.9] - 2023-06-26
45
+
46
+ - Fix: cleanup_preserved_jobs_before in Gouda::Workload.prune now points to Gouda.config
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
- Gouda.instrument(:insert_all, 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.7"
4
+ VERSION = "0.1.9"
5
5
  end
data/lib/gouda/worker.rb CHANGED
@@ -163,7 +163,7 @@ 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
- Gouda.instrument(:exception, exception: e)
166
+ Gouda.instrument(:exception, {exception: e})
167
167
 
168
168
  warn "Uncaught exception during housekeeping (#{e.class} - #{e}"
169
169
  end
@@ -45,7 +45,7 @@ class Gouda::Workload < ActiveRecord::Base
45
45
 
46
46
  def self.prune
47
47
  if Gouda.config.preserve_job_records
48
- where(state: "finished").where("execution_finished_at < ?", Gouda.cleanup_preserved_jobs_before.ago).delete_all
48
+ where(state: "finished").where("execution_finished_at < ?", Gouda.config.cleanup_preserved_jobs_before.ago).delete_all
49
49
  else
50
50
  where(state: "finished").delete_all
51
51
  end
@@ -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
- Gouda.instrument(:workloads_revived_counter, size: 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 = Gouda.instrument(:checkout_and_lock_one, queue_constraint: queue_constraint.to_sql) do |payload|
113
+ _first_available_workload = ActiveSupport::Notifications.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
@@ -147,7 +147,7 @@ class Gouda::Workload < ActiveRecord::Base
147
147
  end
148
148
 
149
149
  def perform_and_update_state!
150
- ActiveSupport::Notifications.instrument("perform_job.gouda", {workload: self}) do |instrument_payload|
150
+ Gouda.instrument(:perform_job, {workload: self}) do |instrument_payload|
151
151
  extras = {}
152
152
  if Gouda::JobFuse.exists?(active_job_class_name: active_job_class_name)
153
153
  extras[:error] = {class_name: "WorkloadSkippedError", message: "Skipped because of a fuse at #{Time.now.utc}"}
data/lib/gouda.rb CHANGED
@@ -70,8 +70,8 @@ module Gouda
70
70
  Gouda.config.logger
71
71
  end
72
72
 
73
- def self.instrument(channel, **options, &block)
74
- ActiveSupport::Notifications.instrument("#{channel}.gouda", **options, &block)
73
+ def self.instrument(channel, options, &block)
74
+ ActiveSupport::Notifications.instrument("#{channel}.gouda", options, &block)
75
75
  end
76
76
 
77
77
 
@@ -647,7 +647,7 @@ class GoudaTest < ActiveSupport::TestCase
647
647
 
648
648
  test "instrumentation" do
649
649
  payload = subscribed_notification_for("workloads_revived_counter.gouda") do
650
- Gouda.instrument(:workloads_revived_counter, size: 1, job_class: "test_class")
650
+ Gouda.instrument(:workloads_revived_counter, {size: 1, job_class: "test_class"})
651
651
  end
652
652
 
653
653
  assert_equal "test_class", payload[:job_class]
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.7
4
+ version: 0.1.9
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-21 00:00:00.000000000 Z
12
+ date: 2024-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord