thunderchunk 0.2.0 → 0.2.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: c833649b47c00913dff97d2e720c98081377b18423134fe802b974684b0845fe
4
- data.tar.gz: 3f361ec71acc5ad2da5c9768e7e9f6f5a0ae60c8ae8cfd22d94a3f0372b754af
3
+ metadata.gz: ef2a4134ae196a39e9d602aa187dd47ad6983db8d16d0e671885158b1cf66e81
4
+ data.tar.gz: 0fc654f13a70c6f48915c1f9e2153aec42cf63cba81d737fd0b8ee057a3490d9
5
5
  SHA512:
6
- metadata.gz: 61ffba944656899c69bb55224b4e15dec0158a6b8656a681095744420cbd6617c57350b6dae9048a75c9f0fb89a8aebbeae710bb636954bcd9d42f6105205e59
7
- data.tar.gz: b0ccaacb0c416783f87c1e03fc0f1d7061463eb2cf2a172cf2c3f6f0d534fa8231640bd4c2d1f687e80744ff4f9edee75eedc6f369375fcd5940630801476167
6
+ metadata.gz: cde1411e7d40208491a3ff56816f55deb27d96f79d41c97bc77b400d7713848137b4e6e12cc4d75fe8f9e2a7ade027e621fb06d1bddfacd4e08b259b6970e481
7
+ data.tar.gz: a63f1d10fef9aa8132ace691dcd09db10946d32e3bdd5c42c6dca8b56aaa86524967db14e0de08d0c12781f861f5e01b2782ffd0a777d1ebeabb47264e68f603
@@ -13,9 +13,9 @@ module ThunderChunk
13
13
  end
14
14
  end
15
15
 
16
- def initialize(chunk, key, publisher)
16
+ def initialize(chunk, key, publisher_loader)
17
17
  @chunk = chunk
18
- @publisher = publisher
18
+ @publisher_loader = publisher_loader
19
19
  @key = key
20
20
  end
21
21
 
@@ -24,8 +24,6 @@ module ThunderChunk
24
24
  end
25
25
 
26
26
  # WARN: AI MADE
27
- # A payload with a key the event does not declare, a declared key left out or a value of another type raises
28
- # Error, whatever operations.validate_returns says: the payload leaves for another chunk.
29
27
  def publish(params)
30
28
  Console.info(self, 'Event Published', key: @key, params:)
31
29
  begin
@@ -34,7 +32,7 @@ module ThunderChunk
34
32
  raise Error, "#{self.class.name}: #{e.message}"
35
33
  end
36
34
 
37
- @publisher.publish(@key, params)
35
+ @publisher_loader.call.publish(@key, params)
38
36
  end
39
37
  end
40
38
  end
@@ -24,10 +24,11 @@ module ThunderChunk
24
24
  def get(key)
25
25
  event_klass = @items[key] || raise(Error, 'this event is not registered')
26
26
 
27
+ # The publisher is built on the first publish: a command that only boots (thunder db setup) sets no resolver.
27
28
  event_klass.new(
28
29
  @chunk,
29
30
  key,
30
- self.class.publisher(@chunk)
31
+ -> { self.class.publisher(@chunk) }
31
32
  )
32
33
  end
33
34
 
@@ -15,10 +15,9 @@ module ThunderChunk
15
15
  chunk_identifier, key = path.split('/')
16
16
  dock = @chunk.sender_dock
17
17
  # WARN: AI MADE
18
- # The sender (and the remote's url in the config) is found on boot, so a missing url fails there; in specs
19
- # every call is stubbed (ThunderSpec), so it is found on the first call only.
18
+ dock.url_for(chunk_identifier, :operation) unless ENV['THUNDER_ENV'] == 'test'
20
19
  sender = -> { dock.sender_for(chunk_identifier, :operation) }
21
- sender.call unless ENV['THUNDER_ENV'] == 'test'
20
+ # WARN: ---
22
21
 
23
22
  ThunderChunk::Operations::Remote.new(sender:, key:)
24
23
  end
@@ -13,18 +13,21 @@ module ThunderChunk
13
13
 
14
14
  def sender_for(chunk_identifier, wire)
15
15
  get(chunk_identifier, wire) || begin
16
- remote = "remotes.chunk.#{chunk_identifier}.external_import.#{wire}"
17
- url = @chunk.config["#{remote}.url"]
18
-
19
- raise(Error, "Remote #{chunk_identifier} does not set a configured url") if url.blank?
20
-
21
- protocol = @chunk.config["#{remote}.protocol"] || :http
16
+ url = url_for(chunk_identifier, wire)
17
+ protocol = @chunk.config["remotes.chunk.#{chunk_identifier}.external_import.#{wire}.protocol"] || :http
22
18
  sender_class = load_class(wire, protocol)
23
19
 
24
20
  set(chunk_identifier, wire, sender_class.new(chunk_identifier, url))
25
21
  end
26
22
  end
27
23
 
24
+ def url_for(chunk_identifier, wire)
25
+ url = @chunk.config["remotes.chunk.#{chunk_identifier}.external_import.#{wire}.url"]
26
+ raise(Error, "Remote #{chunk_identifier} does not set a configured url") if url.blank?
27
+
28
+ url
29
+ end
30
+
28
31
  private
29
32
 
30
33
  def get(chunk_identifier, wire)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ThunderChunk
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thunderchunk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Alef
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - '='
59
59
  - !ruby/object:Gem::Version
60
- version: 0.2.0
60
+ version: 0.2.2
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - '='
66
66
  - !ruby/object:Gem::Version
67
- version: 0.2.0
67
+ version: 0.2.2
68
68
  executables: []
69
69
  extensions: []
70
70
  extra_rdoc_files: []