nulogy_message_bus_producer 3.4.1 → 4.0.0.alpha

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: b40c306c32ccf50c2bf5b8cf87edc9335b3339bef8aa35d667608fdc99ded0e3
4
- data.tar.gz: fd1f7a1e0b65e3246976d0ff8ae54c18c6ad2f9ec1bdd05c5d1546b5137906d5
3
+ metadata.gz: ef6259b620567209e608c461298813e61646f25f8c7aa5adc10e4fa967069ed6
4
+ data.tar.gz: 61a9f10a879d6b2b05d25c1b3ad177f23948dcf79dd9a89766df29cc8f1c3bf9
5
5
  SHA512:
6
- metadata.gz: df2553a5bf95a76e169265147ee6955dd29902b84d4d10d180ae6ac99c835e950c3c3afd82bbfa9ed1687788239a1fc785240a2c87c3f055dd90be73a8556c9b
7
- data.tar.gz: b6b96134a28963e8cacb83237703ce7adbf8ebd2e35af29bc63cf4b9f95b6a949646f6fa44899bd2129dce18b0448547034d84ffe5209665e0732f116a006c07
6
+ metadata.gz: d2b2a6558e97fe79eae7624d8bdaefc585b1a8747cd506cfde6d7757eea01d8f5b7153877efcdbbd424d5d4776a5c79cdfb3a61fdf3144e385a9c2010b7b88b0
7
+ data.tar.gz: 96f659ac685cef6807855baa4b3a4e633b0340f176fec2ac37dbf6c2cefbf20ec0f2d29a2b74196518cf6ee571bae5f56ffe08117cf86d72197125588ed14f8c
data/README.md CHANGED
@@ -8,13 +8,39 @@ This engine contains the classes and validations for producing messages to the M
8
8
 
9
9
  1. Add the gem to your Gemfile: `gem "nulogy_message_bus_producer"`
10
10
  2. Install the migrations: `rake railties:install:migrations`
