nulogy_message_bus_consumer 1.0.0 → 2.0.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: '0989adbcf8a099ac67362106e1724097f7266523a290a36d568d2f8d195a085a'
4
- data.tar.gz: da702aedd0055c0fb3ee4269999bc72009bc6d0823f68264770caa11c10c445c
3
+ metadata.gz: bc67ef0e9ad8a12ee285d6bf7898e262d5af7140ddfc50ce1265086f313dab5d
4
+ data.tar.gz: 968ef8091b7ba117dad2a90f265a9e89844f1604404449d703868f343f41c35d
5
5
  SHA512:
6
- metadata.gz: 690db182773fca7bb41d230eb2a5a2c866f61eae733d1afd63b3f7b4693a747b0d1a82d169f7c09b745d70dd5e945e0c745eebb138e7c2405d608ccb736572ba
7
- data.tar.gz: 2f5bf0079b7932e15cf9996518d17ec9309882f601cef507a8952ebf22f4c9da01ba5ede9d77674bc491c2dbc6a04b6fb00d095e106075c9d2ad81a001421b49
6
+ metadata.gz: 7def0d572755c4b66d8f3ca603fadc64dd3aa159a3a6e868ec38efa589d08d50bdd9ba187cb89ef8773fbe02a5616dea705b6366b4c7371bec3e3979788fca39
7
+ data.tar.gz: 89b43ff862329c5710f5441a765e20924d0411a0f012905d2e697fb6029b3f9df716b9704d290e37e357bbd4f196d30dd86774ae25bcc017cb6087ad1a2e7845
data/Rakefile CHANGED
@@ -23,9 +23,3 @@ require "rspec/core/rake_task"
23
23
  RSpec::Core::RakeTask.new(:spec)
24
24
  require "standard/rake"
25
25
  task default: %i[spec standard]
26
-
27
- require "rake/release"
28
-
29
- Rake::Release::Task.load_all do |spec|
30
- spec.version_tag = "nulogy_message_bus_consumer-v#{spec.version}"
31
- end
@@ -5,6 +5,7 @@ module NulogyMessageBusConsumer
5
5
  :consumer_group_id,
6
6
  :lag_check_interval_seconds,
7
7
  :lag_checks,
8
+ :lag_timeout_milliseconds,
8
9
  :log_lag_interval_seconds,
9
10
  :prune_interval_seconds,
10
11
  :prune_max_age,
