polyn-cli 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bb022568ffd67e3a51e01a83d62efa3ce4e5ddc270281c5a16fc5002c977745
4
- data.tar.gz: c4972decc3bd62952027102d57fe849bea7cca44d0ed2df740f86a5ee10adaa4
3
+ metadata.gz: ddc537a719c0f6247ba0b2b160cf1571d475384e8f00a96cccd8c03ae61d80ae
4
+ data.tar.gz: 91f7c4694751bf1778f477135c9819f42dfe437ceb63f2ffa7b66f43d5b1c358
5
5
  SHA512:
6
- metadata.gz: 4357838f71c9c9327f6a85031fe5ac93b3e44415a435a439000528f7bd87552e700edc07b1912dba739f69b5c704561eb63882b08b63825df197dfd34fdc08e0
7
- data.tar.gz: 27f2b3fc58725688bff695a0167bfd80c547404ca01f78b3a6846408c1e9cc0ef129bf2d68c328aaff5570cefd38a385be19fff97e3a7baeb0742b68813c2c87
6
+ metadata.gz: 5aeaef41c88a5e415579242acad2e23b986f8bbb3a22d1068ba089e3886d82abd5709217ed11165e17dbf44f1f4203f085c4923d7aa180e1f5c64031df7a8dc6
7
+ data.tar.gz: 04f1dd0f81e107ec17f07aff19d30981e1ffd0edbef32d1fd0ae573040f823e03d5fdefc7eb534276d5bf010e449d6d62c3144cc1c5b900939b6fa084c4efbd4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyn-cli (0.1.9)
4
+ polyn-cli (0.2.0)
5
5
  dotenv (~> 2.7.6)
6
6
  json_schemer (~> 0.2)
7
7
  nats-pure (~> 2.0.0)
data/README.md CHANGED
@@ -10,9 +10,9 @@ gem install 'polyn-cli'
10
10
 
11
11
  ## Usage
12
12
 
13
- ### Create New Events Codebase
13
+ ### Create New Schemas Codebase
14
14
 
15
- Run `polyn init` inside a directory to create a new `events` respository for managing your event schemas and NATS server configuration
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 <event_type>` to generate a new JSON Schema for an event
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> <event_type>` to generate new configuration for a consumer of a stream. It will be included in the same file as the stream configuration.
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 events from"
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 event"
15
- argument :event_type, required: true, desc: "The type of event being consumed"
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.validate_event_type!(event_type)
23
+ Polyn::Cli::Naming.validate_message_name!(message_name)
24
24
  end
25
25
 
26
26
  def check_stream_existance
27
- unless File.exist?(file_path)
28
- raise Polyn::Cli::Error,
29
- "You must first create a stream configuration with "\
30
- "`polyn gen:stream #{format_stream_name}`"
31
- end
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 check_event_type_schema
35
- unless File.exist?(File.join(options.dir, "events", "#{event_type}.json"))
36
- raise Polyn::Cli::Error,
37
- "You must first create a schema with `polyn gen:schema #{event_type}`"
38
- end
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
- type = Polyn::Cli::Naming.dot_to_underscore(event_type)
49
- "#{dest}_#{type}"
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 = "#{event_type}"
68
+ filter_subject = "#{message_name}"
69
69
  sample_freq = 100
70
70
  }
71
71
  TF
@@ -10,10 +10,10 @@ module Polyn
10
10
  end
11
11
 
12
12
  def self.validate_stream_name!(name)
13
- unless name.match(/^[a-zA-Z0-9_]+$/)
14
- raise Polyn::Cli::Error,
15
- "Stream name must be all alphanumeric, uppercase, and underscore separated. Got #{name}"
16
- end
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
- unless name.is_a?(String) && name.match?(/\A[a-z0-9]+(?:(?:\.|:)[a-z0-9]+)*\z/)
25
- raise Polyn::Cli::Error,
26
- "Event destination must be lowercase, alphanumeric and dot/colon separated, got #{name}"
27
- end
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.validate_event_type!(name)
31
- unless name.is_a?(String) && name.match?(/\A[a-z0-9]+(?:\.[a-z0-9]+)*\z/)
32
- raise Polyn::Cli::Error,
33
- "Event types must be lowercase, alphanumeric and dot separated"
34
- end
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 an event
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 an event"
10
+ desc "Generates a new JSON Schema file for a message"
11
11
 
12
- argument :event_type, required: true
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 type
18
- @type ||= event_type.split("/").last
17
+ def name
18
+ @name ||= message_name.split("/").last
19
19
  end
20
20
 
21
21
  def subdir
22
22
  @subdir ||= begin
23
- split = event_type.split("/") - [type]
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.validate_event_type!(type)
29
+ Polyn::Cli::Naming.validate_message_name!(name)
30
30
  end
31
31
 
32
32
  def file_name
33
- @file_name ||= File.join(subdir, "#{type}.json")
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(type)
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, "events/#{file_name}")
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 schmea into the event registry.
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 events from the event repository into the Polyn event registry.
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).load_events
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
- @events_dir = opts.fetch(:events_dir, File.join(Dir.pwd, "events"))
26
- @events = {}
27
- @existing_events = {}
25
+ @schemas_dir = opts.fetch(:schemas_dir, File.join(Dir.pwd, "schemas"))
26
+ @schemas = {}
27
+ @existing_schemas = {}
28
28
  end
29
29
 
30
- def load_events
31
- thor.say "Loading events into the Polyn event registry from '#{events_dir}'"
32
- read_events
33
- load_existing_events
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
- events.each do |name, event|
36
- bucket.put(name, JSON.generate(event))
35
+ schemas.each do |name, schema|
36
+ bucket.put(name, JSON.generate(schema))
37
37
  end
