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 +4 -4
- data/Rakefile +0 -6
- data/lib/nulogy_message_bus_consumer/config.rb +2 -0
- data/lib/nulogy_message_bus_consumer/tasks/log_consumer_lag.rb +8 -2
- data/lib/nulogy_message_bus_consumer/version.rb +1 -1
- data/lib/nulogy_message_bus_consumer.rb +1 -1
- data/spec/dummy/log/development.log +83 -4
- data/spec/dummy/log/test.log +1857 -7682
- metadata +4 -23
- data/config/credentials/message-bus-us-east-1.key +0 -1
- data/spec/dummy/config/credentials/message-bus-us-east-1.key +0 -1
- data/spec/dummy/log/production.log +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc67ef0e9ad8a12ee285d6bf7898e262d5af7140ddfc50ce1265086f313dab5d
|
4
|
+
data.tar.gz: 968ef8091b7ba117dad2a90f265a9e89844f1604404449d703868f343f41c35d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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",
|
@@ -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
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
[1m[35m (0.9ms)[0m [1m[35mDROP DATABASE IF EXISTS "message_bus_consumer_development"[0m
|
2
|
+
[1m[35m (22.2ms)[0m [1m[35mDROP DATABASE IF EXISTS "message_bus_consumer_test"[0m
|
3
|
+
[1m[35m (76.6ms)[0m [1m[35mCREATE DATABASE "message_bus_consumer_development" ENCODING = 'utf8'[0m
|
4
|
+
[1m[35m (88.5ms)[0m [1m[35mCREATE DATABASE "message_bus_consumer_test" ENCODING = 'utf8'[0m
|
5
|
+
[1m[35mSQL (0.9ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
6
|
+
[1m[35mSQL (3.5ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "uuid-ossp"[0m
|
7
|
+
[1m[35m (0.9ms)[0m [1m[35mDROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE[0m
|
8
|
+
[1m[35m (3.6ms)[0m [1m[35mCREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)[0m
|
9
|
+
[1m[35m (5.9ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
10
|
+
[1m[35m (1.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
11
|
+
[1m[35m (1.4ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20200612184425)[0m
|
12
|
+
[1m[35m (1.1ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
13
|
+
(20200509095105);
|
14
|
+
|
15
|
+
[0m
|
16
|
+
[1m[35m (5.6ms)[0m [1m[35mCREATE 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)[0m
|
17
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
18
|
+
[1m[35m (0.9ms)[0m [1m[35mBEGIN[0m
|
19
|
+
[1m[36mActiveRecord::InternalMetadata Create (1.2ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2022-11-22 15:53:48.407450"], ["updated_at", "2022-11-22 15:53:48.407450"]]
|
20
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
21
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.8ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
22
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.8ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
23
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
24
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.9ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "dde38963e534769353e4aa869d2984e2f2b3db17"], ["created_at", "2022-11-22 15:53:48.418014"], ["updated_at", "2022-11-22 15:53:48.418014"]]
|
25
|
+
[1m[35m (1.2ms)[0m [1m[35mCOMMIT[0m
|
26
|
+
[1m[35mSQL (1.0ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
27
|
+
[1m[35mSQL (5.0ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "uuid-ossp"[0m
|
28
|
+
[1m[35m (1.3ms)[0m [1m[35mDROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE[0m
|
29
|
+
[1m[35m (6.9ms)[0m [1m[35mCREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)[0m
|
30
|
+
[1m[35m (5.4ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
31
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
32
|
+
[1m[35m (1.4ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20200612184425)[0m
|
33
|
+
[1m[35m (1.3ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
34
|
+
(20200509095105);
|
35
|
+
|
36
|
+
[0m
|
37
|
+
[1m[35m (4.4ms)[0m [1m[35mCREATE 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)[0m
|
38
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
39
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
40
|
+
[1m[36mActiveRecord::InternalMetadata Create (1.7ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2022-11-22 15:53:48.493798"], ["updated_at", "2022-11-22 15:53:48.493798"]]
|
41
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
42
|
+
[1m[36mActiveRecord::InternalMetadata Load (2.0ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
43
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
44
|
+
[1m[36mActiveRecord::InternalMetadata Update (2.0ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2022-11-22 15:53:48.503739"], ["key", "environment"]]
|
45
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
46
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.8ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
47
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
48
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.8ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "dde38963e534769353e4aa869d2984e2f2b3db17"], ["created_at", "2022-11-22 15:53:48.511603"], ["updated_at", "2022-11-22 15:53:48.511603"]]
|
49
|
+
[1m[35m (1.3ms)[0m [1m[35mCOMMIT[0m
|
50
|
+
[1m[35m (1.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
51
|
+
[1m[35m (1.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
52
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
53
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
54
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
55
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
56
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
57
|
+
[1m[35mSQL (0.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
58
|
+
[1m[35mSQL (0.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "uuid-ossp"[0m
|
59
|
+
[1m[35m (2.3ms)[0m [1m[35mDROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE[0m
|
60
|
+
[1m[35m (2.9ms)[0m [1m[35mCREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)[0m
|
61
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
62
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
63
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
64
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
65
|
+
[1m[35mSQL (0.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
66
|
+
[1m[35mSQL (0.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "uuid-ossp"[0m
|
67
|
+
[1m[35m (2.0ms)[0m [1m[35mDROP TABLE IF EXISTS "message_bus_processed_messages" CASCADE[0m
|
68
|
+
[1m[35m (4.0ms)[0m [1m[35mCREATE TABLE "message_bus_processed_messages" ("id" uuid NOT NULL PRIMARY KEY, "created_at" timestamp NOT NULL)[0m
|
69
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
70
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
71
|
+
[1m[35m (0.8ms)[0m [1m[35mBEGIN[0m
|
72
|
+
[1m[36mActiveRecord::InternalMetadata Update (1.5ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "development"], ["updated_at", "2022-11-22 15:54:02.152053"], ["key", "environment"]]
|
73
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
74
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
75
|
+
[1m[35m (0.8ms)[0m [1m[35mBEGIN[0m
|
76
|
+
[1m[36mActiveRecord::InternalMetadata Update (2.1ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2022-11-22 15:54:02.160153"], ["key", "environment"]]
|
77
|
+
[1m[35m (1.2ms)[0m [1m[35mCOMMIT[0m
|
78
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
79
|
+
[1m[35m (1.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(5775182565276900090)[0m
|
80
|
+
[1m[35m (2.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
81
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
82
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT pg_advisory_unlock(5775182565276900090)[0m
|
83
|
+
[1m[35m (1.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|