polyn 0.3.1 → 0.4.0

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: aef622abe4519af5e7b87f1fcd0416183829c8e4a974143d0043a5152c0a46bc
4
- data.tar.gz: 52ed88386aff72d31461492875f9af2239ac4105dd2c2d11f7a3867c9867ec54
3
+ metadata.gz: af29ed5d49542d04eec8fb57a9945c7b2a5f16cbf0bc7244616396fd0d7a9da3
4
+ data.tar.gz: 84d78cd6661b9ce188cf9f2c413a8b011ded1a962a7fea89a32c87ff460cc73d
5
5
  SHA512:
6
- metadata.gz: a51ddc4365ec85ad861498477f6ba17eb10b5dede8f06f58dea297a930f0adcaee150b9cc30c11c8ea26071db54804d1f664827a31e8f3faa085421e59c5dff1
7
- data.tar.gz: 5e2add1f818b85ea73317fd73861f25d1ace5a91a18706863d19bfa6a4d156692ca4771232dba61a8fe8b170f00a8dfa34ffa5bfb39daab018301b94ed92855e
6
+ metadata.gz: f86cd8dd54ee4655e90626ae060127cd0407820ca373f76e1130ae1f9ce7030274eddc0cd0daaae2b4a71d7496a80d31ad7f513e91ecb6d57297ac2692ecfdb2
7
+ data.tar.gz: 6fc44174ea147fd7d243cfd9cf8391c34a8984b25746a67f2b65e167408c130266be5c3b086504d1e5750c638d99b4d17eb1db7de61f8c85f7fb671686ae4542
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polyn (0.3.1)
4
+ polyn (0.4.0)
5
5
  json_schemer (~> 0.2)
6
6
  nats-pure (~> 2.0)
7
7
  opentelemetry-api (~> 1.1)
data/README.md CHANGED
@@ -34,7 +34,7 @@ And then execute:
34
34
 
35
35
  ## Schema Creation
36
36
 
37
- In order for Polyn to process and validate event schemas you will need to use [Polyn CLI](https://github.com/SpiffInc/polyn-cli) to create an `events` codebase. Once your `events` codebase is created you can create and manage your schemas there.
37
+ In order for Polyn to process and validate event schemas you will need to use [Polyn CLI](https://github.com/SpiffInc/polyn-cli) to create an `schemas` codebase. Once your `schemas` codebase is created you can create and manage your schemas there.
38
38
 
39
39
  ## Configuration
40
40
 
@@ -99,7 +99,7 @@ loop do
99
99
  end
100
100
  ```
101
101
 
102
- Polyn assumes you've already used [Polyn CLI](https://github.com/SpiffInc/polyn-cli) to generate a consumer.
102
+ Polyn assumes you've already used [Polyn CLI](https://github.com/SpiffInc/polyn/tree/main/polyn_cli) to generate a consumer.
103
103
 
104
104
  Add the `:source` option to `pull_subscribe` if your consumer name includes more than just the `source_root`. Polyn automatically finds the consumer name from the `type` you pass in.
105
105
  If your `source_root` was `user.backend` and the event type was `user.created.v1` it would look for a consumer named `user_backend_user_created_v1`. If your consumer had a more specific destination such as `notifications` you could pass that as the `:source` option and the consumer name lookup would use `user_backend_notifications_user_created_v1`.
data/lib/polyn/event.rb CHANGED
@@ -118,7 +118,7 @@ module Polyn
118
118
  ##
119
119
  # Get the Event `type` prefixed with reverse domain name
120
120
  def self.full_type(type)
121
- Polyn::Naming.validate_event_type!(type)
121
+ Polyn::Naming.validate_message_name!(type)
122
122
  "#{domain}.#{Polyn::Naming.trim_domain_prefix(type)}"
123
123
  end
124
124
 
data/lib/polyn/naming.rb CHANGED
@@ -35,11 +35,9 @@ module Polyn
35
35
  # Validate the `source` name and raise if invalid
36
36
  def self.validate_source_name!(name)
37
37
  message = validate_source_name(name)
38
- if message == true
39
- name
40
- else
41
- raise Polyn::Errors::ValidationError, message
42
- end
38
+ raise Polyn::Errors::ValidationError, message unless message == true
39
+
40
+ name
43
41
  end
44
42
 
45
43
  ##
@@ -56,7 +54,7 @@ module Polyn
56
54
 
57
55
  ##
58
56
  # Validate the event type
59
- def self.validate_event_type!(name)
57
+ def self.validate_message_name!(name)
60
58
  if name.is_a?(String) && name.match?(/\A[a-z0-9]+(?:\.[a-z0-9]+)*\z/)
61
59
  name
62
60
  else
@@ -75,7 +73,7 @@ module Polyn
75
73
  ##
76
74
  # Create a consumer name from a source and type
77
75
  def self.consumer_name(type, source = nil)
78
- validate_event_type!(type)
76
+ validate_message_name!(type)
79
77
  type = trim_domain_prefix(type)
80
78
  type = type.gsub(".", "_")
81
79
 
@@ -90,7 +90,7 @@ module Polyn
90
90
  schema = get_schema(type)
91
91
  return schema if schema.is_a?(Polyn::Errors::Error)
92
92
 
93
- validate_schema(schema, event)
93
+ validate_schema(schema, event["data"])
94
94
  end
95
95
 
96
96
  def validate_schema(schema, event)
data/lib/polyn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polyn
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.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-28 00:00:00.000000000 Z
12
+ date: 2022-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_schemer