38
38
 
39
- delete_missing_events
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
- :events,
47
+ :schemas,
48
48
  :client,
49
49
  :bucket,
50
50
  :cloud_event_schema,
51
- :events_dir,
51
+ :schemas_dir,
52
52
  :store_name,
53
- :existing_events
53
+ :existing_schemas
54
54
 
55
55
  def connect
56
56
  opts = {
@@ -66,68 +66,68 @@ module Polyn
66
66
  NATS.connect(opts).jetstream
67
67
  end
68
68
 
69
- def read_events
70
- event_files = Dir.glob(File.join(events_dir, "/**/*.json"))
71
- validate_unique_event_types!(event_files)
69
+ def read_schemas
70
+ schema_files = Dir.glob(File.join(schemas_dir, "/**/*.json"))
71
+ validate_unique_schema_names!(schema_files)
72
72
 
73
- event_files.each do |event_file|
74
- thor.say "Loading 'event #{event_file}'"
75
- data_schema = JSON.parse(File.read(event_file))
76
- event_type = File.basename(event_file, ".json")
77
- validate_schema!(event_type, data_schema)
78
- Polyn::Cli::Naming.validate_event_type!(event_type)
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
- events[event_type] = schema
81
+ schemas[schema_name] = schema
82
82
  end
83
83
  end
84
84
 
85
- def validate_unique_event_types!(event_files)
86
- duplicates = find_duplicates(event_files)
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, (event_type, files)|
90
- memo << [event_type, *files].join("\n")
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 event type. The following events were duplicated:",
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(event_files)
100
- event_types = event_files.group_by do |event_file|
101
- File.basename(event_file, ".json")
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
- event_types.each_with_object({}) do |(event_type, files), hash|
104
- hash[event_type] = files if files.length > 1
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!(event_type, 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 #{event_type}\n#{e.message}\n"\
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(event_schema)
117
+ def compose_cloud_event(data_schema)
118
118
  cloud_event_schema.merge({
119
119
  "definitions" => cloud_event_schema["definitions"].merge({
120
- "datadef" => event_schema,
120
+ "datadef" => data_schema,
121
121
  }),
122
122
  })
123
123
  end
124
124
 
125
- def load_existing_events
125
+ def load_existing_schemas
126
126
  sub = client.subscribe("#{key_prefix}.>")
127
127
 
128
128
  loop do
129
- msg = sub.next_msg
130
- existing_events[msg.subject.gsub("#{key_prefix}.", "")] = msg.data unless msg.data.empty?
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 delete_missing_events
144
- missing_events = existing_events.keys - events.keys
145
- missing_events.each do |event|
146
- thor.say "Deleting event #{event}"
147
- bucket.delete(event)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Polyn
4
4
  class Cli
5
- VERSION = "0.1.9"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
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 event repository"
51
+ desc "init", "initializes a Polyn schema repository"
52
52
  def init
53
- say "Initializing Polyn event repository"
53
+ say "Initializing Polyn schema repository"
54
54
  directory "tf", File.join(options.dir, "tf")
55
- directory "events", File.join(options.dir, "events")
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 event registry"
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 event registry"
114
- Polyn::Cli::SchemaLoader.new(self).load_events
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 EVENT_TYPE",
162
- "Generates a new JSON Schema file for an event")
163
- register(Polyn::Cli::StreamGenerator, "gen:stream", "gen:stream NAME",
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 EVENT_TYPE",
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
@@ -5,8 +5,8 @@ RUN gem install bundler
5
5
  RUN bundle install
6
6
 
7
7
  FROM base as app
8
- WORKDIR /events
9
- ADD events ./events
8
+ WORKDIR /schemas
9
+ ADD schemas ./schemas
10
10
  ADD tf ./tf
11
11
 
12
12
  FROM app as dev
@@ -1,6 +1,6 @@
1
- # Polyn Events Repository
1
+ # Polyn Schemas Repository
2
2
 
3
- This repository contains all of the events and terraform resources for the Polyn services
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 Event Registry.
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
- ## Event Schemas
32
+ ## Message Schemas
33
33
 
34
- Run `bundle exec polyn gen:schema <event_type>` to generate a new JSON Schema for an event
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 events should live in the `./events` directory.
37
- The name of your schema file should be the same as your event, but with `.json` at the end.
38
- So if you have an event called `widgets.created.v1` you would create a schema file called `widgets.created.v1.json` in the `./events` directory.
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 event schema with the [Cloud Events Schema](https://cloudevents.io/) when it adds it to the Polyn Event Registry.
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 events by team ownership or some other convention, you can use subdirectories to do so. The full event type should still be part of the file name. You should also ensure there are not duplicate event types in different directories as only one schema can be defined per event type.
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 Event
51
+ ### New Message
52
52
 
53
- A new event schema file should be a lower-case, dot-separated, name with a `v1` suffix
53
+ A new message schema file should be a lower-case, dot-separated, name with a `v1` suffix
54
54
 
55
- ### Existing Event
55
+ ### Existing Message
56
56
 
57
- Existing event 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 event will not break or be invalid when 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 an event schema that is not backwards-compatible will require you to create a brand new
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 events, streams, or consumers.
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
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$id": "<%= schema_id %>",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
- "description": "This is why this event exists and what it does",
4
+ "description": "This is why this message exists and what it does",
5
5
  "type": "object",
6
6
  "properties": {
7
7
 
@@ -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
+ }
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.9
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-11-22 00:00:00.000000000 Z
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