yael 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yael/execution_job.rb +10 -3
- data/lib/yael/route.rb +3 -3
- data/lib/yael/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07272b866ce348e79efb9e790971130208778deeddda76a0f25b8ef31c12c8f6
|
4
|
+
data.tar.gz: 00cce80102e807dd79ce2eee4c89229f2a9b97511d27e0b924bd652cb754ef8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 930c85538376232c96631656b548efb6c7d0bfc382f9e5035eabcf5d963e0d70708a7e35da851e0328acc6014a95d26360493e0c2bf9536c3b68599136605a5f
|
7
|
+
data.tar.gz: 62a5196c9402528681213addc7802e13fec28c4ad0c3aae01b53c0083d1303961f6cffc448bb899c8f426c2dc2a6fd6729496fe1a4539c566b8e9633f96e3f13
|
data/lib/yael/execution_job.rb
CHANGED
@@ -4,17 +4,24 @@ module Yael
|
|
4
4
|
class ExecutionJob < ActiveJob::Base
|
5
5
|
retry_on ActiveRecord::Deadlocked
|
6
6
|
|
7
|
-
def perform(target_name, method, args)
|
7
|
+
def perform(target_name, method, stream, args)
|
8
8
|
target_constant = target_name.constantize
|
9
|
-
parameters = extract_parameters(target_constant.method(method), args)
|
9
|
+
parameters = extract_parameters(target_constant.method(method), stream, args)
|
10
10
|
target_constant.public_send method, **parameters
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def extract_parameters(method, args)
|
15
|
+
def extract_parameters(method, stream, args)
|
16
16
|
requested = method.parameters.select { |e| e.first == :keyreq }.map(&:second)
|
17
|
+
args.merge!(stream: stream) if requested.include?(:stream)
|
18
|
+
args.merge!(publisher: publisher_for(stream: stream)) if requested.include?(:publisher)
|
17
19
|
args.slice(*requested)
|
18
20
|
end
|
21
|
+
|
22
|
+
def publisher_for(stream:)
|
23
|
+
table, _, id = stream.partition "_"
|
24
|
+
table.classify.constantize.find(id)
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
data/lib/yael/route.rb
CHANGED
@@ -9,8 +9,8 @@ module Yael
|
|
9
9
|
@target = target
|
10
10
|
@queue = queue
|
11
11
|
@delay = delay
|
12
|
-
@target_name = target.split("
|
13
|
-
@target_method = target.split("
|
12
|
+
@target_name = target.split(".").first.classify
|
13
|
+
@target_method = target.split(".").second
|
14
14
|
end
|
15
15
|
|
16
16
|
def matches?(stream)
|
@@ -22,7 +22,7 @@ module Yael
|
|
22
22
|
def dispatch(event)
|
23
23
|
method = target_method || "on_#{event.name}"
|
24
24
|
args = event.payload.symbolize_keys
|
25
|
-
ExecutionJob.set(queue: queue, wait: delay).perform_later(target_name, method, args)
|
25
|
+
ExecutionJob.set(queue: queue, wait: delay).perform_later(target_name, method, event.stream, args)
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
data/lib/yael/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yael
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Ravens
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Yael is Yet Another Event Library based on top of ActiveJob. It helps
|
14
14
|
you dispatching events asynchronously in your code base and react to them just like
|