@@ -14,6 +15,7 @@ module NulogyMessageBusConsumer
14
15
  defaults = {
15
16
  lag_check_interval_seconds: 20,
16
17
  lag_checks: 6,
18
+ lag_timeout_milliseconds: 200,
17
19
  log_lag_interval_seconds: 1.minute.to_i,
18
20
  prune_interval_seconds: 1.hour.to_i,
19
21
  prune_max_age: 8.days
@@ -3,9 +3,10 @@ module NulogyMessageBusConsumer
3
3
  class LogConsumerLag
4
4
  attr_reader :interval
5
5
 
6
- def initialize(logger, interval_seconds)
6
+ def initialize(logger, interval_seconds, lag_timeout)
7
7
  @logger = logger
8
8
  @interval = interval_seconds
9
+ @lag_timeout = lag_timeout
9
10
  end
10
11
 
11
12
  def extract_args(kafka_consumer:, **_)
@@ -18,7 +19,12 @@ module NulogyMessageBusConsumer
18
19
  # has finished connecting. There appears to be a race condition.
19
20
  KafkaUtils.wait_for_assignment(@kafka_consumer)
20
21
 
21
- lag_per_topic = @kafka_consumer.lag(@kafka_consumer.committed)
22
+ # Note: consumer#committed has a timeout of 1200ms. To respect our lag_timeout, use the largest.
23
+ committed_timeout = [1200, @lag_timeout].max
24
+ # The first parameter is a TopicPartitionList. When nil, it uses all the assigned ones.
25
+ committed_offsets = @kafka_consumer.committed(nil, committed_timeout)
26
+
27
+ lag_per_topic = @kafka_consumer.lag(committed_offsets, @lag_timeout)
22
28
 
23
29
  @logger.info(JSON.dump({
24
30
  event: "consumer_lag",
@@ -1,3 +1,3 @@
1
1
  module NulogyMessageBusConsumer
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -52,7 +52,7 @@ module NulogyMessageBusConsumer
52
52
  # be called once, without any messages.
53
53
  Steps::ConnectToMessageBus.new(config, logger),
54
54
  Steps::TimedTask.new(
55
- Tasks::LogConsumerLag.new(logger, config.log_lag_interval_seconds)
55
+ Tasks::LogConsumerLag.new(logger, config.log_lag_interval_seconds, config.lag_timeout_milliseconds)
56
56
  ),
57
57
  Steps::TimedTask.new(
58
58
  Tasks::PruneProcessedMessages.new(logger, config.prune_interval_seconds, config.prune_max_age)
@@ -1,4 +1,83 @@
1
- Connecting to the MessageBus
2
- Using consumer group id: test-jasons-partitions-1-audit
3
- Listening for kafka messages on topic test-jasons-partitions-1
4
- {"event":"message_processing_errored","class":"ActiveRecord::NoDatabaseError","message":"FATAL: database \"message_bus_consumer_development\" does not exist\n"}
1
+  (0.9ms) DROP DATABASE IF EXISTS "message_bus_consumer_development"
2
+  (22.2ms) DROP DATABASE IF EXISTS "message_bus_consumer_test"
3
+  (76.6ms) CREATE DATABASE "message_bus_consumer_development" ENCODING = 'utf8'
4
+  (88.5ms) CREATE DATABASE "message_bus_consumer_test" ENCODING = 'utf8'
5
+ SQL (0.9ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
6
+ SQL (3.5ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
7
+  (0.9ms) DROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE
8
+  (3.6ms) CREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)
9
+  (5.9ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
10
+  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
11
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES (20200612184425)
12
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES
13
+ (20200509095105);
14
+
15
+ 
16
+  (5.6ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
17
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
18
+  (0.9ms) BEGIN
19
+ ActiveRecord::InternalMetadata Create (1.2ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2022-11-22 15:53:48.407450"], ["updated_at", "2022-11-22 15:53:48.407450"]]
20
+  (1.1ms) COMMIT
21
+ ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
22
+ ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
23
+  (0.7ms) BEGIN
24
+ ActiveRecord::InternalMetadata Create (0.9ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "dde38963e534769353e4aa869d2984e2f2b3db17"], ["created_at", "2022-11-22 15:53:48.418014"], ["updated_at", "2022-11-22 15:53:48.418014"]]
25
+  (1.2ms) COMMIT
26
+ SQL (1.0ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
27
+ SQL (5.0ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
28
+  (1.3ms) DROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE
29
+  (6.9ms) CREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)
30
+  (5.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
31
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
32
+  (1.4ms) INSERT INTO "schema_migrations" (version) VALUES (20200612184425)
33
+  (1.3ms) INSERT INTO "schema_migrations" (version) VALUES
34
+ (20200509095105);
35
+
36
+ 
37
+  (4.4ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
38
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
39
+  (0.7ms) BEGIN
40
+ ActiveRecord::InternalMetadata Create (1.7ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2022-11-22 15:53:48.493798"], ["updated_at", "2022-11-22 15:53:48.493798"]]
41
+  (1.1ms) COMMIT
42
+ 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]]
43
+  (0.7ms) BEGIN
44
+ ActiveRecord::InternalMetadata Update (2.0ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2022-11-22 15:53:48.503739"], ["key", "environment"]]
45
+  (1.1ms) COMMIT
46
+ ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
47
+  (0.7ms) BEGIN
48
+ ActiveRecord::InternalMetadata Create (0.8ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "dde38963e534769353e4aa869d2984e2f2b3db17"], ["created_at", "2022-11-22 15:53:48.511603"], ["updated_at", "2022-11-22 15:53:48.511603"]]
49
+  (1.3ms) COMMIT
50
+  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
51
+  (1.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
52
+  (0.9ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
53
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
54
+  (0.8ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
55
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
56
+  (0.8ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
57
+ SQL (0.8ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
58
+ SQL (0.8ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
59
+  (2.3ms) DROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE
60
+  (2.9ms) CREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)
61
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
62
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
63
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
64
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
65
+ SQL (0.8ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
66
+ SQL (0.8ms) CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
67
+  (2.0ms) DROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE
68
+  (4.0ms) CREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)
69
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
70
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
71
+  (0.8ms) BEGIN
72
+ ActiveRecord::InternalMetadata Update (1.5ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "development"], ["updated_at", "2022-11-22 15:54:02.152053"], ["key", "environment"]]
73
+  (1.1ms) COMMIT
74
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
75
+  (0.8ms) BEGIN
76
+ ActiveRecord::InternalMetadata Update (2.1ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2022-11-22 15:54:02.160153"], ["key", "environment"]]
77
+  (1.2ms) COMMIT
78
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
79
+  (1.2ms) SELECT pg_try_advisory_lock(5775182565276900090)
80
+  (2.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
81
+ ActiveRecord::InternalMetadata Load (0.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
82
+  (0.9ms) SELECT pg_advisory_unlock(5775182565276900090)
83
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC