polyn-cli 0.1.8 → 0.2.0
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 +4 -4
- data/lib/polyn/cli/consumer_generator.rb +17 -17
- data/lib/polyn/cli/naming.rb +13 -13
- data/lib/polyn/cli/schema_generator.rb +10 -10
- data/lib/polyn/cli/schema_loader.rb +49 -49
- data/lib/polyn/cli/version.rb +1 -1
- data/lib/polyn/cli.rb +10 -10
- data/lib/polyn/templates/Dockerfile +2 -2
- data/lib/polyn/templates/README.md +17 -22
- data/lib/polyn/templates/generators/schema.json +1 -1
- data/lib/polyn/templates/schemas/money.amount.v1.json +15 -0
- data/lib/polyn/templates/{events → schemas}/widgets.created.v1.json +0 -0
- metadata +4 -4
- data/lib/polyn/templates/events/.gitkeep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddc537a719c0f6247ba0b2b160cf1571d475384e8f00a96cccd8c03ae61d80ae
|
4
|
+
data.tar.gz: 91f7c4694751bf1778f477135c9819f42dfe437ceb63f2ffa7b66f43d5b1c358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aeaef41c88a5e415579242acad2e23b986f8bbb3a22d1068ba089e3886d82abd5709217ed11165e17dbf44f1f4203f085c4923d7aa180e1f5c64031df7a8dc6
|
7
|
+
data.tar.gz: 04f1dd0f81e107ec17f07aff19d30981e1ffd0edbef32d1fd0ae573040f823e03d5fdefc7eb534276d5bf010e449d6d62c3144cc1c5b900939b6fa084c4efbd4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -10,9 +10,9 @@ gem install 'polyn-cli'
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
### Create New
|
13
|
+
### Create New Schemas Codebase
|
14
14
|
|
15
|
-
Run `polyn init` inside a directory to create a new `
|
15
|
+
Run `polyn init` inside a directory to create a new `schemas` respository for managing your message schemas and NATS server configuration
|
16
16
|
|
17
17
|
### Stream Generator
|
18
18
|
|
@@ -20,11 +20,11 @@ Run `polyn gen:stream <stream_name>` to generate a new configuration file for a
|
|
20
20
|
|
21
21
|
### Schema Generator
|
22
22
|
|
23
|
-
Run `polyn gen:schema <
|
23
|
+
Run `polyn gen:schema <schema_name>` to generate a new JSON Schema for a message
|
24
24
|
|
25
25
|
### Consumer Generator
|
26
26
|
|
27
|
-
Run `polyn gen:consumer <stream_name> <destination_name> <
|
27
|
+
Run `polyn gen:consumer <stream_name> <destination_name> <schema_name>` to generate new configuration for a consumer of a stream. It will be included in the same file as the stream configuration.
|
28
28
|
|
29
29
|
### Updating NATS Configuration and Schemas
|
30
30
|
|
@@ -9,10 +9,10 @@ module Polyn
|
|
9
9
|
|
10
10
|
desc "Generates a new NATS Consumer configuration for a stream"
|
11
11
|
|
12
|
-
argument :stream_name, required: true, desc: "The name of the stream to consume
|
12
|
+
argument :stream_name, required: true, desc: "The name of the stream to consume messages from"
|
13
13
|
argument :destination_name, required: true,
|
14
|
-
desc: "The name of the application, service, or component consuming the
|
15
|
-
argument :
|
14
|
+
desc: "The name of the application, service, or component consuming the message"
|
15
|
+
argument :message_name, required: true, desc: "The name of the message being consumed"
|
16
16
|
class_option :dir, default: Dir.getwd
|
17
17
|
|
18
18
|
source_root File.join(File.expand_path(__dir__), "../templates")
|
@@ -20,22 +20,22 @@ module Polyn
|
|
20
20
|
def check_names
|
21
21
|
Polyn::Cli::Naming.validate_stream_name!(stream_name)
|
22
22
|
Polyn::Cli::Naming.validate_destination_name!(destination_name)
|
23
|
-
Polyn::Cli::Naming.
|
23
|
+
Polyn::Cli::Naming.validate_message_name!(message_name)
|
24
24
|
end
|
25
25
|
|
26
26
|
def check_stream_existance
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
return if File.exist?(file_path)
|
28
|
+
|
29
|
+
raise Polyn::Cli::Error,
|
30
|
+
"You must first create a stream configuration with "\
|
31
|
+
"`polyn gen:stream #{format_stream_name}`"
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
def check_schema
|
35
|
+
return if File.exist?(File.join(options.dir, "schemas", "#{message_name}.json"))
|
36
|
+
|
37
|
+
raise Polyn::Cli::Error,
|
38
|
+
"You must first create a schema with `polyn gen:schema #{message_name}`"
|
39
39
|
end
|
40
40
|
|
41
41
|
def format_stream_name
|
@@ -45,8 +45,8 @@ module Polyn
|
|
45
45
|
def consumer_name
|
46
46
|
dest = Polyn::Cli::Naming.colon_to_underscore(destination_name)
|
47
47
|
dest = Polyn::Cli::Naming.dot_to_underscore(dest)
|
48
|
-
|
49
|
-
"#{dest}_#{
|
48
|
+
name = Polyn::Cli::Naming.dot_to_underscore(message_name)
|
49
|
+
"#{dest}_#{name}"
|
50
50
|
end
|
51
51
|
|
52
52
|
def file_name
|
@@ -65,7 +65,7 @@ module Polyn
|
|
65
65
|
stream_id = jetstream_stream.#{stream_name}.id
|
66
66
|
durable_name = "#{consumer_name}"
|
67
67
|
deliver_all = true
|
68
|
-
filter_subject = "#{
|
68
|
+
filter_subject = "#{message_name}"
|
69
69
|
sample_freq = 100
|
70
70
|
}
|
71
71
|
TF
|
data/lib/polyn/cli/naming.rb
CHANGED
@@ -10,10 +10,10 @@ module Polyn
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.validate_stream_name!(name)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
return if name.match(/^[a-zA-Z0-9_]+$/)
|
14
|
+
|
15
|
+
raise Polyn::Cli::Error,
|
16
|
+
"Stream name must be all alphanumeric, uppercase, and underscore separated. Got #{name}"
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.format_stream_name(name)
|
@@ -21,17 +21,17 @@ module Polyn
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.validate_destination_name!(name)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
return if name.is_a?(String) && name.match?(/\A[a-z0-9]+(?:(?:\.|:)[a-z0-9]+)*\z/)
|
25
|
+
|
26
|
+
raise Polyn::Cli::Error,
|
27
|
+
"Message destination must be lowercase, alphanumeric and dot/colon separated, got #{name}"
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
def self.validate_message_name!(name)
|
31
|
+
return if name.is_a?(String) && name.match?(/\A[a-z0-9]+(?:\.[a-z0-9]+)*\z/)
|
32
|
+
|
33
|
+
raise Polyn::Cli::Error,
|
34
|
+
"Message names must be lowercase, alphanumeric and dot separated"
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.dot_to_underscore(name)
|
@@ -3,43 +3,43 @@
|
|
3
3
|
module Polyn
|
4
4
|
class Cli
|
5
5
|
##
|
6
|
-
# Generates a new JSON Schema file for
|
6
|
+
# Generates a new JSON Schema file for a message
|
7
7
|
class SchemaGenerator < Thor::Group
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
|
-
desc "Generates a new JSON Schema file for
|
10
|
+
desc "Generates a new JSON Schema file for a message"
|
11
11
|
|
12
|
-
argument :
|
12
|
+
argument :message_name, required: true
|
13
13
|
class_option :dir, default: Dir.getwd
|
14
14
|
|
15
15
|
source_root File.join(File.expand_path(__dir__), "../templates")
|
16
16
|
|
17
|
-
def
|
18
|
-
@
|
17
|
+
def name
|
18
|
+
@name ||= message_name.split("/").last
|
19
19
|
end
|
20
20
|
|
21
21
|
def subdir
|
22
22
|
@subdir ||= begin
|
23
|
-
split =
|
23
|
+
split = message_name.split("/") - [name]
|
24
24
|
split.join("/")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def check_name
|
29
|
-
Polyn::Cli::Naming.
|
29
|
+
Polyn::Cli::Naming.validate_message_name!(name)
|
30
30
|
end
|
31
31
|
|
32
32
|
def file_name
|
33
|
-
@file_name ||= File.join(subdir, "#{
|
33
|
+
@file_name ||= File.join(subdir, "#{name}.json")
|
34
34
|
end
|
35
35
|
|
36
36
|
def schema_id
|
37
|
-
Polyn::Cli::Naming.dot_to_colon(
|
37
|
+
Polyn::Cli::Naming.dot_to_colon(name)
|
38
38
|
end
|
39
39
|
|
40
40
|
def create
|
41
41
|
say "Creating new schema for #{file_name}"
|
42
|
-
template "generators/schema.json", File.join(options.dir, "
|
42
|
+
template "generators/schema.json", File.join(options.dir, "schemas/#{file_name}")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -3,17 +3,17 @@
|
|
3
3
|
module Polyn
|
4
4
|
class Cli
|
5
5
|
##
|
6
|
-
# Loads the JSON
|
6
|
+
# Loads the JSON schema into the schema registry.
|
7
7
|
class SchemaLoader
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
10
|
STORE_NAME = "POLYN_SCHEMAS"
|
11
11
|
|
12
12
|
##
|
13
|
-
# Loads the
|
13
|
+
# Loads the schemas from the schema repository into the Polyn schema registry.
|
14
14
|
# @return [Bool]
|
15
15
|
def self.load(cli)
|
16
|
-
new(cli).
|
16
|
+
new(cli).load_schemas
|
17
17
|
end
|
18
18
|
|
19
19
|
def initialize(thor, **opts)
|
@@ -22,21 +22,21 @@ module Polyn
|
|
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
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
25
|
+
@schemas_dir = opts.fetch(:schemas_dir, File.join(Dir.pwd, "schemas"))
|
26
|
+
@schemas = {}
|
27
|
+
@existing_schemas = {}
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
thor.say "Loading
|
32
|
-
|
33
|
-
|
30
|
+
def load_schemas
|
31
|
+
thor.say "Loading schemas into the Polyn schema registry from '#{schemas_dir}'"
|
32
|
+
read_schemas
|
33
|
+
load_existing_schemas
|
34
34
|
|
35
|
-
|
36
|
-
bucket.put(name, JSON.generate(
|
35
|
+
schemas.each do |name, schema|
|
36
|
+
bucket.put(name, JSON.generate(schema))
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
delete_missing_schemas
|
40
40
|
|
41
41
|
true
|
42
42
|
end
|
@@ -44,13 +44,13 @@ module Polyn
|
|
44
44
|
private
|
45
45
|
|
46
46
|
attr_reader :thor,
|
47
|
-
:
|
47
|
+
:schemas,
|
48
48
|
:client,
|
49
49
|
:bucket,
|
50
50
|
:cloud_event_schema,
|
51
|
-
:
|
51
|
+
:schemas_dir,
|
52
52
|
:store_name,
|
53
|
-
:
|
53
|
+
:existing_schemas
|
54
54
|
|
55
55
|
def connect
|
56
56
|
opts = {
|
@@ -60,74 +60,74 @@ module Polyn
|
|
60
60
|
}
|
61
61
|
|
62
62
|
if Polyn::Cli.configuration.nats_tls
|
63
|
-
opts
|
63
|
+
opts[:tls] = { context: ::OpenSSL::SSL::SSLContext.new(:TLSv1_2) }
|
64
64
|
end
|
65
65
|
|
66
66
|
NATS.connect(opts).jetstream
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
69
|
+
def read_schemas
|
70
|
+
schema_files = Dir.glob(File.join(schemas_dir, "/**/*.json"))
|
71
|
+
validate_unique_schema_names!(schema_files)
|
72
72
|
|
73
|
-
|
74
|
-
thor.say "Loading '
|
75
|
-
data_schema = JSON.parse(File.read(
|
76
|
-
|
77
|
-
validate_schema!(
|
78
|
-
Polyn::Cli::Naming.
|
73
|
+
schema_files.each do |schema_file|
|
74
|
+
thor.say "Loading 'schema #{schema_file}'"
|
75
|
+
data_schema = JSON.parse(File.read(schema_file))
|
76
|
+
schema_name = File.basename(schema_file, ".json")
|
77
|
+
validate_schema!(schema_name, data_schema)
|
78
|
+
Polyn::Cli::Naming.validate_message_name!(schema_name)
|
79
79
|
schema = compose_cloud_event(data_schema)
|
80
80
|
|
81
|
-
|
81
|
+
schemas[schema_name] = schema
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
86
|
-
duplicates = find_duplicates(
|
85
|
+
def validate_unique_schema_names!(schema_files)
|
86
|
+
duplicates = find_duplicates(schema_files)
|
87
87
|
return if duplicates.empty?
|
88
88
|
|
89
|
-
messages = duplicates.reduce([]) do |memo, (
|
90
|
-
memo << [
|
89
|
+
messages = duplicates.reduce([]) do |memo, (schema_name, files)|
|
90
|
+
memo << [schema_name, *files].join("\n")
|
91
91
|
end
|
92
92
|
message = [
|
93
|
-
"There can only be one of each
|
93
|
+
"There can only be one of each schema name. The following schemas were duplicated:",
|
94
94
|
*messages,
|
95
95
|
].join("\n")
|
96
96
|
raise Polyn::Cli::ValidationError, message
|
97
97
|
end
|
98
98
|
|
99
|
-
def find_duplicates(
|
100
|
-
|
101
|
-
File.basename(
|
99
|
+
def find_duplicates(schema_files)
|
100
|
+
schema_names = schema_files.group_by do |schema_file|
|
101
|
+
File.basename(schema_file, ".json")
|
102
102
|
end
|
103
|
-
|
104
|
-
hash[
|
103
|
+
schema_names.each_with_object({}) do |(schema_name, files), hash|
|
104
|
+
hash[schema_name] = files if files.length > 1
|
105
105
|
hash
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
def validate_schema!(
|
109
|
+
def validate_schema!(schema_name, schema)
|
110
110
|
JSONSchemer.schema(schema)
|
111
111
|
rescue StandardError => e
|
112
112
|
raise Polyn::Cli::ValidationError,
|
113
|
-
"Invalid JSON Schema document for event #{
|
113
|
+
"Invalid JSON Schema document for event #{schema_name}\n#{e.message}\n"\
|
114
114
|
"#{JSON.pretty_generate(schema)}"
|
115
115
|
end
|
116
116
|
|
117
|
-
def compose_cloud_event(
|
117
|
+
def compose_cloud_event(data_schema)
|
118
118
|
cloud_event_schema.merge({
|
119
119
|
"definitions" => cloud_event_schema["definitions"].merge({
|
120
|
-
"datadef" =>
|
120
|
+
"datadef" => data_schema,
|
121
121
|
}),
|
122
122
|
})
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
125
|
+
def load_existing_schemas
|
126
126
|
sub = client.subscribe("#{key_prefix}.>")
|
127
127
|
|
128
128
|
loop do
|
129
|
-
msg
|
130
|
-
|
129
|
+
msg = sub.next_msg
|
130
|
+
existing_schemas[msg.subject.gsub("#{key_prefix}.", "")] = msg.data unless msg.data.empty?
|
131
131
|
# A timeout is the only mechanism given to indicate there are no
|
132
132
|
# more messages
|
133
133
|
rescue NATS::IO::Timeout
|
@@ -140,11 +140,11 @@ module Polyn
|
|
140
140
|
"$KV.#{store_name}"
|
141
141
|
end
|
142
142
|
|
143
|
-
def
|
144
|
-
|
145
|
-
|
146
|
-
thor.say "Deleting
|
147
|
-
bucket.delete(
|
143
|
+
def delete_missing_schemas
|
144
|
+
missing_schemas = existing_schemas.keys - schemas.keys
|
145
|
+
missing_schemas.each do |schema|
|
146
|
+
thor.say "Deleting schema #{schema}"
|
147
|
+
bucket.delete(schema)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
data/lib/polyn/cli/version.rb
CHANGED
data/lib/polyn/cli.rb
CHANGED
@@ -48,11 +48,11 @@ module Polyn
|
|
48
48
|
end
|
49
49
|
|
50
50
|
method_option :dir, default: Dir.getwd
|
51
|
-
desc "init", "initializes a Polyn
|
51
|
+
desc "init", "initializes a Polyn schema repository"
|
52
52
|
def init
|
53
|
-
say "Initializing Polyn
|
53
|
+
say "Initializing Polyn schema repository"
|
54
54
|
directory "tf", File.join(options.dir, "tf")
|
55
|
-
directory "
|
55
|
+
directory "schemas", File.join(options.dir, "schemas")
|
56
56
|
template "docker-compose.yml", File.join(options.dir, "docker-compose.yml")
|
57
57
|
template "Dockerfile", File.join(options.dir, "Dockerfile")
|
58
58
|
template ".dockerignore", File.join(options.dir, ".dockerignore")
|
@@ -91,7 +91,7 @@ module Polyn
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
desc "up", "updates the JetStream streams and consumers, as well the Polyn
|
94
|
+
desc "up", "updates the JetStream streams and consumers, as well the Polyn schema registry"
|
95
95
|
def up
|
96
96
|
terraform_root = File.join(Dir.getwd, "tf")
|
97
97
|
# We only want to run nats in the docker container if
|
@@ -110,8 +110,8 @@ module Polyn
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
say "Updating Polyn
|
114
|
-
Polyn::Cli::SchemaLoader.new(self).
|
113
|
+
say "Updating Polyn schema registry"
|
114
|
+
Polyn::Cli::SchemaLoader.new(self).load_schemas
|
115
115
|
end
|
116
116
|
|
117
117
|
private
|
@@ -158,12 +158,12 @@ module Polyn
|
|
158
158
|
remove_file File.join(tf_root, "backend.tf")
|
159
159
|
end
|
160
160
|
|
161
|
-
register(Polyn::Cli::SchemaGenerator, "gen:schema", "gen:schema
|
162
|
-
"Generates a new JSON Schema file for an
|
163
|
-
register(Polyn::Cli::StreamGenerator, "gen:stream", "gen:stream
|
161
|
+
register(Polyn::Cli::SchemaGenerator, "gen:schema", "gen:schema SCHEMA_NAME",
|
162
|
+
"Generates a new JSON Schema file for an schema")
|
163
|
+
register(Polyn::Cli::StreamGenerator, "gen:stream", "gen:stream SCHEMA_NAME",
|
164
164
|
"Generates a new stream configuration with boilerplate")
|
165
165
|
register(Polyn::Cli::ConsumerGenerator, "gen:consumer",
|
166
|
-
"gen:consumer STREAM_NAME DESTINATION_NAME
|
166
|
+
"gen:consumer STREAM_NAME DESTINATION_NAME SCHEMA_NAME",
|
167
167
|
"Generates a new NATS Consumer configuration with boilerplate")
|
168
168
|
end
|
169
169
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# Polyn
|
1
|
+
# Polyn Schemas Repository
|
2
2
|
|
3
|
-
This repository contains all of the
|
3
|
+
This repository contains all of the schemas and terraform resources for the Polyn services
|
4
4
|
environment.
|
5
5
|
|
6
6
|
1. Install [Ruby](https://github.com/asdf-vm/asdf-ruby)
|
@@ -11,7 +11,7 @@ environment.
|
|
11
11
|
5. Ensure Docker & Docker Compose is installed
|
12
12
|
6. Call `bundle exec polyn tf_init` if this is the first time using terraform in the codebase.
|
13
13
|
7. Call `bundle exec polyn up`. By default this will run in `development` mode, which will start the NATS
|
14
|
-
server, configure it via Terraform, and update the Polyn
|
14
|
+
server, configure it via Terraform, and update the Polyn Schema Registry.
|
15
15
|
|
16
16
|
### Running NATS locally
|
17
17
|
|
@@ -29,40 +29,35 @@ Each stream should have its own configuration file under `./tf`. Run `bundle exe
|
|
29
29
|
|
30
30
|
Run `bundle exec polyn gen:consumer <stream_name> <destination_name> <event_type>` to generate new configuration for a consumer of a stream. It will be included in the same file as the stream configuration.
|
31
31
|
|
32
|
-
##
|
32
|
+
## Message Schemas
|
33
33
|
|
34
|
-
Run `bundle exec polyn gen:schema <
|
34
|
+
Run `bundle exec polyn gen:schema <schema_name>` to generate a new JSON Schema for a message
|
35
35
|
|
36
|
-
All the schemas for your
|
37
|
-
The name of your schema file should be the same as your
|
38
|
-
So if you have an
|
36
|
+
All the schemas for your messages should live in the `./schemas` directory.
|
37
|
+
The name of your schema file should be the same as your message, but with `.json` at the end.
|
38
|
+
So if you have an message called `widgets.created.v1` you would create a schema file called `widgets.created.v1.json` in the `./schemas` directory.
|
39
39
|
Every schema should be a valid [JSON Schema](https://json-schema.org/) document.
|
40
|
-
The Polyn CLI tool will combine your
|
40
|
+
The Polyn CLI tool will combine your message schema with the [Cloud Events Schema](https://cloudevents.io/) when it adds it to the Polyn Schema Registry.
|
41
41
|
This means you only need to include the JSON Schema for the `data` portion of the Cloud Event and not the entire Cloud Event schema.
|
42
42
|
|
43
43
|
### Subdirectories
|
44
44
|
|
45
|
-
If you'd like to organize your
|
45
|
+
If you'd like to organize your messages by team ownership or some other convention, you can use subdirectories to do so. The full message name should still be part of the file name. You should also ensure there are not duplicate schema names in different directories as only one schema can be defined per message name.
|
46
46
|
|
47
47
|
You can generate a schema in a subdirectory like this: `bundle exec polyn gen:schema some/nested/dir/widgets.created.v1`
|
48
48
|
|
49
49
|
## Schema Versioning
|
50
50
|
|
51
|
-
### New
|
51
|
+
### New Message
|
52
52
|
|
53
|
-
A new
|
53
|
+
A new message schema file should be a lower-case, dot-separated, name with a `v1` suffix
|
54
54
|
|
55
|
-
### Existing
|
55
|
+
### Existing Message
|
56
56
|
|
57
|
-
Existing
|
58
|
-
Backwards-compatibile meaning that any services Producing or Consuming the
|
59
|
-
Polyn Event Registry is updated with the change. There are many ways to make breaking change and so you should be
|
60
|
-
careful when you do this.
|
57
|
+
Existing message schemas can be changed without updating the file name if the change is backwards-compatible.
|
58
|
+
Backwards-compatibile meaning that any services Producing or Consuming the message will not break or be invalid when the Polyn Schema Registry is updated with the change. There are many ways to make breaking change and so you should be careful when you do this.
|
61
59
|
|
62
|
-
Making a change to
|
63
|
-
json file. The new file should have the same name as your old file, but with the version number increased. Your
|
64
|
-
Producers will need to continue producing both events until you are sure there are no more consumers using the
|
65
|
-
old event.
|
60
|
+
Making a change to a message schema that is not backwards-compatible will require you to create a brand new json file. The new file should have the same name as your old file, but with the version number increased. Your Producers will need to continue producing both message versions until you are sure there are no more consumers using the old message.
|
66
61
|
|
67
62
|
## Terraform State
|
68
63
|
|
@@ -74,7 +69,7 @@ For local development Polyn expects the `terraform.tfstate` file to exist in the
|
|
74
69
|
|
75
70
|
### Production
|
76
71
|
|
77
|
-
In production Terraform recommends keeping `terraform.tfstate` in a [remote storage location](https://www.terraform.io/language/state). The remote state file should be the "source of truth" for your infrastucture and shouldn't be getting accessed during development. Depending on the size of your organization and security policies, not all developers will have access to the remote storage source and you don't want that to prohibit them from adding
|
72
|
+
In production Terraform recommends keeping `terraform.tfstate` in a [remote storage location](https://www.terraform.io/language/state). The remote state file should be the "source of truth" for your infrastucture and shouldn't be getting accessed during development. Depending on the size of your organization and security policies, not all developers will have access to the remote storage source and you don't want that to prohibit them from adding schemas, streams, or consumers.
|
78
73
|
|
79
74
|
Polyn expects you to keep a `./remote_state_config/backend.tf` file that configures a Terraform [backend](https://www.terraform.io/language/settings/backends/configuration). This will only be used when `POLYN_ENV=production`.
|
80
75
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"$id": "money:amount:v1",
|
3
|
+
"type": "object",
|
4
|
+
"properties": {
|
5
|
+
"currency": {
|
6
|
+
"type": "string",
|
7
|
+
"description": "currency code for the amount"
|
8
|
+
},
|
9
|
+
"amount": {
|
10
|
+
"type": "number",
|
11
|
+
"description": "amount of money"
|
12
|
+
}
|
13
|
+
},
|
14
|
+
"required": ["currency", "amount"]
|
15
|
+
}
|
File without changes
|
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.
|
4
|
+
version: 0.2.0
|
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-
|
12
|
+
date: 2022-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dotenv
|
@@ -106,10 +106,10 @@ files:
|
|
106
106
|
- lib/polyn/templates/Gemfile
|
107
107
|
- lib/polyn/templates/README.md
|
108
108
|
- lib/polyn/templates/docker-compose.yml
|
109
|
-
- lib/polyn/templates/events/.gitkeep
|
110
|
-
- lib/polyn/templates/events/widgets.created.v1.json
|
111
109
|
- lib/polyn/templates/generators/schema.json
|
112
110
|
- lib/polyn/templates/generators/stream.tf
|
111
|
+
- lib/polyn/templates/schemas/money.amount.v1.json
|
112
|
+
- lib/polyn/templates/schemas/widgets.created.v1.json
|
113
113
|
- lib/polyn/templates/tf/kv_buckets.tf
|
114
114
|
- lib/polyn/templates/tf/provider.tf
|
115
115
|
- lib/polyn/templates/tf/remote_state_config/backend.tf
|
File without changes
|