event_engine 0.2.1 → 0.2.3

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: 9f780a13e96d7a1fd1534d39aeda5cca32379d283e886839538f969d2cdcfa53
4
- data.tar.gz: 1dad812c37e3d4b44178d8d2a9b42b1623a94fef984c6e32d66f84a0b4a3d76a
3
+ metadata.gz: e487942b070a87cfa23e72a27d34e9247704caadfa887be26c1cd63eb3d4506d
4
+ data.tar.gz: 4f87ddcd5d44b28009ad2e45bc46296ab52d9f047037ec7023067238554f6a4e
5
5
  SHA512:
6
- metadata.gz: 685bad2445b1b6022625790855b51c4614be06e7cfafc81556d959a1a2d3254663a5a701bccfdc805c3260ec19919e939f22a5733d64481bdf894a60daeae896
7
- data.tar.gz: bd15af2c996f15d0422b624947c78fa2d2607e13a611b028ed6f03a3d5a470ee3d8963c15c038976c5bb2c164f3eebe41a90fe372d4c3c28b39abb0e4fa8d955
6
+ metadata.gz: 6f63838b3a3c2835e9c1511172413f6991cb0831afdf3b21247e5ef5ba03f0d40a92fb21ba1282ef6ce100a5081837821999de9b51f3cc920a2a5b30a94ec9fa
7
+ data.tar.gz: 688da6973e692d3b57b6d468191c37e9f701fa767888c030aec9318a0193685388ba6441b88be08d5fb54ff85ee6f8f019eee4a91791259ee4cce2af4a3baef2
data/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.3] - 2026-10-23
11
+
12
+ ### Added
13
+
14
+ - **Unrouted events.** A rule of `unrouted` defines an event before anything
15
+ handles it. It passes `validate_rules!`, and emitting it raises
16
+ `EventEngine::UnroutableEventError`.
17
+
18
+ ## [0.2.2] - 2026-09-06
19
+
20
+ ### Fixed
21
+
22
+ - Versioned lookup after boot. `EventSchemaJsonLoader.load` returned a
23
+ `SchemaRegistry` where `SchemaRegistry#load_from_schema!` stores an
24
+ `EventSchema`, so `emit(..., event_version: 2)` — documented in the README —
25
+ called `schema_for` on a registry and raised `NoMethodError`. The loader now
26
+ returns the `EventSchema` its callers assign.
27
+ - `SchemaRegistry#reset!` left `@event_schema` as a plain `Hash`, so registering
28
+ into a reset registry raised `NoMethodError`.
29
+
10
30
  ## [0.2.1] - 2026-07-29
11
31
 
12
32
  ### Fixed
data/README.md CHANGED
@@ -234,6 +234,7 @@ packs:
234
234
  events:
235
235
  invoice_voided: audit # this one event
236
236
  lead_converted: # catalogued but undecided
