waldit 0.0.1 → 0.0.2

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: afad3b16943e3984c6584b02ef8edb2fb8abb8413687726a657110018e9fcbd4
4
- data.tar.gz: 934aacd6442c00b7fd40287360e2d8a1b52e0f37328711e029d36812d9cf94d1
3
+ metadata.gz: 8367ecd692940c28ead4bc255173137f7d9f34b9db3df262c15081ab64334ce0
4
+ data.tar.gz: 84a7c6eeee1b62ff8a3f507e5ae6128759292a80d6e5bd1f1a936ca33c431326
5
5
  SHA512:
6
- metadata.gz: ff61b8c0d473390f5197ae4544ad932014483ba68cdb8972e79eee35d4747814c5e64ae60cc53a078653de82f483ae94e98db69b40796a8be0d38b1a9db694d1
7
- data.tar.gz: a9e6c961b67f1be3335d773af2c42d76b7f74fd5d0eb48bd3cb5dce4cf355ce88144caa626ede05de357af47ce03986893bd0b9accab687bf4490c077fc8c787
6
+ metadata.gz: 161fafcaba15339898929328f103ff1b659aa17aa89179e7e9124ecb7f7b0487da39d55402711f02f724326203a28c2f7e322ba97a28b3672007663114ac33fd
7
+ data.tar.gz: cd4cc774d28e9f14732bc807478716c190fa52f6b2f4ec243512655db7fbd3d5aae6c712e7a9a301192702ea5b5a3753e315921ca62c64ea8c7c0119ffa27950
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ # typed: false
3
+
4
+ module Waldit
5
+ module Sidekiq
6
+ class SaveContext
7
+ include ::Sidekiq::ClientMiddleware
8
+
9
+ def call(job_class, job, queue, redis)
10
+ if (context = Waldit.context)
11
+ job["waldit_context"] = context.to_json
12
+ end
13
+ yield
14
+ end
15
+ end
16
+
17
+ class LoadContext
18
+ include ::Sidekiq::ServerMiddleware
19
+
20
+ def call(job_instance, job, queue, &block)
21
+ context = deserialize_context(job) || {}
22
+ Waldit.with_context(context.merge(background_job: job_instance.class.to_s), &block)
23
+ end
24
+
25
+ private
26
+
27
+ def deserialize_context(job)
28
+ if (serialized_context = job["waldit_context"]) && serialized_context.is_a?(String)
29
+ context = JSON.parse(serialized_context)
30
+ context if context.is_a? Hash
31
+ end
32
+ rescue JSON::ParserError
33
+ nil
34
+ end
35
+ end
36
+ end
37
+ end
@@ -2,5 +2,5 @@
2
2
  # typed: true
3
3
 
4
4
  module Waldit
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
  end
data/rbi/waldit.rbi CHANGED
@@ -2,7 +2,7 @@
2
2
  module Waldit
3
3
  extend T::Sig
4
4
  extend Waldit::Context
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.2"
6
6
 
7
7
  class << self
8
8
  sig { returns(String) }
@@ -63,6 +63,39 @@ module Waldit
63
63
  def diff; end
64
64
  end
65
65
 
66
+ module Sidekiq
67
+ class SaveContext
68
+ include ::Sidekiq::ClientMiddleware
69
+
70
+ sig do
71
+ params(
72
+ job_class: T.untyped,
73
+ job: T.untyped,
74
+ queue: T.untyped,
75
+ redis: T.untyped
76
+ ).returns(T.untyped)
77
+ end
78
+ def call(job_class, job, queue, redis); end
79
+ end
80
+
81
+ class LoadContext
82
+ include ::Sidekiq::ServerMiddleware
83
+
84
+ sig do
85
+ params(
86
+ job_instance: T.untyped,
87
+ job: T.untyped,
88
+ queue: T.untyped,
89
+ block: T.untyped
90
+ ).returns(T.untyped)
91
+ end
92
+ def call(job_instance, job, queue, &block); end
93
+
94
+ sig { params(job: T.untyped).returns(T.untyped) }
95
+ def deserialize_context(job); end
96
+ end
97
+ end
98
+
66
99
  class Watcher < Wal::StreamingWatcher
67
100
  extend T::Sig
68
101
 
data/sig/waldit.rbs CHANGED
@@ -39,6 +39,23 @@ module Waldit::Record
39
39
  def diff: () -> ::Hash[String | Symbol, [ untyped, untyped ]]
40
40
  end
41
41
 
42
+ module Waldit::Sidekiq
43
+ end
44
+
45
+ class Waldit::Waldit::Sidekiq::SaveContext
46
+ include ::Sidekiq::ClientMiddleware
47
+
48
+ def call: (untyped job_class, untyped job, untyped queue, untyped redis) -> untyped
49
+ end
50
+
51
+ class Waldit::Waldit::Sidekiq::LoadContext
52
+ include ::Sidekiq::ServerMiddleware
53
+
54
+ def call: (untyped job_instance, untyped job, untyped queue) { () -> untyped } -> untyped
55
+
56
+ def deserialize_context: (untyped job) -> untyped
57
+ end
58
+
42
59
  class Waldit::Watcher < Wal::StreamingWatcher
43
60
  def audit_event: (InsertEvent | UpdateEvent | DeleteEvent event) -> void
44
61
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waldit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Navarro
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-29 00:00:00.000000000 Z
10
+ date: 2025-07-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: wal
@@ -93,6 +93,20 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: sidekiq
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
96
110
  description: Postgres based audit trail for your Active Records, with 100% consistency.
97
111
  email:
98
112
  - rnavarro@rnavarro.com.br
@@ -109,6 +123,7 @@ files:
109
123
  - lib/waldit/postgresql_adapter.rb
110
124
  - lib/waldit/railtie.rb
111
125
  - lib/waldit/record.rb
126
+ - lib/waldit/sidekiq.rb
112
127
  - lib/waldit/version.rb
113
128
  - lib/waldit/watcher.rb
114
129
  - rbi/waldit.rbi