11
+ 3. Use the [Nulogy GraphQL API](https://github.com/nulogy/nulogy_graphql_api)'s schema specs to [ensure schema changes are safe](https://github.com/nulogy/nulogy_graphql_api#schema-generation)
11
12
 
12
- ## Usage
13
+ ## Overview
13
14
 
14
- Subscriptions should inherit from `NulogyMessageBusProducer::BaseSubscription`.
15
+ The Producer gem supports two ways of producing messages:
16
+
17
+ ### Subscription
18
+
19
+ A subscription (either self-serve or configured) is triggered via a domain event.
20
+ The subscription `event_data` (TODO: column should also be renamed) will render the query against a public GraphQL Schema.
21
+
22
+ ### Publication
23
+
24
+ aka the pub half of `pubsub`.
25
+
26
+ A client publishes arbitrary `event_data` (serializable to JSON) to a `topic` under a `event_type`.
27
+
28
+ ### Comparison
29
+
30
+ | Attribute | Subscription | Publication |
31
+ |-----------------------|------------------------------------------------------|--------------------------|
32
+ | subscription_id | consumer supplied | random |
33
+ | subscription_group_id | consumer supplied | random |
34
+ | topic | consumer supplied | explicit (user supplied) |
35
+ | type | computed (domain event / GraphQL subscription field) | explicit (user supplied) |
36
+ | message ordering | per `company_uuid` per `subscription_group_id` | per `company_uuid` |
37
+
38
+ ## Usage
15
39
 
16
40
  ### Subscriptions
17
41
 
42
+ Subscriptions should inherit from `NulogyMessageBusProducer::BaseSubscription`.
43
+
18
44
  Subscriptions are created by consumers to subscribe to certain events that the producer exposes.
19
45
 
20
46
  When an event is fired/triggered, subscriptions are used to generate events into the
@@ -24,6 +50,31 @@ Debezium then reads this table from the PG replication log and pushes them into
24
50
 
25
51
  There are two ways to create subscriptions:
26
52
 
53
+ #### Configured
54
+
55
+ Subscriptions provided by configuration in the producer app:
56
+
57
+ ```ruby
58
+ NulogyMessageBusProducer.configure do |c|
59
+ c.register_schema(schema: "ExampleDomain::Schema", key: "exampleDomain")
60
+
61
+ c.add_subscription!(
62
+ schema: "ExampleDomain::Schema",
63
+ query: <<~QUERY
64
+ subscription {
65
+ domainEvent(subscriptionId: "uuid", subscriptionGroupId: "uuid2", topicName: "consumer-inbox") {
66
+ domainObject {
67
+ field
68
+ }
69
+ }
70
+ }
71
+ QUERY
72
+ )
73
+ end
74
+ ```
75
+
76
+ These subscriptions are stored in the producer and require a deploy to update.
77
+
27
78
  #### Self-Serve (deprecated)
28
79
 
29
80
  You create these subscriptions via the public GraphQL API. e.g.
@@ -45,29 +96,70 @@ This style of subscriptions may be removed in a future release.
45
96
 
46
97
  There is a [guide to migrate from Self-Serve to Configured](docs/self_serve_to_configured_subscriptions.md)
47
98
 
48
- #### Configured (new)
99
+ ### Publications
49
100
 
50
- Subscriptions provided by configuration in the producer app:
101
+ The Message Bus has a unified `SubscriptionEvent` (TODO: rename) data structure that will create a Kafka message.
102
+ Thus, the publication-style of producing messages must provide any required fields to produce a valid `SubscriptionEvent`.
51
103
 
52
104
  ```ruby
53
- NulogyMessageBusProducer.configure do |c|
54
- c.register_schema(schema: "ExampleDomain::Schema", key: "exampleDomain")
105
+ # publish
106
+ # NulogyMessageBusProducer.publish(topic:, type:, company_uuid:, data:)
107
+
108
+ NulogyMessageBusProducer.publish(
109
+ topic: "some-target-inbox",
110
+ type: "some-event-type",
111
+ company_uuid: company.uuid,
112
+ data: {message: "some data", value: "3", ...}
113
+ )
114
+ ```
55
115
 
56
- c.add_subscription!(
57
- schema: "ExampleDomain::Schema",
58
- query: <<~QUERY
59
- subscription {
60
- domainEvent(subscriptionId: "uuid", subscriptionGroupId: "uuid2", topicName: "consumer-inbox") {
61
- domainObject {
62
- field
63
- }
64
- }
65
- }
66
- QUERY
67
- )
116
+ Note that we do not support publishing to multiple topics at the moment.
117
+
118
+ A producer may want to wrap these methods:
119
+
120
+ ```ruby
121
+ class MetricsPublisher
122
+ def initialize(company, type: "some-kind-of-metric", topic: "metrics-stream")
123
+ @company_uuid = company.uuid
124
+ @topic = topic
125
+ @type = type
126
+ end
127
+
128
+ def publish(data)
129
+ NulogyMessageBusProducer.publish(
130
+ topic: @topic,
131
+ type: @type,
132
+ company_uuid: @company_uuid,
133
+ data: {message:"something", value: 3}
134
+ )
135
+ end
68
136
  end
137
+
138
+ MetricsPublisher.new(Current.company).publish(metric_data)
69
139
  ```
70
140
 
141
+ #### Self-Serve (soft-deprecated)
142
+
143
+ You create these subscriptions via the public GraphQL API. For testing, the [Insomnia](https://insomnia.rest/) client
144
+ is highly recommended.
145
+
146
+ ```graphql
147
+ subscription {
148
+ workOrderUpdated(subscriptionId: "uuid", subscriptionGroupId: "uuid", topicName: "some-topic") {
149
+ workOrder {
150
+ id
151
+ code
152
+ }
153
+ }
154
+ }
155
+ ```
156
+
157
+ These subscriptions are written to the `NulogyMessageBusProducer.subscriptions_table_name` table.
158
+
159
+ This style of subscriptions may be removed in a future release.
160
+
161
+ There is a [guide to migrate from Self-Serve to Configured](docs/self_serve_to_configured_subscriptions.md)
162
+
71
163
  ## Configuration
72
164
 
73
165
  | Configuration | Default | Description |
@@ -261,19 +353,20 @@ rails message_bus_producer:repopulate_replication_slots
261
353
 
262
354
  ## Rake Tasks
263
355
 
264
- | Rake command | Description |
265
- |--------------|-----------------|
266
- | (default) | RSpec + RuboCop |
267
- | `spec` | RSpec |
268
- | `rubocop` | RuboCop |
356
+ | Rake command | Description |
357
+ |------------------|------------------|
358
+ | (default) | RSpec + Standard |
359
+ | `spec` | RSpec |
360
+ | `standardrb` | Standard |
361
+ | `standardrb:fix` | Fix to Standard |
269
362
 
270
363
  # Gem Development Setup
271
364
 
272
365
  If you are doing work on this gem you will want to:
273
366
  ```shell script
274
367
  docker-compose up
275
- rake db:setup
276
- rake
368
+ bundle exec rake db:setup
369
+ bundle exec rake
277
370
  ```
278
371
 
279
372
  # Gem Releases
@@ -285,4 +378,4 @@ You must be listed as a gem owner [on rubygems](https://rubygems.org/gems/nulogy
285
378
  * Update `lib/nulogy_message_bus_producer/version.rb`
286
379
  * Run `bundle install`
287
380
  * Update the CHANGELOG
288
- * Run `rake release`
381
+ * Run `bundle exec rake release`
@@ -0,0 +1,9 @@
1
+ class AddEventTypeToSubscriptionEvents < ActiveRecord::Migration[5.2]
2
+ def up
3
+ add_column :message_bus_subscription_events, :event_type, :text
4
+ end
5
+
6
+ def down
7
+ remove_column :message_bus_subscription_events, :event_type
8
+ end
9
+ end
@@ -34,6 +34,23 @@ module NulogyMessageBusProducer
34
34
  config.context_for_subscription(subscription)
35
35
  end
36
36
 
37
+ def self.register_publication
38
+ raise "not implemented yet"
39
+ end
40
+
41
+ def self.publish(topic:, type:, company_uuid:, data:)
42
+ SubscriptionEvent.create_or_update(
43
+ id: SecureRandom.uuid,
44
+ subscription_id: SecureRandom.uuid,
45
+ partition_key: company_uuid,
46
+
47
+ company_uuid: company_uuid,
48
+ event_type: type,
49
+ event_json: data,
50
+ topic_name: topic
51
+ )
52
+ end
53
+
37
54
  def self.trigger_event(schema, event_type, root_object)
38
55
  schema_key = NulogyMessageBusProducer.resolve_schema_key(schema)
39
56
  subscriptions = Subscriptions::Finder.new(config).for_schema_event(schema_key, event_type)
@@ -1,9 +1,12 @@
1
1
  module NulogyMessageBusProducer
2
2
  # A model that contains the event data for a particular subscription
3
3
  # It is simply saved in the database and shipped to Kafka by Debezium
4
+ # TODO: rename this --- can be from a subscription or publication
5
+ # Message? -- kinda conflicts with a "kafka message" but that is on the consumer side.
4
6
  class SubscriptionEvent < ApplicationRecord
5
7
  self.table_name = :message_bus_subscription_events
6
8
 
9
+ # TODO: this should be renamed. You can't update an Event.
7
10
  def self.create_or_update(attrs)
8
11
  find_or_initialize_by(id: attrs[:id]).tap do |model|
9
12
  model.update!(attrs)
@@ -1,3 +1,3 @@
1
1
  module NulogyMessageBusProducer
2
- VERSION = "3.4.1".freeze
2
+ VERSION = "4.0.0.alpha".freeze
3
3
  end
@@ -10,7 +10,8 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2020_10_05_164116) do
13
+ ActiveRecord::Schema.define(version: 2021_03_30_204121) do
14
+
14
15
  # These are extensions that must be enabled in order to support this database
15
16
  enable_extension "plpgsql"
16
17
  enable_extension "uuid-ossp"
@@ -22,6 +23,7 @@ ActiveRecord::Schema.define(version: 2020_10_05_164116) do
22
23
  t.uuid "company_uuid", null: false
23
24
  t.json "event_json", null: false
24
25
  t.datetime "created_at"
26
+ t.text "event_type"
25
27
  t.index ["created_at"], name: "index_nulogy_mb_producer_subscription_events_on_created_at"
26
28
  end
27
29
 
@@ -35,4 +37,5 @@ ActiveRecord::Schema.define(version: 2020_10_05_164116) do
35
37
  t.datetime "updated_at", null: false
36
38
  t.index ["event_type"], name: "index_nulogy_mb_producer_subscriptions_on_event_type"
37
39
  end
40
+
38
41
  end
@@ -2331,3 +2331,223 @@ Migrating to CreateActiveStorageTables (20201005164116)
2331
2331
  ActiveRecord::InternalMetadata Update (1.2ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2021-03-09 17:25:53.533488"], ["key", "environment"]]
2332
2332
   (1.6ms) COMMIT
2333
2333
   (1.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2334
+  (1.4ms) SELECT pg_try_advisory_lock(3053653019973222135)
2335
+  (5.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2336
+ Migrating to AddEventTypeToSubscriptionEvents (20210330204121)
2337
+  (2.0ms) BEGIN
2338
+  (8.7ms) ALTER TABLE "message_bus_subscriptions" ADD "event_type" text
2339
+  (2.0ms) ROLLBACK
2340
+  (2.1ms) SELECT pg_advisory_unlock(3053653019973222135)
2341
+  (1.9ms) CREATE DATABASE "nulogy_message_bus_producer_development" ENCODING = 'utf8'
2342
+  (1.8ms) CREATE DATABASE "nulogy_message_bus_producer_test" ENCODING = 'utf8'
2343
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2344
+  (3.0ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2345
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2346
+  (1.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2347
+  (1.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2348
+  (1.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2349
+ SQL (3.8ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2350
+ SQL (1.6ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
2351
+  (8.9ms) DROP TABLE IF EXISTS "message_bus_subscription_events" CASCADE
2352
+  (21.9ms) CREATE TABLE "message_bus_subscription_events" ("id" uuid NOT NULL PRIMARY KEY, "subscription_id" uuid NOT NULL, "partition_key" character varying NOT NULL, "topic_name" character varying NOT NULL, "company_uuid" uuid NOT NULL, "event_json" json NOT NULL, "created_at" timestamp)
2353
+  (4.3ms) CREATE INDEX "index_nulogy_mb_producer_subscription_events_on_created_at" ON "message_bus_subscription_events" ("created_at")
2354
+  (3.0ms) DROP TABLE IF EXISTS "message_bus_subscriptions" CASCADE
2355
+  (6.1ms) CREATE TABLE "message_bus_subscriptions" ("id" uuid NOT NULL PRIMARY KEY, "subscription_group_id" uuid NOT NULL, "event_type" character varying NOT NULL, "topic_name" character varying NOT NULL, "query" character varying NOT NULL, "schema_key" text NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
2356
+  (3.6ms) CREATE INDEX "index_nulogy_mb_producer_subscriptions_on_event_type" ON "message_bus_subscriptions" ("event_type")
2357
+  (2.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2358
+ ActiveRecord::InternalMetadata Load (1.5ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2359
+  (1.5ms) BEGIN
2360
+  (1.6ms) COMMIT
2361
+ ActiveRecord::InternalMetadata Load (1.5ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2362
+  (1.7ms) BEGIN
2363
+  (1.4ms) COMMIT
2364
+ SQL (4.3ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2365
+ SQL (2.1ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
2366
+  (16.8ms) DROP TABLE IF EXISTS "message_bus_subscription_events" CASCADE
2367
+  (22.6ms) CREATE TABLE "message_bus_subscription_events" ("id" uuid NOT NULL PRIMARY KEY, "subscription_id" uuid NOT NULL, "partition_key" character varying NOT NULL, "topic_name" character varying NOT NULL, "company_uuid" uuid NOT NULL, "event_json" json NOT NULL, "created_at" timestamp)
2368
+  (4.5ms) CREATE INDEX "index_nulogy_mb_producer_subscription_events_on_created_at" ON "message_bus_subscription_events" ("created_at")
2369
+  (4.2ms) DROP TABLE IF EXISTS "message_bus_subscriptions" CASCADE
2370
+  (8.6ms) CREATE TABLE "message_bus_subscriptions" ("id" uuid NOT NULL PRIMARY KEY, "subscription_group_id" uuid NOT NULL, "event_type" character varying NOT NULL, "topic_name" character varying NOT NULL, "query" character varying NOT NULL, "schema_key" text NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
2371
+  (4.1ms) CREATE INDEX "index_nulogy_mb_producer_subscriptions_on_event_type" ON "message_bus_subscriptions" ("event_type")
2372
+  (3.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2373
+  (5.9ms) INSERT INTO "schema_migrations" (version) VALUES (20201005164116)
2374
+  (3.0ms) INSERT INTO "schema_migrations" (version) VALUES
2375
+ (20200611150212),
2376
+ (20201005150212);
2377
+
2378
+ 
2379
+ ActiveRecord::InternalMetadata Load (3.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2380
+  (2.0ms) BEGIN
2381
+ ActiveRecord::InternalMetadata Create (3.6ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2021-03-30 20:52:23.588828"], ["updated_at", "2021-03-30 20:52:23.588828"]]
2382
+  (3.0ms) COMMIT
2383
+ ActiveRecord::InternalMetadata Load (2.0ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2384
+  (1.5ms) BEGIN
2385
+ ActiveRecord::InternalMetadata Update (1.8ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2021-03-30 20:52:23.604948"], ["key", "environment"]]
2386
+  (2.3ms) COMMIT
2387
+  (2.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2388
+  (1.1ms) SELECT pg_try_advisory_lock(3053653019973222135)
2389
+  (2.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2390
+ Migrating to AddEventTypeToSubscriptionEvents (20210330204121)
2391
+  (1.5ms) BEGIN
2392
+  (2.8ms) ALTER TABLE "message_bus_subscriptions" ADD "event_type" text
2393
+  (1.6ms) ROLLBACK
2394
+  (1.6ms) SELECT pg_advisory_unlock(3053653019973222135)
2395
+  (1.5ms) SELECT pg_try_advisory_lock(3053653019973222135)
2396
+  (2.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2397
+ Migrating to AddEventTypeToSubscriptionEvents (20210330204121)
2398
+  (1.6ms) BEGIN
2399
+  (3.1ms) ALTER TABLE "message_bus_subscriptions" ADD "event_type" text
2400
+  (1.6ms) ROLLBACK
2401
+  (2.4ms) SELECT pg_advisory_unlock(3053653019973222135)
2402
+  (2.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2403
+  (1.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2404
+  (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2405
+  (1.2ms) SELECT pg_try_advisory_lock(3053653019973222135)
2406
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2407
+ Migrating to CreateActiveStorageTables (20201005164116)
2408
+  (1.2ms) BEGIN
2409
+ ActiveRecord::SchemaMigration Destroy (2.7ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = $1 [["version", "20201005164116"]]
2410
+  (5.3ms) COMMIT
2411
+  (1.4ms) SELECT pg_advisory_unlock(3053653019973222135)
2412
+  (1.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2413
+  (1.1ms) SELECT pg_try_advisory_lock(3053653019973222135)
2414
+  (2.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2415
+ Migrating to CreateActiveStorageTables (20201005164116)
2416
+  (1.5ms) BEGIN
2417
+ ActiveRecord::SchemaMigration Create (1.7ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20201005164116"]]
2418
+  (2.7ms) COMMIT
2419
+ Migrating to AddEventTypeToSubscriptionEvents (20210330204121)
2420
+  (1.7ms) BEGIN
2421
+  (3.3ms) ALTER TABLE "message_bus_subscriptions" ADD "event_type" text
2422
+  (1.5ms) ROLLBACK
2423
+  (1.5ms) SELECT pg_advisory_unlock(3053653019973222135)
2424
+  (2.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2425
+  (1.7ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2426
+  (1.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2427
+  (1.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2428
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2429
+  (1.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2430
+  (24.4ms) DROP DATABASE IF EXISTS "nulogy_message_bus_producer_development"
2431
+  (1.8ms) DROP DATABASE IF EXISTS "nulogy_message_bus_producer_test"
2432
+  (248.6ms) CREATE DATABASE "nulogy_message_bus_producer_development" ENCODING = 'utf8'
2433
+  (1.9ms) CREATE DATABASE "nulogy_message_bus_producer_test" ENCODING = 'utf8'
2434
+  (16.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
2435
+  (10.8ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
2436
+  (1.3ms) SELECT pg_try_advisory_lock(3053653019973222135)
2437
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2438
+ Migrating to CreatePublicSubscriptionsAndEventsTables (20200611150212)
2439
+  (1.5ms) BEGIN
2440
+ SQL (7.7ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
2441
+  (6.6ms) CREATE TABLE "message_bus_subscriptions" ("id" uuid NOT NULL PRIMARY KEY, "subscription_group_id" uuid NOT NULL, "event_type" character varying NOT NULL, "topic_name" character varying NOT NULL, "query" character varying NOT NULL, "schema_key" text NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
2442
+  (3.3ms) CREATE INDEX "index_nulogy_mb_producer_subscriptions_on_event_type" ON "message_bus_subscriptions" ("event_type")
2443
+  (5.9ms) CREATE TABLE "message_bus_subscription_events" ("id" uuid NOT NULL PRIMARY KEY, "public_subscription_id" uuid NOT NULL, "partition_key" character varying NOT NULL, "topic_name" character varying NOT NULL, "tenant_id" uuid NOT NULL, "event_json" json NOT NULL, "created_at" timestamp)
2444
+  (3.2ms) CREATE INDEX "index_nulogy_mb_producer_subscription_events_on_created_at" ON "message_bus_subscription_events" ("created_at")
2445
+ ActiveRecord::SchemaMigration Create (2.0ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20200611150212"]]
2446
+  (2.9ms) COMMIT
2447
+ Migrating to RenameTenantIdAndPublic (20201005150212)
2448
+  (1.2ms) BEGIN
2449
+  (2.3ms) ALTER TABLE "message_bus_subscription_events" RENAME COLUMN "tenant_id" TO "company_uuid"
2450
+  (1.5ms) ALTER TABLE "message_bus_subscription_events" RENAME COLUMN "public_subscription_id" TO "subscription_id"
2451
+ ActiveRecord::SchemaMigration Create (1.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20201005150212"]]
2452
+  (1.8ms) COMMIT
2453
+ Migrating to CreateActiveStorageTables (20201005164116)
2454
+  (1.4ms) BEGIN
2455
+ ActiveRecord::SchemaMigration Create (1.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20201005164116"]]
2456
+  (1.8ms) COMMIT
2457
+ Migrating to AddEventTypeToSubscriptionEvents (20210330204121)
2458
+  (1.9ms) BEGIN
2459
+  (2.2ms) ALTER TABLE "message_bus_subscriptions" ADD "event_type" text
2460
+  (1.3ms) ROLLBACK
2461
+  (1.6ms) SELECT pg_advisory_unlock(3053653019973222135)
2462
+  (1.4ms) SELECT pg_try_advisory_lock(3053653019973222135)
2463
+  (2.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2464
+ Migrating to AddEventTypeToSubscriptionEvents (20210330204121)
2465
+  (1.7ms) BEGIN
2466
+  (2.3ms) ALTER TABLE "message_bus_subscription_events" ADD "event_type" text
2467
+ ActiveRecord::SchemaMigration Create (2.1ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20210330204121"]]
2468
+  (2.3ms) COMMIT
2469
+ ActiveRecord::InternalMetadata Load (2.0ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2470
+  (1.5ms) BEGIN
2471
+ ActiveRecord::InternalMetadata Create (2.8ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2021-03-31 14:32:42.969683"], ["updated_at", "2021-03-31 14:32:42.969683"]]
2472
+  (1.8ms) COMMIT
2473
+  (1.2ms) SELECT pg_advisory_unlock(3053653019973222135)
2474
+  (1.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2475
+  (4.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2476
+  (4.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2477
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2478
+  (1.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2479
+  (1.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2480
+  (1.1ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2481
+  (3.0ms) DROP DATABASE IF EXISTS "nulogy_message_bus_producer_test"
2482
+  (2.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2483
+  (1.8ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2484
+  (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2485
+  (1.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2486
+  (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2487
+  (1.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2488
+  (1.9ms) DROP DATABASE IF EXISTS "nulogy_message_bus_producer_test"
2489
+  (5.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2490
+  (4.5ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2491
+  (1.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2492
+  (1.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2493
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2494
+  (1.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2495
+  (3.0ms) DROP DATABASE IF EXISTS "nulogy_message_bus_producer_test"
2496
+  (4.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2497
+  (2.8ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2498
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2499
+  (1.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2500
+  (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2501
+  (2.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
2502
+  (23.2ms) DROP DATABASE IF EXISTS "nulogy_message_bus_producer_test"
2503
+  (223.2ms) CREATE DATABASE "nulogy_message_bus_producer_test" ENCODING = 'utf8'
2504
+ SQL (1.4ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
2505
+ SQL (7.9ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
2506
+  (1.6ms) DROP TABLE IF EXISTS "message_bus_subscription_events" CASCADE
2507
+  (8.8ms) CREATE TABLE "message_bus_subscription_events" ("id" uuid NOT NULL PRIMARY KEY, "subscription_id" uuid NOT NULL, "partition_key" character varying NOT NULL, "topic_name" character varying NOT NULL, "company_uuid" uuid NOT NULL, "event_json" json NOT NULL, "created_at" timestamp, "event_type" text)
2508
+  (3.8ms) CREATE INDEX "index_nulogy_mb_producer_subscription_events_on_created_at" ON "message_bus_subscription_events" ("created_at")
2509
+  (1.4ms) DROP TABLE IF EXISTS "message_bus_subscriptions" CASCADE
2510
+  (5.9ms) CREATE TABLE "message_bus_subscriptions" ("id" uuid NOT NULL PRIMARY KEY, "subscription_group_id" uuid NOT NULL, "event_type" character varying NOT NULL, "topic_name" character varying NOT NULL, "query" character varying NOT NULL, "schema_key" text NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
2511
+  (3.8ms) CREATE INDEX "index_nulogy_mb_producer_subscriptions_on_event_type" ON "message_bus_subscriptions" ("event_type")
2512
+  (6.2ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
2513
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
2514
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES (20210330204121)
2515
+  (2.2ms) INSERT INTO "schema_migrations" (version) VALUES
2516
+ (20201005164116),
2517
+ (20200611150212),
2518
+ (20201005150212);
2519
+
2520
+ 
2521
+  (6.0ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
2522
+ ActiveRecord::InternalMetadata Load (2.0ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2523
+  (1.4ms) BEGIN
2524
+ ActiveRecord::InternalMetadata Create (1.6ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2021-03-31 17:26:56.186267"], ["updated_at", "2021-03-31 17:26:56.186267"]]
2525
+  (1.8ms) COMMIT
2526
+ ActiveRecord::InternalMetadata Load (1.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
2527
+  (1.3ms) BEGIN
2528
+ ActiveRecord::InternalMetadata Update (1.5ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2021-03-31 17:26:56.197348"], ["key", "environment"]]
2529
+  (1.7ms) COMMIT
2530
+ NulogyMessageBusProducer::SubscriptionEvent Load (3.6ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "052ccd7d-fcb8-4779-a431-edcd07c6f9f2"], ["LIMIT", 1]]
2531
+  (1.5ms) BEGIN
2532
+ NulogyMessageBusProducer::SubscriptionEvent Create (2.1ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "052ccd7d-fcb8-4779-a431-edcd07c6f9f2"], ["subscription_id", "b7431c4b-6ba1-48de-9089-0d551a0b2289"], ["partition_key", "d42fd0ff-5f7c-4479-a555-275ad4a3d9ba"], ["topic_name", "some-topic"], ["company_uuid", "d42fd0ff-5f7c-4479-a555-275ad4a3d9ba"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 18:13:57.002078"], ["event_type", "some-type"]]
2533
+  (2.9ms) COMMIT
2534
+ NulogyMessageBusProducer::SubscriptionEvent Load (2.9ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "4301a9a9-410d-4906-a308-3f2e2a716481"], ["LIMIT", 1]]
2535
+  (1.9ms) BEGIN
2536
+ NulogyMessageBusProducer::SubscriptionEvent Create (1.9ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "4301a9a9-410d-4906-a308-3f2e2a716481"], ["subscription_id", "af99e3c4-e8da-4650-8429-a093d57e28c5"], ["partition_key", "43c04d27-3b88-4bb8-aa32-6e9cc401a9a1"], ["topic_name", "some-topic"], ["company_uuid", "43c04d27-3b88-4bb8-aa32-6e9cc401a9a1"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 18:20:17.588245"], ["event_type", "some-type"]]
2537
+  (2.9ms) COMMIT
2538
+ NulogyMessageBusProducer::SubscriptionEvent Load (2.4ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "0de39387-eb7b-4c82-981e-5440bcb563b0"], ["LIMIT", 1]]
2539
+  (1.7ms) BEGIN
2540
+ NulogyMessageBusProducer::SubscriptionEvent Create (2.1ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "0de39387-eb7b-4c82-981e-5440bcb563b0"], ["subscription_id", "9d1b70b1-7598-4687-a634-d55b17f868cc"], ["partition_key", "c7075533-fd2e-4f63-b964-980f3fa5f4a6"], ["topic_name", "some-topic"], ["company_uuid", "c7075533-fd2e-4f63-b964-980f3fa5f4a6"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 18:21:19.585687"], ["event_type", "some-type"]]
2541
+  (2.9ms) COMMIT
2542
+ NulogyMessageBusProducer::SubscriptionEvent Load (2.6ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "afa71c73-ea8c-4c05-ab56-5518923ef09f"], ["LIMIT", 1]]
2543
+  (1.6ms) BEGIN
2544
+ NulogyMessageBusProducer::SubscriptionEvent Create (2.1ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "afa71c73-ea8c-4c05-ab56-5518923ef09f"], ["subscription_id", "a91d295d-d570-49fc-bb50-7bc2317e7635"], ["partition_key", "106bea13-ccdb-49a5-a613-9c3e206267ca"], ["topic_name", "some-topic"], ["company_uuid", "106bea13-ccdb-49a5-a613-9c3e206267ca"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 18:21:20.593447"], ["event_type", "some-type"]]
2545
+  (3.1ms) COMMIT
2546
+ NulogyMessageBusProducer::SubscriptionEvent Load (2.3ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "91cc1302-d68e-42e4-8491-d4743289c54a"], ["LIMIT", 1]]
2547
+  (1.7ms) BEGIN
2548
+ NulogyMessageBusProducer::SubscriptionEvent Create (1.9ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "91cc1302-d68e-42e4-8491-d4743289c54a"], ["subscription_id", "d820eb79-29b4-48cb-91d3-aa6deeb7b182"], ["partition_key", "67afaf53-d2b3-47cd-937b-6d4ef9492b39"], ["topic_name", "some-topic"], ["company_uuid", "67afaf53-d2b3-47cd-937b-6d4ef9492b39"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 18:21:21.425429"], ["event_type", "some-type"]]
2549
+  (3.0ms) COMMIT
2550
+ NulogyMessageBusProducer::SubscriptionEvent Load (2.2ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "31e9b591-c646-4fcc-bcc6-70afe4aaa05c"], ["LIMIT", 1]]
2551
+  (1.3ms) BEGIN
2552
+ NulogyMessageBusProducer::SubscriptionEvent Create (1.3ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "31e9b591-c646-4fcc-bcc6-70afe4aaa05c"], ["subscription_id", "8e8b156e-b4e5-47a7-9f86-e6e876ccaf51"], ["partition_key", "c035daf9-1d15-4515-bbe2-7170a1ed7402"], ["topic_name", "some-topic"], ["company_uuid", "c035daf9-1d15-4515-bbe2-7170a1ed7402"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 18:21:22.409136"], ["event_type", "some-type"]]
2553
+  (1.8ms) COMMIT
@@ -46608,3 +46608,29 @@ COMMIT;
46608
46608
   (2.0ms) RELEASE SAVEPOINT active_record_1
46609
46609
  NulogyMessageBusProducer::SubscriptionEvent Load (1.6ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."subscription_id" = $1 LIMIT $2 [["subscription_id", "629c7f67-2a11-4822-9a24-e61030d229c9"], ["LIMIT", 1]]
46610
46610
   (1.9ms) ROLLBACK
46611
+  (1.0ms) BEGIN
46612
+ NulogyMessageBusProducer::SubscriptionEvent Load (4.9ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "8ce5a391-d750-415b-9c81-70f2cc18c5e4"], ["LIMIT", 1]]
46613
+  (2.0ms) SAVEPOINT active_record_1
46614
+  (1.8ms) ROLLBACK TO SAVEPOINT active_record_1
46615
+  (1.7ms) ROLLBACK
46616
+  (2.0ms) BEGIN
46617
+ NulogyMessageBusProducer::SubscriptionEvent Load (1.9ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "3021b411-c2a5-48c0-9e08-a941ed714ce9"], ["LIMIT", 1]]
46618
+  (2.3ms) SAVEPOINT active_record_1
46619
+ NulogyMessageBusProducer::SubscriptionEvent Create (3.9ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "3021b411-c2a5-48c0-9e08-a941ed714ce9"], ["subscription_id", "e03f0e3e-9c62-408b-906a-2a1469a0460c"], ["partition_key", "8eb1ab0b-dfaa-43ff-8995-266807bd8b0a"], ["topic_name", "some-topic"], ["company_uuid", "9dc238f9-3c1a-40ac-b6b8-8f8db06c62d2"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 17:27:05.849975"], ["event_type", "some-type"]]
46620
+  (1.6ms) RELEASE SAVEPOINT active_record_1
46621
+ NulogyMessageBusProducer::SubscriptionEvent Load (1.9ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" ORDER BY "message_bus_subscription_events"."id" DESC LIMIT $1 [["LIMIT", 1]]
46622
+  (2.4ms) ROLLBACK
46623
+  (1.3ms) BEGIN
46624
+ NulogyMessageBusProducer::SubscriptionEvent Load (1.7ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "6feda3d0-0a0e-4e9a-8e82-40a5b05e9335"], ["LIMIT", 1]]
46625
+  (2.1ms) SAVEPOINT active_record_1
46626
+ NulogyMessageBusProducer::SubscriptionEvent Create (2.0ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "6feda3d0-0a0e-4e9a-8e82-40a5b05e9335"], ["subscription_id", "13b956c1-122c-4949-a25c-1e81fad604b8"], ["partition_key", "cf83b600-b5b4-4483-aa35-2cc7e375ee0c"], ["topic_name", "some-topic"], ["company_uuid", "260e85ba-696b-489f-a3b7-229aed9af3e5"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 17:27:28.657359"], ["event_type", "some-type"]]
46627
+  (1.5ms) RELEASE SAVEPOINT active_record_1
46628
+ NulogyMessageBusProducer::SubscriptionEvent Load (1.5ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" ORDER BY "message_bus_subscription_events"."id" DESC LIMIT $1 [["LIMIT", 1]]
46629
+  (1.7ms) ROLLBACK
46630
+  (1.2ms) BEGIN
46631
+ NulogyMessageBusProducer::SubscriptionEvent Load (2.1ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" WHERE "message_bus_subscription_events"."id" = $1 LIMIT $2 [["id", "fdb612fd-ff7e-4d1b-9f47-a976eaf55de7"], ["LIMIT", 1]]
46632
+  (1.5ms) SAVEPOINT active_record_1
46633
+ NulogyMessageBusProducer::SubscriptionEvent Create (1.9ms) INSERT INTO "message_bus_subscription_events" ("id", "subscription_id", "partition_key", "topic_name", "company_uuid", "event_json", "created_at", "event_type") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id" [["id", "fdb612fd-ff7e-4d1b-9f47-a976eaf55de7"], ["subscription_id", "371f45eb-c140-454c-a8c3-efc4736e7658"], ["partition_key", "c9e8ebdb-d03f-45cc-97e3-c3ddd1913548"], ["topic_name", "some-topic"], ["company_uuid", "e9a1bffb-bd56-458c-a29c-d0d9aa99d783"], ["event_json", "{\"field\":\"value\"}"], ["created_at", "2021-03-31 17:27:39.991197"], ["event_type", "some-type"]]
46634
+  (1.4ms) RELEASE SAVEPOINT active_record_1
46635
+ NulogyMessageBusProducer::SubscriptionEvent Load (1.3ms) SELECT "message_bus_subscription_events".* FROM "message_bus_subscription_events" ORDER BY "message_bus_subscription_events"."id" DESC LIMIT $1 [["LIMIT", 1]]
46636
+  (2.1ms) ROLLBACK
@@ -14,7 +14,9 @@ RSpec.describe NulogyMessageBusProducer::RepopulateReplicationSlots do
14
14
  cleanup_everything
15
15
  end
16
16
 
17
- it "generates events" do
17
+ # TODO: This test is incredibly flakey.
18
+ # It rarely works in CI, and ocassionally works locally.
19
+ xit "generates events" do
18
20
  Kafka.create_topic(topic_name)
19
21
  consumer = Kafka.setup_kafka_consumer(topic_name)
20
22
 
@@ -0,0 +1,25 @@
1
+ require "integration_spec_helper"
2
+
3
+ RSpec.describe NulogyMessageBusProducer do
4
+ describe "publishing events" do
5
+ it "publishes an event" do
6
+ company_uuid = SecureRandom.uuid
7
+
8
+ described_class.publish(
9
+ topic: "some-topic",
10
+ type: "some-type",
11
+ company_uuid: company_uuid,
12
+ data: {
13
+ field: "value"
14
+ }
15
+ )
16
+
17
+ message = NulogyMessageBusProducer::SubscriptionEvent.last
18
+
19
+ expect(message).to be_present
20
+ expect(message.topic_name).to eq("some-topic")
21
+ expect(message.company_uuid).to eq(company_uuid)
22
+ expect(message.event_json).to eq({"field" => "value"})
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nulogy_message_bus_producer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 4.0.0.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nulogy
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -217,6 +217,7 @@ files:
217
217
  - Rakefile
218
218
  - db/migrate/20200611150212_create_public_subscriptions_and_events_tables.rb
219
219
  - db/migrate/20201005150212_rename_tenant_id_and_public.rb
220
+ - db/migrate/20210330204121_add_event_type_to_subscription_events.rb
220
221
  - lib/nulogy_message_bus_producer.rb
221
222
  - lib/nulogy_message_bus_producer/application_record.rb
222
223
  - lib/nulogy_message_bus_producer/base_subscription.rb
@@ -298,6 +299,7 @@ files:
298
299
  - spec/integration/lib/nulogy_message_bus_producer/subscriptions/postgres_transport_spec.rb
299
300
  - spec/integration/lib/nulogy_message_bus_producer/subscriptions/query_validator_spec.rb
300
301
  - spec/integration/lib/nulogy_message_bus_producer/subscriptions/risky_subscription_blocker_spec.rb
302
+ - spec/integration/lib/nulogy_message_bus_producer_spec.rb
301
303
  - spec/integration_spec_helper.rb
302
304
  - spec/nulogy_message_bus_producer/configuration/query_parser_spec.rb
303
305
  - spec/nulogy_message_bus_producer/subscriptions/subscription_spec.rb
@@ -312,7 +314,7 @@ files:
312
314
  homepage: https://github.com/nulogy/message-bus/tree/master/gems/nulogy_message_bus_producer
313
315
  licenses: []
314
316
  metadata: {}
315
- post_install_message:
317
+ post_install_message:
316
318
  rdoc_options: []
317
319
  require_paths:
318
320
  - lib
@@ -323,12 +325,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
323
325
  version: '2.0'
324
326
  required_rubygems_version: !ruby/object:Gem::Requirement
325
327
  requirements:
326
- - - ">="
328
+ - - ">"
327
329
  - !ruby/object:Gem::Version
328
- version: '0'
330
+ version: 1.3.1
329
331
  requirements: []
330
332
  rubygems_version: 3.0.3
331
- signing_key:
333
+ signing_key:
332
334
  specification_version: 4
333
335
  summary: Nulogy's code for producing to the Message Bus
334
336
  test_files:
@@ -389,6 +391,7 @@ test_files:
389
391
  - spec/dummy/log/test.log
390
392
  - spec/dummy/log/development.log
391
393
  - spec/integration_spec_helper.rb
394
+ - spec/integration/lib/nulogy_message_bus_producer_spec.rb
392
395
  - spec/integration/lib/nulogy_message_bus_producer/repopulate_replication_slots_spec.rb
393
396
  - spec/integration/lib/nulogy_message_bus_producer/config_spec.rb
394
397
  - spec/integration/lib/nulogy_message_bus_producer/subscriptions/risky_subscription_blocker_spec.rb