polyn-cli 0.1.7 → 0.1.8

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: 1a6369f7bbcf1c0f9aab5bb11725d0fedd259eaa08365d3415a61791a83c4afa
4
- data.tar.gz: 171a1f5a3bec71a1e5a113233c462ce98b9323cce7c7fec0ef68e9de40debcaf
3
+ metadata.gz: fc201c551bb6f0b5e55c32ff47557164de1a2020cd11e1997c2e2acc8f61025d
4
+ data.tar.gz: 50e911060818ec5b06db12ad09f683212b1b02fdb3241cafde48e8eccde2d4ad
5
5
  SHA512:
6
- metadata.gz: 5e561f347e9e2b66f1c674a9e8310bc0ab8f963679249e76dae3fc7bbe0dfbf91bffe71999435cf013f819b4589ec81eda97bb85b4c0a9400f95ffe06b1990ce
7
- data.tar.gz: f70e69705a333700d85c561e81ad4db92ee54daf7764df5c2649b6d927c7cc52bc6008803f2f4eba1a7c9ce826ae234d191c5f7c34b2324b547003f29d1c9773
6
+ metadata.gz: cc1541bbaa72a2126c6d42a0c40352e0baf347a2cf6855213d70361b77154516cf998365ed0ddf5734292427a8411ec7fc3085b44856db3f13d8716e9278da58
7
+ data.tar.gz: c46bf95e3fe9afa651fccab77d8bd9e9cf4671a02a9c5a05952ce6c3bc0ab8854a38839aeb71a1fda6c5c121875d43a759037d781a4f8d58367bfd84fea96359
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyn-cli (0.1.7)
4
+ polyn-cli (0.1.8)
5
5
  dotenv (~> 2.7.6)
6
6
  json_schemer (~> 0.2)
7
7
  nats-pure (~> 2.0.0)
data/README.md CHANGED
@@ -35,6 +35,7 @@ Run `polyn up` to update your NATS server with the latest configuration in your
35
35
  * `NATS_SERVERS` - locations of your servers (defaults to localhost)
36
36
  * `NATS_CREDENTIALS` - path to nats credentials file
37
37
  * `NATS_CA_FILE` - Fully Qualified Path to a file containing Root CA (PEM format). Use when the server has certs signed by an unknown authority.
38
+ * `NATS_TLS` - Boolean, defaults to `false`. Should NATS connect with TLS?
38
39
  * `POLYN_ENV` - type of environment (defaults to "development")
39
40
 
40
41
  ## Development
@@ -5,13 +5,14 @@ module Polyn
5
5
  ##
6
6
  # Configuration data for Polyn::Cli
7
7
  class Configuration
8
- attr_reader :polyn_env, :nats_servers, :nats_credentials, :nats_ca_file
8
+ attr_reader :polyn_env, :nats_servers, :nats_credentials, :nats_ca_file, :nats_tls
9
9
 
10
10
  def initialize
11
11
  @polyn_env = ENV["POLYN_ENV"] || "development"
12
- @nats_servers = ENV["NATS_SERVERS"] || "localhost:4222"
12
+ @nats_servers = ENV["NATS_SERVERS"] || "nats://127.0.0.1:4222"
13
13
  @nats_credentials = ENV["NATS_CREDENTIALS"] || ""
14
14
  @nats_ca_file = ENV["NATS_CA_FILE"] || ""
15
+ @nats_tls = ENV["NATS_TLS"] || false
15
16
  end
16
17
  end
17
18
  end
@@ -18,7 +18,7 @@ module Polyn
18
18
 
19
19
  def initialize(thor, **opts)
20
20
  @thor = thor
21
- @client = NATS.connect(Polyn::Cli.configuration.nats_servers).jetstream
21
+ @client = connect
22
22
  @store_name = opts.fetch(:store_name, STORE_NAME)
23
23
  @bucket = client.key_value(@store_name)
24
24
  @cloud_event_schema = Polyn::Cli::CloudEvent.to_h.freeze
@@ -52,6 +52,20 @@ module Polyn
52
52
  :store_name,
53
53
  :existing_events
54
54
 
55
+ def connect
56
+ opts = {
57
+ max_reconnect_attempts: 5,
58
+ reconnect_time_wait: 0.5,
59
+ servers: Polyn::Cli.configuration.nats_servers.split(","),
60
+ }
61
+
62
+ if Polyn::Cli.configuration.nats_tls
63
+ opts.tls = { context: ::OpenSSL::SSL::SSLContext.new(:TLSv1_2) }
64
+ end
65
+
66
+ NATS.connect(opts).jetstream
67
+ end
68
+
55
69
  def read_events
56
70
  event_files = Dir.glob(File.join(events_dir, "/**/*.json"))
57
71
  validate_unique_event_types!(event_files)
@@ -70,16 +84,16 @@ module Polyn
70
84
 
71
85
  def validate_unique_event_types!(event_files)
72
86
  duplicates = find_duplicates(event_files)
73
- unless duplicates.empty?
74
- messages = duplicates.reduce([]) do |memo, (event_type, files)|
75
- memo << [event_type, *files].join("\n")
76
- end
77
- message = [
78
- "There can only be one of each event type. The following events were duplicated:",
79
- *messages,
80
- ].join("\n")
81
- raise Polyn::Cli::ValidationError, message
87
+ return if duplicates.empty?
88
+
89
+ messages = duplicates.reduce([]) do |memo, (event_type, files)|
90
+ memo << [event_type, *files].join("\n")
82
91
  end
92
+ message = [
93
+ "There can only be one of each event type. The following events were duplicated:",
94
+ *messages,
95
+ ].join("\n")
96
+ raise Polyn::Cli::ValidationError, message
83
97
  end
84
98
 
85
99
  def find_duplicates(event_files)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Polyn
4
4
  class Cli
5
- VERSION = "0.1.7"
5
+ VERSION = "0.1.8"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyn-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarod
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-11-09 00:00:00.000000000 Z
12
+ date: 2022-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dotenv