237
+ lead_scored: unrouted # defined, not routed yet
237
238
  ```
238
239
 
239
240
  A rule names a **registered processor**. Resolution is **event → pack → default**,
@@ -251,6 +252,13 @@ and the resolved name is both the processor invoked and the value stamped on
251
252
  A newly catalogued event appears with no value. It falls through to its pack rule or
252
253
  the default; if neither exists, emitting it raises rather than being dropped.
253
254
 
255
+ ### Defining an event before it is routed
256
+
257
+ Give an event the rule `unrouted` to define it before anything handles it. It
258
+ passes `validate_rules!` and `event_engine:rules:check`, and emitting it raises
259
+ `EventEngine::UnroutableEventError`. Replace `unrouted` with a processor name once
260
+ the event has one.
261
+
254
262
  ### When a rule is wrong
255
263
 
256
264
  Both misconfigurations fail loudly and name the fix:
@@ -3,17 +3,17 @@ require "json"
3
3
  module EventEngine
4
4
  class EventSchemaJsonLoader
5
5
  def self.load(path)
6
- registry = SchemaRegistry.new
7
- return registry unless File.exist?(path)
6
+ schema = EventSchema.new
7
+ return schema unless File.exist?(path)
8
8
 
9
9
  contents = File.read(path.to_s)
10
- return registry if contents.strip.empty?
10
+ return schema if contents.strip.empty?
11
11
 
12
12
  JSON.parse(contents).each do |attributes|
13
- registry.register(CatalogEntry.from_h(attributes))
13
+ schema.register(CatalogEntry.from_h(attributes))
14
14
  end
15
15
 
16
- registry
16
+ schema
17
17
  end
18
18
  end
19
19
  end
@@ -2,6 +2,8 @@ require "yaml"
2
2
 
3
3
  module EventEngine
4
4
  class ProcessingRules
5
+ UNROUTED = :unrouted
6
+
5
7
  def self.load(path)
6
8
  return new unless File.exist?(path.to_s)
7
9
 
@@ -33,7 +35,7 @@ module EventEngine
33
35
  end
34
36
 
35
37
  def processor_names
36
- ([ @default ] + @packs.values + @events.values).compact.uniq
38
+ ([ @default ] + @packs.values + @events.values).compact.uniq - [ UNROUTED ]
37
39
  end
38
40
  end
39
41
  end
@@ -9,8 +9,10 @@ module EventEngine
9
9
  end
10
10
 
11
11
  def resolve(event)
12
- @rules.for(event_name: event.event_name, pack: event.domain) ||
13
- raise(UnroutableEventError.new(event))
12
+ name = @rules.for(event_name: event.event_name, pack: event.domain)
13
+ raise UnroutableEventError.new(event) if name.nil? || name == ProcessingRules::UNROUTED
14
+
15
+ name
14
16
  end
15
17
  end
16
18
  end
@@ -30,7 +30,7 @@ module EventEngine
30
30
  end
31
31
 
32
32
  def reset!
33
- @event_schema = {}
33
+ @event_schema = EventSchema.new
34
34
  @loaded = false
35
35
  end
36
36
 
@@ -1,3 +1,3 @@
1
1
  module EventEngine
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/event_engine.rb CHANGED
@@ -174,7 +174,7 @@ module EventEngine
174
174
  slice = EventSchemaJsonLoader.load(schema_path)
175
175
 
176
176
  schema_registry.load_from_schema!(EventSchema.new) unless schema_registry.loaded?
177
- slice.event_schema.schemas_by_event.each_value do |versions|
177
+ slice.schemas_by_event.each_value do |versions|
178
178
  versions.each_value { |schema| schema_registry.register(schema) }
179
179
  end
180
180
 
@@ -145,6 +145,8 @@ off to that local first and come back.
145
145
  domain; pair narrow rules with a `default_processor`.
146
146
  - Routing at a name with no registered processor fails at emit time, not at boot.
147
147
  Keep steps 3 and 4 in the same initializer so they cannot drift.
148
+ - A rule of `unrouted` defines an event before anything handles it. It passes the
149
+ rules check, and emitting it raises `EventEngine::UnroutableEventError`.
148
150
  - A pack helper firing an event that is not in the committed catalog raises
149
151
  `EventEngine::DefinitionPublisher::EventNotInCatalogError`. That means the
150
152
  catalog is stale — rebuild it in step 2, do not work around it in app code.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-09-06 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -102,7 +101,6 @@ metadata:
102
101
  changelog_uri: https://github.com/DYB-Development/event_engine/blob/main/CHANGELOG.md
103
102
  bug_tracker_uri: https://github.com/DYB-Development/event_engine/issues
104
103
  documentation_uri: https://github.com/DYB-Development/event_engine#readme
105
- post_install_message:
106
104
  rdoc_options: []
107
105
  require_paths:
108
106
  - lib
@@ -117,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  - !ruby/object:Gem::Version
118
116
  version: '0'
119
117
  requirements: []
120
- rubygems_version: 3.5.16
121
- signing_key:
118
+ rubygems_version: 4.0.20
122
119
  specification_version: 4
123
120
  summary: The Rails host runtime for the schema-first EventEngine pipeline
124
121
  test_files: []