polyn-cli 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/polyn/cli/configuration.rb +3 -2
- data/lib/polyn/cli/schema_loader.rb +24 -10
- data/lib/polyn/cli/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: 9bb022568ffd67e3a51e01a83d62efa3ce4e5ddc270281c5a16fc5002c977745
|
4
|
+
data.tar.gz: c4972decc3bd62952027102d57fe849bea7cca44d0ed2df740f86a5ee10adaa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4357838f71c9c9327f6a85031fe5ac93b3e44415a435a439000528f7bd87552e700edc07b1912dba739f69b5c704561eb63882b08b63825df197dfd34fdc08e0
|
7
|
+
data.tar.gz: 27f2b3fc58725688bff695a0167bfd80c547404ca01f78b3a6846408c1e9cc0ef129bf2d68c328aaff5570cefd38a385be19fff97e3a7baeb0742b68813c2c87
|
data/Gemfile.lock
CHANGED
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"] || "
|
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 =
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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)
|
data/lib/polyn/cli/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.9
|
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-
|
12
|
+
date: 2022-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dotenv
|