Compare commits

...
295 Commits
Author SHA1 Message Date
Рябов Владислав Олегович f7a141d25e Merge branch 'MSP-9033' into 'main'
MSP-9033 update deps

Closes MSP-9033

See merge request isp/isp-config-service!24
2026-11-20 10:43:21 +00:00
riabovvo 6731fc6b93 MSP-9033 update deps 2026-11-20 13:42:09 +03:00
Рябов Владислав Олегович d45f814d6a Merge branch 'MSP-9033' into 'main'
update deps

Closes MSP-9033

See merge request isp/isp-config-service!23
2026-11-20 09:15:19 +00:00
riabovvo 1ff499ace3 update deps 2026-11-20 12:12:39 +03:00
Рябов Владислав Олегович b481c2a45e Merge branch 'MSP-9033' into 'main'
Resolve MSP-9033

Closes MSP-9033

See merge request isp/isp-config-service!22
2026-11-20 07:46:26 +00:00
riabovvo dde6c49b92 MSP-9033 update Dockerfile 2026-11-20 10:26:44 +03:00
riabovvo 9a66bd060a MSP-9033 bump version to 3.12.1 2026-11-20 10:11:31 +03:00
riabovvo d669c65038 MSP-9033 update local.go 2026-11-20 10:11:17 +03:00
komissarovyv c9ee296835 Merge branch 'module-leader-election' into 'main'
Module leader election: derivation, event narrowing and observation API

See merge request isp/isp-config-service!21
2026-11-19 13:21:17 +03:00
komissarovyv 53dff62759 Update release notes for the leader logging change 2026-11-19 12:57:41 +03:00
komissarovyv 439e6f5ebf Drop the module leader recompute event
The queue event did two things: set the routing-changed flag, which the lifecycle
event of the same change already sets, and deliver the leader-change info log. It
cost an extra raft INSERT per connect/disconnect, two GetForLeaderElection reads per
lifecycle event used for nothing else, a payload kind, a compaction key and a
subscription-service method that only logged.

The leader is now logged where it is published: the address-list emission logs the
leader it just sent, and the routing rebuild logs one summary line with the leaders
it published. Modules without election stay silent, as before.

A future self-election needs a recompute trigger that also re-broadcasts the address
list; that event will be added when the requirement exists, not carried as a no-op.
2026-11-19 12:57:28 +03:00
komissarovyv a8a475435c Bump version to 3.12.0 2026-11-19 12:14:34 +03:00
komissarovyv b36cb1cd0e Update kit to 1.76.0 2026-11-19 12:13:00 +03:00
komissarovyv 06ec2c6a87 Fix flaky leader flag assertion in module leader mode test 2026-11-18 22:05:09 +03:00
komissarovyv 45d7ea443f Show module leader flag in the observation API 2026-11-18 21:59:30 +03:00
komissarovyv 2bb06ffb8e Share module leader derivation by module 2026-11-18 21:49:35 +03:00
komissarovyv 45de1d1b12 Log module leader changes on the recompute event
The event handler maps the leader recompute onto the routing map rebuild with
the ready and disconnected events of the batch, so a leader change reaches the
routing map of every config service node.

The address list is not re-broadcast from it: the ready and disconnected event
of the same change already broadcasts it, and an extra snapshot per connect
broke the acceptance test on the exact number of host lists a module receives.

An info is written when the leader address in the payload differs from the
address before the change, naming the module, both addresses and the reason.
An event that changed nothing is silent, so the log stays readable.
2026-11-18 21:29:29 +03:00
komissarovyv 6cd0b2c712 Add internal module leader recompute event
The queue gets a payload kind of its own to recompute a module leader, with the
compaction key module_leader_<moduleId> so the collapse of ready and
disconnected into one module_lifecycle_<moduleId> event cannot swallow it.

The event is inserted next to the events of the same change: on a connect, on a
disconnect by WebSocket close, and on the phantom cleanup of the own node.
Graceful shutdown by DeleteOwnBackends keeps inserting no events. The payload
carries the leader address before and after the change, derived from the module
instances that are already loaded, so the event worker reads nothing from the
database. No new columns, no new tables, no new migrations.
2026-11-18 21:29:23 +03:00
komissarovyv 3d04dd2df7 Narrow module events to the module leader 2026-11-18 20:00:09 +03:00
komissarovyv 6cfa1955ea Derive module leader from connected instances 2026-11-18 20:00:09 +03:00
komissarovyv 9e24122e75 Cover module leader mode storage in acceptance tests 2026-11-18 19:31:14 +03:00
komissarovyv 71997dc438 Expose rqlite db handle for tests 2026-11-18 19:31:14 +03:00
komissarovyv bd8a1b2de4 Add module_leader_mode column to connected instances 2026-11-18 19:31:10 +03:00
komissarovyv 7b0108a358 Pin leader contract fields in the acceptance harness 2026-11-18 19:12:53 +03:00
komissarovyv a195c76799 Local isp-kit replace for module leader contract 2026-11-18 19:06:10 +03:00
komissarovyv 780c2232fb Merge branch 'fix-variable-links-persist' into 'main'
Fix: variable links not saved when a variable is used multiple times in config

See merge request isp/isp-config-service!20
2026-10-28 11:37:27 +03:00
Hermes Agent ef0978e064 Bump version to 3.11.1, add changelog 2026-10-28 11:29:32 +03:00
Hermes Agent c464393e93 Drop link self-healing paths, fix linter findings
- Remove link resync on module reconnect, link resave on no-op config
  update, and link backfill on variable create/upsert: links are
  formed only on config save
- Disable exhaustruct_v5 and goconst linters
- Fix golangci-lint findings: noinlineerr, slices.Backward,
  wrapcheck for ConfigValidationError (errors.As in controller keeps
  working via %w), funlen nolint on acceptance test
2026-10-28 11:22:59 +03:00
Hermes Agent 7f4e3ef028 Fix variable links not persisted when variable is used multiple times in config
- Dedupe extracted variable names (duplicate INSERTs aborted the
  config_has_variable transaction on PK conflict)
- Check per-statement rqlite errors in ExecTransaction: a failed
  statement silently returned success before
- Make link upserts idempotent (insert or ignore) and add link
  backfill on variable create/upsert from existing configs
- Validate config variables before insert (no orphaned configs)
- Resync active config links on module reconnect and on no-op
  config update (self-healing)
2026-10-28 10:34:45 +03:00
Синельник Тимур Романович 5c8a554d4f Merge branch 'MSP-8394' into 'main'
Resolve MSP-8394

Closes MSP-8394

See merge request isp/isp-config-service!19
2026-09-25 14:11:50 +03:00
Синельник Тимур Романович 5bdb4813b5 MSP-8394 Guard returning errors.WithMessage with err != nil check 2026-09-25 14:08:18 +03:00
Синельник Тимур Романович 17ec4bdce9 MSP-8394 Use slices.Backward for cycle 2026-09-25 14:06:15 +03:00
Синельник Тимур Романович 428de36857 MSP-8394 Up deps & use isp-kit/errors 2026-09-25 13:45:02 +03:00
Синельник Тимур Романович fc9c4f956f MSP-8394 Bump version to 3.11.0 2026-08-24 12:23:43 +03:00
Синельник Тимур Романович 44961d8416 MSP-8394 Add required admin permission 2026-08-24 12:22:33 +03:00
komissarovyv 2a846c67e4 MODULE_READY can be handled several times 2026-08-09 12:45:52 +03:00
komissarovyv 481f06bfec Bump dependencies 2026-07-27 16:21:37 +03:00
komissarovyv 3b99380a62 Disable migrate tool build 2026-07-07 12:41:50 +03:00
komissarovyv ffa09db7b2 Merge branch 'MSP-8007' into 'main'
Resolve MSP-8007

Closes MSP-8007

See merge request isp/isp-config-service!18
2026-07-07 11:44:22 +03:00
kochanovrv 94af308030 MSP-8007 fix threads 2026-07-07 11:24:09 +03:00
kochanovrv 36e320af28 MSP-8007 up sqlite 2026-07-06 16:21:06 +03:00
kochanovrv c2d7aea679 MSP-8007 up version to v3.9.2 2026-07-06 15:02:33 +03:00
kochanovrv aebd33e5cb MSP-8007 update isp-kit 2026-07-06 15:02:15 +03:00
Кузьмин Игорь Александрович 45b28e46e6 Edit .gitlab-ci.yml 2026-05-13 11:23:17 +00:00
Грязнов Денис Владимирович 48ccd130b2 Merge branch 'MSP-7572' into 'main'
Resolve MSP-7572

Closes MSP-7572

See merge request isp/isp-config-service!17
2026-04-23 14:17:35 +00:00
nglmq 7eb341856d MSP-7572 edit endpoint to inner 2026-04-22 12:36:48 +03:00
nglmq 38fe10f3a1 MSP-7572 bump version to 3.9.1 2026-04-22 12:36:48 +03:00
nglmq fa327ecf5c MSP-7572 edit go version in Dockerfiles 2026-04-22 12:36:48 +03:00
nglmq 6c3e8a632e MSP-7572 linter fixes 2026-04-21 12:35:50 +03:00
nglmq 03fcb26473 MSP-7572 swagger update 2026-04-21 11:57:23 +03:00
nglmq 7f4a1c8131 MSP-7572 new andpoint for required modules 2026-04-21 11:57:00 +03:00
komissarovyv 416f9307c3 Bump isp-kit 2026-02-20 19:26:48 +03:00
Грязнов Денис Владимирович 1273869b07 Merge branch 'dev' into 'main'
Dev

See merge request isp/isp-config-service!16
2026-02-11 13:45:59 +00:00
Синельник Тимур Романович 1839a18bb4 up deps 2026-02-11 16:14:03 +03:00
Синельник Тимур Романович 34d7fabf61 MSP-7042 Bump version to 3.9.0 2026-02-11 16:13:27 +03:00
Синельник Тимур Романович c295bda53b MSP-7042 Up deps & support http methods and transport 2026-02-11 16:13:03 +03:00
komissarovyv f97795bd90 Fix migrate 2026-02-10 17:35:55 +03:00
Кузьмин Игорь Александрович f7931b1d83 Edit .gitlab-ci.yml 2026-02-09 09:06:25 +00:00
Кузьмин Игорь Александрович 245cf8852d Edit .gitlab-ci.yml 2026-02-06 08:11:25 +00:00
Кузьмин Игорь Александрович 7b09eb3a07 Edit Dockerfile.dit 2026-02-05 14:45:18 +00:00
Кузьмин Игорь Александрович e45900fbaa Revert "Replace .gitlab-ci.yml"
This reverts commit aefc14ece9
2026-02-05 14:41:25 +00:00
Кузьмин Игорь Александрович b0330e80f3 Revert "Delete Dockerfile.dit"
This reverts commit 5a3d4fffea
2026-02-05 14:38:46 +00:00
Синельник Тимур Романович 9a2cdd0662 Merge branch 'sprint_dev' into 'main'
Sprint dev

Closes MSP-6930

See merge request isp/isp-config-service!13
2026-01-26 15:48:59 +03:00
Синельник Тимур Романович 9b577e96b1 Merge branch 'MSP-6930' into 'sprint_dev'
Resolve MSP-6930

See merge request isp/isp-config-service!14
2025-12-18 13:33:21 +03:00
Синельник Тимур Романович 7873c57c8e MSP-6930 Bump version to 3.8.0 2025-12-18 12:21:17 +03:00
Синельник Тимур Романович 38fdb65ec2 MSP-6930 Update updated_at 2025-12-18 12:21:17 +03:00
Синельник Тимур Романович 9ebf03a15a MSP-6930 Add /schema/update_by_module_name endpoint 2025-12-18 12:12:22 +03:00
Лихачев Алексей Михайлович 8101f9a8c8 Merge branch 'MSP-6703' into 'main'
MSP-6703

See merge request isp/isp-config-service!12
2025-12-01 13:37:18 +00:00
likhachevam 924d1cf6fe MSP-6703 up version to v3.7.0 2025-12-01 12:34:15 +03:00
likhachevam de3e456617 MSP-6703 fix 'enabled' config field 2025-12-01 12:34:05 +03:00
likhachevam fc5a21d6bb MSP-6703 add AutoOptimizeInterval to config.yml 2025-11-24 15:21:15 +03:00
likhachevam 4763d88628 MSP-6703 remove unused utils 2025-11-21 16:10:27 +03:00
likhachevam a6d72ec1a4 MSP-6703 add rqlite backup proxy 2025-11-21 16:03:57 +03:00
likhachevam 99d4aaca45 MSP-6703 fix race conditions 2025-11-21 13:24:48 +03:00
likhachevam 2f614a5c75 MSP-6703 update clearInterval format 2025-11-21 13:24:32 +03:00
likhachevam 960b87d86d MSP-6703 update waitForLeaderTimeout 2025-11-20 18:37:44 +03:00
likhachevam 35e15b7ae1 MSP-6703 update config.yml 2025-11-20 15:23:25 +03:00
likhachevam 392e5f5cff MSP-6703 fix go version 2025-11-20 14:58:18 +03:00
likhachevam 451d277644 MSP-6703 add backup_cleaner 2025-11-20 11:04:25 +03:00
likhachevam 2caed6b3f0 MSP-6703 up rqlite & add backups 2025-11-20 11:04:02 +03:00
likhachevam a349df7b05 MSP-6703 up dependencies 2025-11-20 11:01:43 +03:00
Лихачев Алексей Михайлович efed09bb92 Merge branch 'MSP-6459' into 'main'
MSP-6459

See merge request isp/isp-config-service!11
2025-10-09 12:25:11 +00:00
likhachevam a2c222dfd9 MSP-6459 up version to v3.6.0 2025-10-08 11:31:16 +03:00
likhachevam 129ce7c2c6 MSP-6459 update /purge_versions endpoint 2025-10-08 11:31:11 +03:00
likhachevam cde261cf5d MSP-6459 up go version to v1.25 2025-10-07 17:49:10 +03:00
likhachevam 8ef12f8b11 MSP-6459 update /purge_version endpoint 2025-10-07 17:27:58 +03:00
likhachevam 99782ef3bb MSP-6459 update linter 2025-10-07 16:46:34 +03:00
likhachevam 6a36603b5d MSP-6459 add PurgeConfigVersions endpoint 2025-10-07 16:46:18 +03:00
Кузьмин Игорь Александрович 5a3d4fffea Delete Dockerfile.dit 2025-09-17 14:41:30 +00:00
Грязнов Денис Владимирович 7a585711f6 Merge branch 'MSP-6078' into 'main'
Resolve MSP-6078

Closes MSP-6078

See merge request isp/isp-config-service!10
2025-08-21 12:03:53 +00:00
Кузнецов Иван Александрович d024e038c2 MSP-6078 update deps 2025-08-21 14:20:59 +03:00
Кузнецов Иван Александрович 7b329a8c73 MSP-6078 update deps 2025-08-21 13:45:43 +03:00
Кузнецов Иван Александрович e62089f019 MSP-6078 bump version to 3.5.0 2025-08-20 14:09:46 +03:00
Кузнецов Иван Александрович c3ed4a0e27 MSP-6078 update deps 2025-08-20 14:06:40 +03:00
komissarovyv 846129b1af Bump dependencies 2025-07-08 11:30:51 +03:00
komissarovyv 66edb03aa4 Bump dependencies 2025-07-08 11:20:46 +03:00
komissarovyv d56d6613bb Call upsert variables in any case 2025-07-08 11:19:04 +03:00
Кузьмин Игорь Александрович 5a67d0cc4f Edit README.md 2025-06-23 08:56:31 +00:00
Кузьмин Игорь Александрович 803b067278 Edit README.md 2025-06-23 07:58:36 +00:00
Рябов Кирилл Александрович 78eeee0bc6 Merge branch 'MSP-5579' into 'main'
MSP-5579

See merge request isp/isp-config-service!9
2025-06-10 13:09:48 +07:00
Kirill Ryabov c6f2c3a813 MSP-5579 bump version to 3.4.0 2025-06-09 16:10:30 +03:00
Kirill Ryabov 441702a180 MSP-5579 update swagger 2025-06-09 16:10:30 +03:00
Kirill Ryabov de85ffa726 MSP-5579 add test for autodiscovery functionality 2025-06-09 16:10:30 +03:00
Kirill Ryabov 1482636ad8 MSP-5579 enable metrics autodiscovery 2025-06-09 16:10:30 +03:00
Kirill Ryabov b62b0eef8b MSP-5579 include internal metrics autodiscovery method to locator & setup route 2025-06-09 16:10:30 +03:00
Kirill Ryabov 37f85f56fa MSP-5579 implement internal metrics autodiscovery endpoint 2025-06-09 16:10:30 +03:00
Kirill Ryabov 4c131093b1 MSP-5579 add handling MetricsAutodiscovery field from backend declaration 2025-06-09 14:52:49 +03:00
Kirill Ryabov 22bfe6f2a1 MSP-5579 enrich Backend struct with MetricsAutodiscovery field & add MetricsAdWrapper struct 2025-06-09 14:52:49 +03:00
Kirill Ryabov fd5ce55c4c MSP-5579 add metrics_autodiscovery column migration 2025-06-09 11:35:23 +03:00
Kirill Ryabov e5494e2849 MSP-5579 update dependencies 2025-06-09 11:35:23 +03:00
Кузьмин Игорь Александрович eb79974760 Edit Dockerfile 2025-06-06 14:02:13 +00:00
Кузьмин Игорь Александрович 350d22ae75 Edit Dockerfile 2025-06-06 13:49:02 +00:00
Рябов Кирилл Александрович 3e7f235876 Merge branch 'MSP-5494' into 'main'
MSP-5494

See merge request isp/isp-config-service!8
2025-05-27 18:36:55 +07:00
Kirill Ryabov 778e194d1d MSP-5494 bump version to 3.3.1 2025-05-26 14:43:31 +03:00
Kirill Ryabov bfe9764707 MSP-5494 update swagger 2025-05-26 14:43:31 +03:00
Kirill Ryabov 5877176645 MSP-5494 update dependencies 2025-05-26 14:43:31 +03:00
Kirill Ryabov 10e74db016 MSP-5494 migrate linter to v2 2025-05-26 14:43:31 +03:00
Kirill Ryabov 82f6d624ba MSP-5494 add github actions ci to build & publish docker image 2025-05-26 14:43:31 +03:00
Кузьмин Игорь Александрович 22e76538c4 Edit README.md 2025-04-18 13:57:57 +00:00
Кузьмин Игорь Александрович 11a5477bcb Edit README.md 2025-04-18 09:40:32 +00:00
Кузьмин Игорь Александрович aefc14ece9 Replace .gitlab-ci.yml 2025-04-18 09:13:59 +00:00
komissarovyv 0e6b5dec52 Merge branch 'MSP-5223' into 'main'
Resolve MSP-5223

Closes MSP-5223

See merge request isp/isp-config-service!7
2025-04-17 14:50:09 +00:00
Кузнецов Иван Александрович 2a424699d7 MSP-5223 composition struct domain.Config in domain.CreateUpdateConfigResponse 2025-04-17 15:23:36 +03:00
Кузнецов Иван Александрович 3c19a8d532 MSP-5223 update response CreateUpdateConfig: add IsChanged field 2025-04-16 16:05:17 +03:00
Кузнецов Иван Александрович 28be68322c MSP-5223 update compare actual data config and update request data config 2025-04-15 19:00:41 +03:00
Кузнецов Иван Александрович 867fd98bce MSP-5223 update naming + update changelog.md 2025-04-15 15:22:24 +03:00
Кузнецов Иван Александрович 1d3bacd22c MSP-5223 add endpoint /config/config/sync_config 2025-04-15 13:59:34 +03:00
Кузнецов Иван Александрович a483722e1d MSP-5223 update CreateUpdateConfig: add case equal name and data config 2025-04-15 13:29:27 +03:00
Кузнецов Иван Александрович 6ab012444f MSP-5223 UpdateConfigName not update field updated_at 2025-04-15 10:18:36 +03:00
Кузнецов Иван Александрович 57f58e7fb7 MSP-5223 rename field UpdateConfigNameRequest ConfigId -> Id 2025-04-15 10:10:46 +03:00
Кузнецов Иван Александрович a51aae9b69 MSP-5223 UpdateConfigNameRequest change field OldConfigName -> ConfidId + change ConfigVersion.CreatedAt actualCfg.CreatedAt -> actual.UpdatedAt 2025-04-14 19:17:04 +03:00
Кузнецов Иван Александрович 4214bd3f20 MSP-5223 swagger for UpdateConfigName 2025-04-14 19:17:04 +03:00
Кузнецов Иван Александрович a0b2a75c9d MSP-5223 GetAllVersion add handler entity.ErrConfigNotFound 2025-04-14 19:17:04 +03:00
Кузнецов Иван Александрович 159db8114e MSP-5223 bump version to 3.3.0 2025-04-14 19:16:57 +03:00
Кузнецов Иван Александрович a7b203bcd0 MSP-5223 implement handler config/config/update_config_name 2025-04-14 11:50:25 +03:00
Кузнецов Иван Александрович d0b55947c5 MSP-5223 configHistory.CreatedAt = oldConfig.UpdatedAt 2025-04-11 14:33:18 +03:00
Кузнецов Иван Александрович a3c65a1434 MSP-5223 generate new swagger 2025-04-11 14:16:24 +03:00
Кузнецов Иван Александрович 29c1a4deeb MSP-5223 update .golangci.yml + fix linters 2025-04-11 14:15:30 +03:00
Кузнецов Иван Александрович ee44e68af9 MSP-5223 update deps 2025-04-11 13:38:21 +03:00
Кузнецов Иван Александрович 7a426b647b MSP-5223 sort imports 2025-04-11 13:36:48 +03:00
Кузнецов Иван Александрович 9d299beaf6 MSP-5223 add actual config in GetAllVersions 2025-04-11 13:31:08 +03:00
komissarovyv 7a1d882248 Merge branch 'v3' into 'main'
V3

See merge request isp/isp-config-service!6
2025-03-24 12:29:17 +00:00
komissarovyv ab95da7242 MSP-5013 change variable error 2025-03-24 15:26:59 +03:00
komissarovyv f63bf4a9f1 MSP-5013 make description optional 2025-03-19 18:32:09 +03:00
komissarovyv a9d4b96305 MSP-5013 bump dependencies 2025-03-12 12:08:01 +03:00
komissarovyv cedb376a91 MSP-5013 use simple regexp to inject variables 2025-03-11 15:52:45 +03:00
komissarovyv 93d09a779d MSP-5013 hack jinja variables 2025-03-11 14:01:30 +03:00
komissarovyv 41fa496052 MSP-5013 fix test 2025-03-10 17:28:15 +03:00
komissarovyv 398d537d8a MSP-5013 unmarshal fix 2025-03-06 15:43:02 +03:00
komissarovyv c501354be1 MSP-5013 unmarshal fix 2025-03-06 15:40:54 +03:00
komissarovyv 7852772e9d MSP-5013 fix get by name 2025-03-06 14:56:01 +03:00
komissarovyv efc4a4ee38 MSP-5013 change routes 2025-03-06 11:53:04 +03:00
komissarovyv 25c07ef016 MSP-5013 bump version 2025-03-06 11:18:51 +03:00
komissarovyv b3511f018a MSP-5013 bump version 2025-03-06 11:10:15 +03:00
komissarovyv 46ba9541eb MSP-5013 reinit go mod 2025-03-06 11:03:01 +03:00
komissarovyv ecf2d06cfa MSP-5013 add full variable support 2025-03-05 18:10:07 +03:00
komissarovyv d6a8f77610 MSP-5013 Update doc 2025-03-03 17:32:13 +03:00
komissarovyv be0dea3702 MSP-5013 Add variables swagger 2025-03-03 15:23:03 +03:00
komissarovyv 148327c74e MSP-5013 Handle error in rqlite response 2025-03-03 15:22:54 +03:00
komissarovyv eed94a4920 MSP-5013 Disable logs in rqlite client by default 2025-03-03 15:22:46 +03:00
komissarovyv e47646c953 MSP-5013 Update dependencies 2025-03-03 15:22:38 +03:00
Кузьмин Игорь Александрович 69567c4869 Upload New File 2024-12-27 13:42:14 +00:00
Кузьмин Игорь Александрович 7a00dd1794 Upload New File 2024-12-27 13:41:48 +00:00
komissarovyv 5fbfe1b039 Add logs 2024-12-12 13:52:08 +03:00
komissarovyv 8f9dc2048f Merge branch 'v3' into 'master'
Add service

See merge request isp/isp-config-service!5
2024-11-27 09:08:46 +00:00
komissarovyv ca70e4a038 Add service 2024-11-27 12:07:45 +03:00
komissarovyv 16d2701e26 Merge branch 'v3' into 'master'
V3

See merge request isp/isp-config-service!4
2024-11-26 16:07:20 +00:00
komissarovyv 005510e0a5 Return default addresses 2024-11-26 19:04:50 +03:00
komissarovyv 5ba6913d5f Add disco mode support 2024-11-26 16:29:46 +03:00
komissarovyv c3400ab6cd Change migrate tool port 2024-11-20 17:06:52 +03:00
komissarovyv 83355f8bbc Move migrate tool to container 2024-11-20 14:31:52 +03:00
komissarovyv 93f2a5ed50 Merge branch 'v3' into 'master'
V3

Closes MSP-4227 and MSP-4182

See merge request isp/isp-config-service!1
2024-11-15 10:02:52 +00:00
komissarovyv 120abaf6dd Update swagger 2024-11-01 19:04:31 +03:00
komissarovyv 2db855d360 Pass backend connection id 2024-11-01 18:58:16 +03:00
komissarovyv 7aa2805f4c Clean phantom backends 2024-11-01 18:41:17 +03:00
komissarovyv 1342f0dcf2 Close cluster client 2024-10-29 21:54:01 +03:00
komissarovyv 4f4fb5e6c7 Clean events only on leader 2024-10-29 18:11:36 +03:00
komissarovyv 68c8681a9b Keep only last N config versions 2024-10-29 17:41:03 +03:00
komissarovyv cb8c66849a Fix migration 2024-10-29 12:48:33 +03:00
komissarovyv 3f60267bdc Fix migration 2024-10-29 12:35:31 +03:00
komissarovyv 43a1a206d5 Bump dependencies 2024-10-29 12:04:52 +03:00
komissarovyv d4badbb8db Return prev module id 2024-10-28 22:17:10 +03:00
komissarovyv 5346030323 Fix maintaince proxy 2024-10-28 21:44:54 +03:00
komissarovyv c32c9d5eba Implement auth 2024-10-28 20:24:48 +03:00
komissarovyv 000a5aacdf Merge branch 'MSP-4227' into 'v3'
Resolve MSP-4227

See merge request isp/isp-config-service!3
2024-10-16 08:06:58 +00:00
Пучков Андрей Павлович 62815a7691 MSP-4227 Bump version to 3.0.2 2024-10-14 16:51:19 +03:00
Пучков Андрей Павлович e52c0f760c MSP-4227 fix module name 2024-10-14 16:51:05 +03:00
komissarovyv bfe2a7f817 Merge branch 'MSP-4182' into 'v3'
Resolve MSP-4182

See merge request isp/isp-config-service!2
2024-10-02 07:41:41 +00:00
Синельник Тимур Романович 99c0e1b17d MSP-4182 Bump version to 3.0.1 2024-10-02 10:22:17 +03:00
Синельник Тимур Романович e1547dbb94 MSP-4182 Add autoincrement to isp_config_service__event id field 2024-10-02 10:02:25 +03:00
komissarovyv 38c4295d0b Use match elements 2024-09-08 09:36:16 +03:00
komissarovyv 3a9e163c9e Bump rqlited 2024-09-07 10:51:30 +03:00
d1slike 0065c7c5a7 Add migration tool 2024-05-24 18:26:39 +03:00
d1slike fb21d43425 Use idempotent module id 2024-05-24 16:26:00 +03:00
d1slike 13c5ed92f4 Do not check is response is array (fix panic) 2024-05-24 13:25:18 +03:00
Кузьмин Игорь Александрович c3d626f074 Update config.yml 2024-05-20 15:40:03 +00:00
d1slike a6fa3eee8a Reimplement disovery service 2024-05-17 11:37:03 +03:00
d1slike bf024474d1 Implement missing endpoint 2024-05-16 20:31:18 +03:00
d1slike 2228e02770 Implement missing endpoint 2024-05-16 20:27:40 +03:00
d1slike d7d17e7f13 Add Dockerfile 2024-05-15 14:42:52 +03:00
d1slike 9bc9655c3d Add Dockerfile 2024-05-15 14:39:25 +03:00
d1slike 0320131d57 Add log level 2024-05-15 13:54:40 +03:00
d1slike 8275c01d21 Align to CI 2024-05-15 12:44:39 +03:00
d1slike 125013ba0a Implement acceptance test 2024-05-14 19:21:19 +03:00
d1slike 3b34468842 Improve logging 2024-05-14 14:34:13 +03:00
d1slike cddd3383e8 Implement api 2024-05-12 16:35:33 +03:00
d1slike c6148a1c1c Implement api 2024-05-08 18:45:21 +03:00
d1slike b2e34c00a4 Implement api 2024-05-08 15:40:14 +03:00
d1slike 80a99c425b Implement event stream 2024-05-07 20:16:44 +03:00
d1slike f90063cb03 Add go.sum 2024-05-06 20:18:15 +03:00
d1slike c4abdaa54b Implement lifecycle 2024-05-06 20:09:14 +03:00
d1slike 8a2a65d8ed Implement lifecycle 2024-05-06 09:43:11 +03:00
d1slike 2e23e882bb Implement lifecycle 2024-05-03 18:24:07 +03:00
d1slike 4e96b7a930 Reimplement 2024-05-03 17:46:22 +03:00
d1slike 5e72ec3864 Fix build 2024-04-24 17:56:48 +03:00
d1slike 05eb762273 Fix data 2024-04-24 17:34:03 +03:00
Кузьмин Игорь Александрович e2419e2c4b Update file README.md 2024-03-25 14:40:05 +00:00
Кузьмин Игорь Александрович 72afc94782 Update README.md 2024-03-25 14:04:00 +00:00
Кузьмин Игорь Александрович 02070b1db1 Update file README.md 2024-03-25 13:50:01 +00:00
Кузьмин Игорь Александрович 2fc6c7ba91 Delete Dockerfile.dit 2024-03-25 13:16:38 +00:00
Кузьмин Игорь Александрович c706d7932d Delete .gitlab-ci.yml 2024-03-25 13:16:28 +00:00
Кузьмин Игорь 62714cdfe1 Upload New File 2023-05-10 08:44:16 +00:00
Кузьмин Игорь a2c49ac39f Add new file 2023-05-03 10:11:43 +00:00
komissarovyv de55ea643c Merge branch 'deps' into 'master'
Deps

See merge request integration-system/isp-config-service!6
2022-12-09 09:09:04 +00:00
d1slike 5fb60e14b8 Ignore test 2022-12-08 16:35:34 +03:00
d1slike 02603cb018 Bump version 2022-12-08 16:22:25 +03:00
d1slike ffbff595d1 Remove ci 2022-12-08 16:18:01 +03:00
d1slike 989429824e Upgrade dependencies 2022-12-08 16:18:01 +03:00
Кузьмин Игорь a31e6080e2 Update default_remote_config.json 2022-11-29 11:56:09 +00:00
Кузьмин Игорь 90e05dfb4b Add new file 2022-11-29 11:51:08 +00:00
Мержанов Максим Владимирович 2af27ddb68 Merge branch 'remove_instance_uuid' into 'master'
remove instanceUuid

See merge request integration-system/isp-config-service!5
2021-05-26 14:08:58 +00:00
Maxim Merzhanov d004faa9e0 remove instanceUuid 2021-05-25 18:39:58 +03:00
Мержанов Максим Владимирович 45a4a23112 Merge branch '__deps' into 'master'
Update dependencies

See merge request integration-system/isp-config-service!4
2021-05-18 12:09:02 +00:00
Egor Kiryushchenko 1bb50f8175 Update dependencies 2021-05-17 16:22:07 +03:00
Мержанов Максим Владимирович 0cbfcab3f9 Merge branch 'bugfixes' into 'master'
Bugfixes

See merge request integration-system/isp-config-service!3
2021-05-14 09:36:25 +00:00
Maxim Merzhanov d4125963b2 update CHANGELOG.md 2021-05-13 17:35:22 +03:00
Maxim Merzhanov 2e33c2275c address review comments
- increase shutdown limit to 10/11 sec as it was set in isp-lib/bootstrap
- refactor
- update libs versions to released
2021-05-13 17:04:15 +03:00
Maxim Merzhanov a5b21198e0 cluster: reduce websocket read buffer from 10 to 1 2021-04-30 18:05:06 +03:00
Maxim Merzhanov e765cda3f9 add timeouts to all websocket emits 2021-04-30 13:09:52 +03:00
Maxim Merzhanov 5a91184d6c fix deadlock in cluster client 2021-04-22 19:25:35 +03:00
Maxim Merzhanov e2094296f4 fix race in test (TimeoutRetryer.Do needs to be fixed in isp-lib-test) 2021-04-22 19:16:26 +03:00
Maxim Merzhanov 777e856d00 fix potential error shadowing when leader apply log, but return nil instead of ApplyLogResponse 2021-04-21 17:04:48 +03:00
Maxim Merzhanov c3f419bbc5 update raft lib, improve raft logging 2021-04-21 16:47:59 +03:00
Maxim Merzhanov 52705f6982 fix hanging on graceful shutdown 2021-04-21 16:47:59 +03:00
Maxim Merzhanov a5134181be add integration test for multiple config updates 2021-04-19 10:25:43 +03:00
Maxim Merzhanov 79c801d493 add metric server 2021-04-05 18:42:54 +03:00
Maxim Merzhanov f9823d5303 fix version config store test 2021-04-01 18:55:08 +03:00
Maxim Merzhanov 8339591b27 fix leader address race on leader disconnect 2021-04-01 18:36:12 +03:00
Maxim Merzhanov 17a6e3186d fix a couple of data races 2021-04-01 16:54:42 +03:00
Maxim Merzhanov 213bad9722 increase default version config count to 15 2021-04-01 16:47:44 +03:00
Maxim Merzhanov ef33bd9fd2 up test lib, fix grpc awaiting 2021-03-10 11:41:36 +03:00
Мержанов Максим Владимирович 123de3d452 Merge branch '__deps' into 'master'
Update dependencies

See merge request integration-system/isp-config-service!2
2021-01-26 19:21:26 +03:00
Egor Kiryushchenko 6591bff728 Update dependencies 2021-01-26 13:52:14 +03:00
Maxim Merzhanov 88c0779aa2 fix marshaling body of ERROR_CONNECTION event 2021-01-15 16:05:47 +03:00
Максим Мержанов 95adcb117c Merge branch '__deps' into 'master'
Update dependencies

See merge request integration-system/isp-config-service!14
2020-11-24 16:56:15 +03:00
Egor Kiryushchenko 372636f43b Update dependencies 2020-11-24 09:42:16 +03:00
Maxim Merzhanov 54dae1ab2b fix test 2020-11-23 10:47:08 +03:00
Egor Kiryushchenko f0f50a8507 fix lint 2020-11-20 16:46:46 +03:00
Egor Kiryushchenko c3d0d5be4c Update dependencies 2020-11-19 10:29:59 +03:00
DeniskaRediska 929132743c up version 2020-10-22 15:51:52 +03:00
DeniskaRediska 6643e8937c add db pass part 2020-10-22 15:49:25 +03:00
Максим Мержанов 08b4ee461e Merge branch 'api_ext_branch' into 'master'
add valid property to method `/config/get_configs_by_module_id`

See merge request integration-system/isp-config-service!6
2020-09-28 16:08:21 +03:00
Рябов Владислав Олегович ae501969bf add valid property to method /config/get_configs_by_module_id 2020-09-28 16:08:21 +03:00
Максим Мержанов c29ed6d41e Merge branch 'api_ext_branch' into 'master'
add new config methods

See merge request integration-system/isp-config-service!5
2020-09-24 22:08:50 +03:00
Рябов Владислав Олегович 1c28c895b5 add new config methods 2020-09-24 22:08:50 +03:00
d1slike d9c32437c9 remove utc 2020-07-15 17:37:22 +03:00
d1slike 0429bed9e3 up version 2020-07-15 17:33:06 +03:00
DeniskaRediska 8bdc36a302 up created_at for version_config 2020-07-10 19:48:09 +03:00
DeniskaRediska a3576cc3f4 add created_at for version_config 2020-07-10 19:38:35 +03:00
DeniskaRediska 713db0aa4c reverse version config 2020-07-10 19:26:35 +03:00
d1slike 95aae06a41 downgrade version 2020-06-09 14:42:36 +03:00
DeniskaRediska 31a4a6f5b8 ref 2020-06-09 13:55:39 +03:00
DeniskaRediska 1c66729974 fix generate version id 2020-06-09 13:41:56 +03:00
d1slike 6387947b22 small ref 2020-06-09 12:57:07 +03:00
DeniskaRediska 3a8469c5a9 fix test 2020-06-08 20:44:54 +03:00
DeniskaRediska 44715591ef fix lint 2020-06-08 20:14:50 +03:00
DeniskaRediska ceb9d71a1a fix lint 2020-06-08 20:11:53 +03:00
DeniskaRediska 15ad05277b add config version 2020-06-08 18:39:25 +03:00
d1slike 14c5b0a678 fix broadcasting config on activating and upserting configs 2020-06-03 15:43:05 +03:00
d1slike c95964fa3c get module dependencies from first connected backend 2020-06-03 14:35:11 +03:00
d1slike a46f2cee34 Merge remote-tracking branch 'origin/required_modules' into feat_broadcasting
# Conflicts:
#	go.mod
#	go.sum
2020-06-03 14:10:14 +03:00
d1slike 1764ce9a30 Merge remote-tracking branch 'origin/add_conf_version' into feat_broadcasting
# Conflicts:
#	go.mod
#	go.sum
2020-06-03 14:09:57 +03:00
DeniskaRediska 384fa0417a add config version 2020-06-03 11:33:52 +03:00
Maxim Merzhanov 97ba1050a7 appease linter 2020-06-02 18:19:33 +03:00
Maxim Merzhanov 628c506e85 list required modules in get_modules_info method 2020-06-02 17:06:02 +03:00
d1slike 9226796463 broadcasting to modules 2020-06-01 19:35:22 +03:00
Maxim Merzhanov 83176ba878 update doc 2020-03-24 13:24:16 +03:00
Maxim Merzhanov 94cb067214 refactor sync apply helpers 2020-03-23 18:31:47 +03:00
Maxim Merzhanov b56b6e0e42 update isp-etp lib 2020-03-23 17:51:30 +03:00
Maxim Merzhanov 28aa3eae33 add module/broadcast_event method 2020-03-23 16:49:21 +03:00
Maxim Merzhanov 96dee8dee3 stringify cluster commands in log 2020-03-23 12:49:34 +03:00
Maxim Merzhanov 400410c449 up version 2020-03-23 12:17:37 +03:00
Maxim Merzhanov ab08abb3f6 fix integration test 2020-03-23 11:50:04 +03:00
Maxim Merzhanov 01e32537a8 update docs 2020-03-23 11:21:23 +03:00
Maxim Merzhanov 652d1c8c4f update isp-lib and go-pg 2020-03-23 11:16:30 +03:00
169 changed files with 12555 additions and 6229 deletions

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
name: Create and publish a Docker image
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
APP_NAME: ${{ github.event.repository.name }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version from tag
id: version_reader
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_reader.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ steps.version_reader.outputs.version }}
build-args: |
app_name=${{ env.APP_NAME }}
version=${{ steps.version_reader.outputs.version }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
+9 -3
View File
@@ -9,8 +9,8 @@
.idea/**/tasks.xml
.idea/dictionaries
*.iml
config_service
config-service
convert_service
convert-service
# Sensitive or high-churn files:
.idea/**/dataSources/
@@ -67,5 +67,11 @@ fabric.properties
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
/node_modules/
/vendor/
/node_modules/
package.json
yarn.lock
conf/config_dev.yml
.DS_Store
+3
View File
@@ -0,0 +1,3 @@
include:
- project: '$CI_PROJECT_PATH'
file: '/ci-isp-go-service.yml'
+75 -36
View File
@@ -1,39 +1,78 @@
version: "2"
run:
tests: false
allow-parallel-runners: true
linters:
enable-all: true
default: all
disable:
- goimports
- depguard # не используется
- gochecknoinits
- gochecknoglobals
- wsl
- gocognit
- godox # находит тудушки, не нужно
- golint # подумать, может вернуть
- stylecheck # подумать, может вернуть
linters-settings:
maligned:
suggest-new: true
lll:
line-length: 140
tab-width: 1
funlen:
lines: 80
statements: 40
prealloc:
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
# True by default.
simple: true
range-loops: true # Report preallocation suggestions on range loops, true by default
for-loops: true # Report preallocation suggestions on for loops, false by default
gocritic:
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
enabled-tags:
- diagnostic
- performance
disabled-checks:
- hugeParam # в данном проекте не нужен
- contextcheck # не имеет смысла
- depguard # не всегда имеет смысл
- dupword # не имеет смысла
- exhaustruct # не имеет смысла
- exhaustruct_v5 # не имеет смысла
- goconst # не всегда имеет смысл
- godot # не актуально для swagger
- godox # не позволяет оставлять todo
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
- nlreturn # не всегда имеет смысл
- nolintlint # Goland все равно форматирует с отступом
- perfsprint # мнимая производительность в угоду читаемости
- tagalign # не всегда имеет смысл
- varnamelen # очень индивидуально (db)
- wsl # расставление пробелов очень индивидуально
- wsl_v5 # расставление пробелов очень индивидуально
- godoclint # ругается на // nolint, не удобно
- prealloc # слишком аггресивный, в большинстве случаев не требуется
- gomoddirectives # в проекте осознанно захардкожены версии зависимостей
settings:
cyclop:
max-complexity: 15 # по умолчанию 10 мало
funlen:
lines: 80
lll:
line-length: 150
revive:
rules:
- name: var-naming # отключаем Id -> ID
disabled: true
staticcheck:
checks: # отключаем Id -> ID
- -ST1000
- -ST1016
- -ST1020
- -ST1021
- -ST1022
testifylint:
disable:
- compares
- equal-values
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- wrapcheck
path: controller # достаточное кол-во контекста на уровне контроллеров
- linters:
- wrapcheck
path: transaction # транзакции прозрачны
- linters:
- unqueryvet
- prealloc
path: ".*_test\\.go$"
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
+1 -1
View File
@@ -1 +1 @@
2.2.0
3.12.1
-36
View File
@@ -1,36 +0,0 @@
### v2.2.0
* migrate to go modules
* add linter, refactor
### v2.1.3
* improved logging
### v2.1.2
* leader ws client ConnectionReadLimit is now configured by WS.WsConnectionReadLimitKB config param and defaults to 4 MB
### v2.1.1
* update to new endpoint descriptor struct with extra fields introduced in isp-lib v2.1.0
### v2.1.0
* fix panic type casting in shapshot
* create empty default config now
* add method `/module/get_by_name` to fetch module object by name
### v2.0.3
* fix data race when applyCommandOnLeader in websocket handler
* update dependencies
### v2.0.2
* fix raft server address announcing (serverId == serverAddress == cluster.outerAddress)
### v2.0.1
* fix nil pointer dereference in repositories
* increase default websocket ConnectionReadLimit to 4 MB, add to configuration
### v2.0.0
* full rewrite to support cluster mode
* change websocket protocol from socketio to etp
### v1.1.0
* update libs
* default config handling
+42
View File
@@ -0,0 +1,42 @@
FROM golang:1.27-alpine AS builder
WORKDIR /build
ARG version
ENV version_env=$version
ARG app_name
ENV app_name_env=$app_name
COPY . .
RUN apk update && apk upgrade && apk add --no-cache gcc musl-dev
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
WORKDIR cmd/migrate
#RUN CGO_ENABLED=1 go build -o /migrate .
FROM alpine:3.23
RUN apk add --no-cache tzdata
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
RUN echo "Europe/Moscow" > /etc/timezone
#COPY --from=builder migrate /migrate/migrate
COPY cmd/migrate/config.yml /migrate/config.yml
RUN chmod 666 /migrate/config.yml
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
USER appuser
WORKDIR /app
ARG app_name
ENV app_name_env=$app_name
COPY --from=builder main /app/$app_name_env
COPY /conf/config.yml /app/config.yml
COPY /conf/default_remote_config.json* /app/default_remote_config.json
COPY /migrations /app/migrations
ENTRYPOINT /app/$app_name_env
+52
View File
@@ -0,0 +1,52 @@
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.27 git
WORKDIR /build
ARG version
ENV version_env=$version
ARG app_name
ENV app_name_env=$app_name
COPY . .
ENV GOPROXY=https://repo-mirror.mos.ru/repository/go-public
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
WORKDIR cmd/migrate
RUN CGO_ENABLED=1 go build -o /migrate .
FROM dockerhub.mos.ru/mosos/arbat:15.5
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
RUN echo "Europe/Moscow" > /etc/timezone
COPY --from=builder migrate /migrate/migrate
COPY cmd/migrate/config.yml /migrate/config.yml
RUN chmod 666 /migrate/config.yml
ARG UID=10001
RUN useradd \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
--user-group \
appuser
RUN mkdir -p /app/data
RUN chown appuser:appuser /app/data
VOLUME /app/data
USER appuser
WORKDIR /app
ARG app_name
ENV app_name_env=$app_name
COPY --from=builder main /app/$app_name_env
COPY /conf/config.yml /app/config.yml
COPY /conf/default_remote_config.json* /app/default_remote_config.json
COPY /migrations /app/migrations
ENTRYPOINT /app/$app_name_env
COPY /conf/config.yml /app/config.yml
COPY /conf/default_remote_config.json* /app/default_remote_config.json
COPY /migrations /app/migrations
ENTRYPOINT /app/$app_name_env
-674
View File
@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+2
View File
@@ -0,0 +1,2 @@
# isp-config-service
+214
View File
@@ -0,0 +1,214 @@
package assembly
import (
"context"
"net/http"
"net/http/httputil"
"net/url"
"time"
"isp-config-service/conf"
"isp-config-service/service/module/backend"
"isp-config-service/service/variable"
httpEndpoint "github.com/txix-open/isp-kit/http/endpoint"
"github.com/txix-open/isp-kit/http/endpoint/httplog"
"isp-config-service/controller"
"isp-config-service/controller/api"
"isp-config-service/repository"
"isp-config-service/routes"
apisvs "isp-config-service/service/api"
"isp-config-service/service/event"
"isp-config-service/service/metrics"
"isp-config-service/service/module"
"isp-config-service/service/rqlite/db"
"isp-config-service/service/subscription"
"github.com/txix-open/etp/v4"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/endpoint"
"github.com/txix-open/isp-kit/log"
"github.com/txix-open/isp-kit/worker"
)
const (
wsReadLimit = 4 * 1024 * 1024
handleEventsInterval = 500 * time.Millisecond
cleanEventInterval = 60 * time.Second
cleanPhantomBackendsInterval = 5 * time.Minute
eventTtl = 60 * time.Second
)
type LocalConfig struct {
Local conf.Local
RqliteAddress string
}
type Locator struct {
db db.DB
cfg LocalConfig
leaderChecker LeaderChecker
logger log.Logger
}
type LeaderChecker interface {
IsLeader() bool
}
type OwnBackendsCleaner interface {
DeleteOwnBackends(ctx context.Context)
}
func NewLocator(
db db.DB,
leaderChecker LeaderChecker,
cfg LocalConfig,
logger log.Logger,
) Locator {
return Locator{
db: db,
leaderChecker: leaderChecker,
cfg: cfg,
logger: logger,
}
}
type Config struct {
GrpcMux *grpc.Mux
HttpMux http.Handler
MetricsAdHandler http.Handler
EtpSrv *etp.Server
HandleEventWorker *worker.Worker
CleanEventWorker *worker.Worker
CleanPhantomBackendWorker *worker.Worker
CleanBackupsWorker *worker.Worker
OwnBackendsCleaner OwnBackendsCleaner
}
//nolint:funlen
func (l Locator) Config() *Config {
moduleRepo := repository.NewModule(l.db)
backendRepo := repository.NewBackend(l.db)
eventRepo := repository.NewEvent(l.db)
configRepo := repository.NewConfig(l.db)
configSchemaRepo := repository.NewConfigSchema(l.db)
configHistoryRepo := repository.NewConfigHistory(l.db)
variableRepo := repository.NewVariable(l.db)
variableService := variable.NewService(variableRepo, configRepo, eventRepo)
variableController := api.NewVariable(variableService)
etpSrv := etp.NewServer(
etp.WithServerReadLimit(wsReadLimit),
etp.WithServerAcceptOptions(&etp.AcceptOptions{
InsecureSkipVerify: true,
}),
)
emitter := module.NewEmitter(l.logger)
subscriptionService := subscription.NewService(
moduleRepo,
backendRepo,
configRepo,
etpSrv.Rooms(),
emitter,
variableService,
l.logger,
)
backendService := backend.NewBackend(
backendRepo,
eventRepo,
l.cfg.Local.Rqlite.NodeId,
etpSrv.Rooms(),
l.logger,
)
cleanPhantomBackendJob := backend.NewCleaner(backendService, l.logger)
cleanPhantomBackendWorker := worker.New(cleanPhantomBackendJob, worker.WithInterval(cleanPhantomBackendsInterval))
moduleService := module.NewService(
moduleRepo,
backendService,
configRepo,
configSchemaRepo,
subscriptionService,
emitter,
variableService,
l.logger,
)
moduleController := controller.NewModule(moduleService, l.logger)
configHistoryApiService := apisvs.NewConfigHistory(configRepo, moduleRepo, configHistoryRepo,
l.cfg.Local.KeepConfigVersions, l.logger)
configHistoryController := api.NewConfigHistory(configHistoryApiService)
moduleApiService := apisvs.NewModule(moduleRepo, backendRepo, configSchemaRepo)
moduleApiController := api.NewModule(moduleApiService)
configApiService := apisvs.NewConfig(
configRepo,
moduleRepo,
configSchemaRepo,
eventRepo,
configHistoryApiService,
variableService,
l.logger,
)
configApiController := api.NewConfig(configApiService)
configSchemaApiService := apisvs.NewConfigSchema(configSchemaRepo, moduleRepo)
configSchemaController := api.NewConfigSchema(configSchemaApiService)
controllers := routes.Controllers{
Module: moduleController,
ModuleApi: moduleApiController,
ConfigApi: configApiController,
ConfigHistoryApi: configHistoryController,
ConfigSchemaApi: configSchemaController,
VariableApi: variableController,
}
mapper := endpoint.DefaultWrapper(l.logger)
grpcMux := routes.GrpcHandler(mapper, controllers)
routes.BindEtp(etpSrv, controllers, l.logger)
rqliteUrl, err := url.Parse(l.cfg.RqliteAddress)
if err != nil {
panic(err)
}
rqliteProxy := httputil.NewSingleHostReverseProxy(rqliteUrl)
rqliteBackupUrl, err := url.Parse(l.cfg.RqliteAddress + "/db/backup")
if err != nil {
panic(err)
}
rqliteBackupProxy := httputil.NewSingleHostReverseProxy(rqliteBackupUrl)
httpMux := routes.HttpHandler(etpSrv, l.cfg.Local, rqliteProxy, rqliteBackupProxy)
eventHandler := event.NewHandler(subscriptionService, l.logger)
handleEventJob := event.NewWorker(eventRepo, eventHandler, l.logger)
handleEventWorker := worker.New(handleEventJob, worker.WithInterval(handleEventsInterval))
cleanerJob := event.NewCleaner(eventRepo, l.leaderChecker, eventTtl, l.logger)
cleanEventWorker := worker.New(cleanerJob, worker.WithInterval(cleanEventInterval))
cleanBackupsJob := event.NewBackupCleaner(l.leaderChecker, l.cfg.Local.Backup, l.logger)
cleanBackupsWorker := worker.New(cleanBackupsJob, worker.WithInterval(l.cfg.Local.Backup.ClearInterval))
metricsSvc := metrics.New(backendRepo)
metricsController := controller.NewMetrics(metricsSvc)
httpWrapper := httpEndpoint.DefaultWrapper(l.logger, httplog.Log(l.logger, false))
return &Config{
GrpcMux: grpcMux,
EtpSrv: etpSrv,
HttpMux: httpMux,
MetricsAdHandler: httpWrapper.Endpoint(metricsController.Autodiscovery),
HandleEventWorker: handleEventWorker,
CleanEventWorker: cleanEventWorker,
CleanPhantomBackendWorker: cleanPhantomBackendWorker,
CleanBackupsWorker: cleanBackupsWorker,
OwnBackendsCleaner: backendService,
}
}
+75
View File
@@ -0,0 +1,75 @@
### v3.12.1
* Обновление ограничений конфигурации: в параметре `KeepConfigVersions` допустимо значение `0`
### v3.12.0
* Обновлен isp-kit до v1.76.0: подтянуты транзитивные зависимости (grpc v1.85.0, otel v1.47.0, goose v3.30.1, prometheus/client_golang v1.25.0), сервис собирается на Go 1.27
* Добавлена колонка `module_leader_mode` в таблицу `isp_config_service__backend` — режим выбора лидера, объявленный инстансом в `MODULE:READY`. Любое значение, кроме `REQUEST_ELECTION` (в том числе зарезервированные `IM_LEADER` и `IM_FOLLOWER`), нормализуется в пустое значение с логом уровня `warn`, рукопожатие при этом не отклоняется
* Для модулей, объявивших `REQUEST_ELECTION`, список адресов в событии `{module}_MODULE_CONNECTED` и карта маршрутов в `CONFIG:SEND_ROUTES_*` сузены до одного инстанса — лидера, а когда инстансов не осталось — до пустого списка. Модули без election не затронуты
* Лидер выводится из подключённых инстансов (минимум по `created_at`, тай-брейк по `ws_connection_id`) и нигде не хранится: ни новой таблицы, ни колонки «лидер/не лидер» нет
* Расширен ответ по `/module/get_modules_info` и `/routing/get_routes`: поле `isModuleLeader` в `domain.Connection`. `/routing/get_routes` остался полным — все инстансы всех модулей; сужение касается только событий, уходящих модулям
* Сужение видно в логах: публикация списка адресов модуля с election пишет `info` с адресом лидера, пересборка карты маршрутов — одной строкой список опубликованных лидеров (`модуль=адрес` через запятую). Модули без election по-прежнему не шумят
### v3.11.1
* Исправлено: при сохранении конфига с многократным использованием одной переменной через `_Var()` терялись все связи переменной с конфигами (конфликт PK в транзакции ссылок)
* Ошибки statement в rqlite-транзакциях больше не игнорируются молча, возвращаются как ошибка запроса
* Отключены линтеры `exhaustruct_v5`, `goconst`
### v3.11.0
* Добавлены `admin` permission к endpoint'ам
### v3.10.0
* событие `MODULE_READY` теперь может быть обработано несколько раз, обновляя полученные данные об инстансе модуля
### v3.9.3
* обновлены зависимости
### v3.9.2
* Обновлен isp-kit
### v3.9.1
* Версия go 1.26
* Добавлен эндпоинт `/module/get_required_modules` для получения списка модулей, от которых зависит модуль, отправивший запрос
### v3.9.0
* Обновлены зависимости
* Добавлено поле `transport` в таблицу `isp_config_service__backend`
* Расширен ответ по `/routing/get_routes` и `/module/get_modules_info`:
* Добавлено поле `httpMethod` в `domain.EndpointDescriptor`
* Добавлено поле `transport` в `domain.Connection`
### v3.8.1
* исправлена миграция для `config-history`
### v3.8.0
* Добавлен новый endpoint `config/schema/update_by_module_name` для обновления схемы модуля по его названию
## v3.7.0
* добавлены rqlite-автобэкапы и прокси-эндпоинт `/backup` для создания резервных копий
* изменен таймаут ожидания лидера с 30 до 180 секунд
* исправлены потенциальные race conditions
* добавлен параметр периодической оптимизации sqlite `AutoOptimizeInterval: 23h`
* обновлены зависимости
## v3.6.0
* добавлен новый эндпоинт `config/config/purge_versions` для удаления старых версий всех конфигураций модуля, за исключением n последних
* обновлены зависимости
## v3.5.0
* обновлены зависимости
## v3.4.1
* исправлена проблема при которой не отвязывалась единственная переменная от конфигурации
* исправлена проблема при которой версия конфига сохраняется с некорректным временем (бралось текущее время, а не время обновления конфига)
* обновлены зависимости
## v3.4.0
* добавлено поле `metrics_autodiscovery` в таблицу `isp_config_service__backend`
* реализован внутренний метод `/internal/metrics/autodiscovery`, формирующий конфигурацию для `HTTP-based service discovery` механизма `Prometheus`
* обновлены зависимости
## v3.3.1
* добавлен скрипт для сборки и публикации образа в `GitHub Contaier Registry`
* обновлены зависимости
## v3.3.0
* обновлены зависимости
* добавлен новый эндпоинт `config/config/update_config_name` для изменения названия конфигурации без повышения версии и рассылки события
* теперь эндпоинт `config/config/get_all_version` первым элементом возвращает актуальную версию конфигурации
* добавлен новый эндпоинт `/config/config/sync` для синхронизации актуальной конфигурации пришедшего модуля
* добавлена оптимизация в `config/config/create_update_config`: если в запросе `data` и `name` не отличаются от текущей версии конфигурации, то событие логируется на уровне `info` без обновления конфигурации; возвращается текущая версия конфигурации
## v3.2.0
* добавлена поддержка переменных в конфигурациях
## v3.1.2
* возвращена поддержка rqlite.DiscoMode `dns` и `dns-srv`
* добавлена поддержка работы в `kubernetes` c autodiscovery
## v3.1.1
* инструмент миграции перенесен внутрь контейнера
## v3.1.0
* добавлено возможность анонсировать несколько бекендов с одинаковыми адресами
* реализован механизм поиска и очистки фантомных бекендов (те который отключились, но остались висеть в таблице маршрутизации)
* добавлена очистка таблицы маршрутизации в момент отключения самого модуля
## v3.0.2
* Новая реализация модуля на базе rqlite
-202
View File
@@ -1,202 +0,0 @@
package cluster
import (
"errors"
"sync"
"time"
"github.com/integration-system/isp-lib/v2/structure"
"github.com/integration-system/isp-lib/v2/utils"
log "github.com/integration-system/isp-log"
jsoniter "github.com/json-iterator/go"
"isp-config-service/codes"
"isp-config-service/entity"
"isp-config-service/raft"
"isp-config-service/store/state"
)
var (
ErrNoLeader = errors.New("no leader in cluster")
ErrLeaderClientNotInitialized = errors.New("leader client not initialized")
ErrNotLeader = errors.New("node is not a leader")
json = jsoniter.ConfigFastest
)
const (
leaderConnectionTimeout = 3 * time.Second
defaultApplyTimeout = 3 * time.Second
)
type Client struct {
r *raft.Raft
leaderMu sync.RWMutex
leaderState leaderState
leaderClient *SocketLeaderClient
declaration structure.BackendDeclaration
onClientDisconnect func(string)
}
func (client *Client) Shutdown() error {
client.leaderMu.Lock()
defer client.leaderMu.Unlock()
if client.leaderClient != nil {
client.leaderClient.Close()
client.leaderClient = nil
}
return client.r.GracefulShutdown()
}
func (client *Client) IsLeader() bool {
client.leaderMu.RLock()
defer client.leaderMu.RUnlock()
return client.leaderState.isLeader
}
func (client *Client) SyncApply(command []byte) (*ApplyLogResponse, error) {
client.leaderMu.RLock()
defer client.leaderMu.RUnlock()
if !client.leaderState.leaderElected {
return nil, ErrNoLeader
}
if client.leaderState.isLeader {
apply, err := client.r.SyncApply(command)
if err != nil {
return nil, err
}
logResponse := apply.(ApplyLogResponse)
return &logResponse, err
} else {
if client.leaderClient == nil {
return nil, ErrLeaderClientNotInitialized
}
response, err := client.leaderClient.Ack(command, defaultApplyTimeout)
if err != nil {
return nil, err
}
var logResponse ApplyLogResponse
err = json.Unmarshal(response, &logResponse)
if err != nil {
return nil, err
}
return &logResponse, nil
}
}
func (client *Client) SyncApplyOnLeader(command []byte) (*ApplyLogResponse, error) {
client.leaderMu.RLock()
defer client.leaderMu.RUnlock()
if !client.leaderState.isLeader {
return nil, ErrNotLeader
}
apply, err := client.r.SyncApply(command)
if err != nil {
return nil, err
}
logResponse := apply.(ApplyLogResponse)
return &logResponse, err
}
func (client *Client) listenLeader() {
for n := range client.r.LeaderCh() {
client.leaderMu.Lock()
log.WithMetadata(map[string]interface{}{
"leader_elected": n.LeaderElected,
"current_leader": n.CurrentLeaderAddress,
"is_leader": n.IsLeader,
}).Info(codes.LeaderStateChanged, "leader state changed")
if client.leaderClient != nil {
log.Debugf(0, "close previous leader ws connection %s", client.leaderState.leaderAddr)
client.leaderClient.Close()
client.leaderClient = nil
}
if n.LeaderElected && !n.IsLeader {
leaderClient := NewSocketLeaderClient(n.CurrentLeaderAddress, func() {
client.onClientDisconnect(client.leaderState.leaderAddr)
})
if err := leaderClient.Dial(leaderConnectionTimeout); err != nil {
log.Fatalf(codes.LeaderClientConnectionError, "could not connect to leader: %v", err)
continue
}
client.leaderClient = leaderClient
log.Info(codes.SendDeclarationToLeader, "sending declaration to leader through websocket")
go client.declareMyselfToLeader(leaderClient)
} else if n.LeaderElected && n.IsLeader {
go client.declareMyselfToCluster()
}
client.leaderState = leaderState{
leaderElected: n.LeaderElected,
isLeader: n.IsLeader,
leaderAddr: n.CurrentLeaderAddress,
}
client.leaderMu.Unlock()
}
}
func (client *Client) declareMyselfToLeader(leaderClient *SocketLeaderClient) {
response, err := leaderClient.SendDeclaration(client.declaration, defaultApplyTimeout)
if err != nil {
log.Warnf(codes.SendDeclarationToLeader, "send declaration to leader. err: %v", err)
} else if response != utils.WsOkResponse {
log.Warnf(codes.SendDeclarationToLeader, "send declaration to leader. response: %s", response)
}
}
// used when a leader need to declare himself to a cluster
func (client *Client) declareMyselfToCluster() {
now := state.GenerateDate()
module := entity.Module{
Id: state.GenerateId(),
Name: client.declaration.ModuleName,
CreatedAt: now,
LastConnectedAt: now,
}
command := PrepareModuleConnectedCommand(module)
syncApplyCommand(client, command, "ModuleConnectedCommand")
declarationCommand := PrepareUpdateBackendDeclarationCommand(client.declaration)
syncApplyCommand(client, declarationCommand, "UpdateBackendDeclarationCommand")
}
type leaderState struct {
leaderElected bool
isLeader bool
leaderAddr string
}
func NewRaftClusterClient(r *raft.Raft, declaration structure.BackendDeclaration, onLeaderDisconnect func(string)) *Client {
client := &Client{
r: r,
declaration: declaration,
leaderState: leaderState{},
onClientDisconnect: onLeaderDisconnect,
}
go client.listenLeader()
return client
}
func syncApplyCommand(clusterClient *Client, command []byte, commandName string) {
applyLogResponse, err := clusterClient.SyncApply(command)
if err != nil {
log.WithMetadata(map[string]interface{}{
"command": string(command),
"commandName": commandName,
}).Warnf(codes.SyncApplyError, "announce myself. apply command: %v", err)
}
if applyLogResponse != nil && applyLogResponse.ApplyError != "" {
log.WithMetadata(map[string]interface{}{
"result": string(applyLogResponse.Result),
"applyError": applyLogResponse.ApplyError,
"commandName": commandName,
}).Warnf(codes.SyncApplyError, "announce myself. apply command")
}
}
-92
View File
@@ -1,92 +0,0 @@
package cluster
import (
"bytes"
"encoding/binary"
"time"
"github.com/integration-system/isp-lib/v2/structure"
log "github.com/integration-system/isp-log"
"isp-config-service/codes"
"isp-config-service/entity"
)
const (
ApplyCommandEvent = "CONFIG_CLUSTER:APPLY_COMMAND"
CommandSizeBytes = 8
ClusterParam = "cluster"
)
const (
_ = iota
UpdateBackendDeclarationCommand
DeleteBackendDeclarationCommand
UpdateConfigSchemaCommand
ModuleConnectedCommand
ModuleDisconnectedCommand
DeleteModulesCommand
ActivateConfigCommand
DeleteConfigsCommand
UpsertConfigCommand
DeleteCommonConfigsCommand
UpsertCommonConfigCommand
)
func PrepareUpdateBackendDeclarationCommand(backend structure.BackendDeclaration) []byte {
return prepareCommand(UpdateBackendDeclarationCommand, backend)
}
func PrepareDeleteBackendDeclarationCommand(backend structure.BackendDeclaration) []byte {
return prepareCommand(DeleteBackendDeclarationCommand, backend)
}
func PrepareModuleConnectedCommand(module entity.Module) []byte {
return prepareCommand(ModuleConnectedCommand, module)
}
func PrepareModuleDisconnectedCommand(module entity.Module) []byte {
return prepareCommand(ModuleDisconnectedCommand, module)
}
func PrepareDeleteModulesCommand(ids []string) []byte {
return prepareCommand(DeleteModulesCommand, DeleteModules{Ids: ids})
}
func PrepareActivateConfigCommand(configID string, date time.Time) []byte {
return prepareCommand(ActivateConfigCommand, ActivateConfig{ConfigId: configID, Date: date})
}
func PrepareDeleteConfigsCommand(ids []string) []byte {
return prepareCommand(DeleteConfigsCommand, DeleteModules{Ids: ids})
}
func PrepareUpsertConfigCommand(config UpsertConfig) []byte {
return prepareCommand(UpsertConfigCommand, config)
}
func PrepareUpdateConfigSchemaCommand(schema entity.ConfigSchema) []byte {
return prepareCommand(UpdateConfigSchemaCommand, schema)
}
func PrepareDeleteCommonConfigsCommand(id string) []byte {
return prepareCommand(DeleteCommonConfigsCommand, DeleteCommonConfig{Id: id})
}
func PrepareUpsertCommonConfigCommand(config UpsertCommonConfig) []byte {
return prepareCommand(UpsertCommonConfigCommand, config)
}
func prepareCommand(command uint64, payload interface{}) []byte {
cmd := make([]byte, 8)
binary.BigEndian.PutUint64(cmd, command)
buf := bytes.NewBuffer(cmd)
err := json.NewEncoder(buf).Encode(payload)
if err != nil {
log.Fatalf(codes.PrepareLogCommandError, "prepare log command: %v", err)
}
return buf.Bytes()
}
-65
View File
@@ -1,65 +0,0 @@
package cluster
import (
json2 "encoding/json"
"fmt"
"google.golang.org/grpc/codes"
"isp-config-service/entity"
"time"
)
type ApplyLogResponse struct {
ApplyError string
Result json2.RawMessage
}
func (a ApplyLogResponse) Error() string {
return a.ApplyError
}
type DeleteModules struct {
Ids []string
}
type ActivateConfig struct {
ConfigId string
Date time.Time
}
type UpsertConfig struct {
Config entity.Config
Create bool
Unsafe bool
}
type DeleteConfigs struct {
Ids []string
}
type DeleteCommonConfig struct {
Id string
}
type UpsertCommonConfig struct {
Config entity.CommonConfig
Create bool
}
type ResponseWithError struct {
Response interface{}
Error string
ErrorCode codes.Code
}
func NewResponseErrorf(code codes.Code, format string, args ...interface{}) ResponseWithError {
return ResponseWithError{
Error: fmt.Sprintf(format, args...),
ErrorCode: code,
}
}
func NewResponse(value interface{}) ResponseWithError {
return ResponseWithError{
Response: value,
}
}
-115
View File
@@ -1,115 +0,0 @@
package cluster
import (
"context"
"fmt"
"net"
"net/http"
"net/url"
"time"
"github.com/cenkalti/backoff/v4"
etp "github.com/integration-system/isp-etp-go/v2/client"
"github.com/integration-system/isp-lib/v2/config"
"github.com/integration-system/isp-lib/v2/structure"
"github.com/integration-system/isp-lib/v2/utils"
log "github.com/integration-system/isp-log"
"isp-config-service/codes"
"isp-config-service/conf"
)
var (
// Set from config in main
WsConnectionReadLimit int64
)
type SocketLeaderClient struct {
client etp.Client
url string
globalCtx context.Context
cancel context.CancelFunc
}
func (c *SocketLeaderClient) Ack(data []byte, timeout time.Duration) ([]byte, error) {
ctx, cancel := context.WithTimeout(c.globalCtx, timeout)
defer cancel()
response, err := c.client.EmitWithAck(ctx, ApplyCommandEvent, data)
return response, err
}
func (c *SocketLeaderClient) SendDeclaration(backend structure.BackendDeclaration, timeout time.Duration) (string, error) {
data, err := json.Marshal(backend)
if err != nil {
return "", err
}
ctx, cancel := context.WithTimeout(c.globalCtx, timeout)
defer cancel()
response, err := c.client.EmitWithAck(ctx, utils.ModuleReady, data)
return string(response), err
}
func (c *SocketLeaderClient) Dial(timeout time.Duration) error {
backOff := backoff.NewExponentialBackOff()
backOff.MaxElapsedTime = timeout
bf := backoff.WithContext(backOff, c.globalCtx)
dial := func() error {
return c.client.Dial(c.globalCtx, c.url)
}
return backoff.Retry(dial, bf)
}
func (c *SocketLeaderClient) Close() {
c.cancel()
err := c.client.Close()
if err != nil {
log.Warnf(codes.LeaderClientConnectionError, "leader client close err: %v", err)
}
log.Debug(0, "leader client connection closed")
}
func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *SocketLeaderClient {
etpConfig := etp.Config{
HttpClient: http.DefaultClient,
ConnectionReadLimit: WsConnectionReadLimit,
}
client := etp.NewClient(etpConfig)
leaderClient := &SocketLeaderClient{
client: client,
url: getURL(address),
}
ctx, cancel := context.WithCancel(context.Background())
leaderClient.globalCtx = ctx
leaderClient.cancel = cancel
leaderClient.client.OnDisconnect(func(err error) {
log.WithMetadata(map[string]interface{}{
"leaderAddr": address,
}).Warn(codes.LeaderClientDisconnected, "disconnected ws from leader")
leaderDisconnectionCallback()
})
leaderClient.client.OnError(func(err error) {
log.Warnf(codes.LeaderClientConnectionError, "leader client on error: %v", err)
})
leaderClient.client.OnConnect(func() {
log.WithMetadata(map[string]interface{}{
"leaderAddr": address,
}).Info(codes.LeaderClientConnected, "connected to new leader")
})
return leaderClient
}
func getURL(address string) string {
addr, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
panic(err) // must never occurred
}
cfg := config.Get().(*conf.Configuration)
params := url.Values{}
params.Add(ClusterParam, "true")
// TODO выпилить instance_uuid ?
params.Add(utils.ModuleNameGetParamKey, cfg.ModuleName)
params.Add(utils.InstanceUuidGetParamKey, "9d89354b-c728-4b48-b002-a7d3b229f151")
return fmt.Sprintf("ws://%s:%d/isp-etp/?%s", addr.IP.String(), addr.Port, params.Encode())
}
+12
View File
@@ -0,0 +1,12 @@
db:
host: 127.0.0.1
port: 5432
database: test
username: test
password: test
schema: config_service
newConfigService:
address: http://127.0.0.1:9001/
username: default
password: test
+43
View File
@@ -0,0 +1,43 @@
package main
import (
"time"
"github.com/txix-open/isp-kit/json"
)
type Module struct {
Id string
Name string
LastConnectedAt *time.Time
LastDisconnectedAt *time.Time
CreatedAt time.Time
}
type Config struct {
Id string
ModuleId string
Name string
Version int
Active bool
Data json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
type ConfigHistory struct {
Id string
ConfigId string
ConfigVersion int
Data json.RawMessage
CreatedAt time.Time
}
type ConfigSchema struct {
Id string
ModuleId string
Version string
Schema json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
+78
View File
@@ -0,0 +1,78 @@
module isp-config-service/migrate
go 1.27
replace isp-config-service => ../..
require (
github.com/jmoiron/sqlx v1.4.0
github.com/mattn/go-sqlite3 v1.14.47
github.com/pressly/goose/v3 v3.30.1
github.com/txix-open/isp-kit v1.76.0
isp-config-service v0.0.0-00010101000000-000000000000
)
require (
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.15 // indirect
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.2 // indirect
github.com/go-playground/universal-translator v0.18.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.13.0 // indirect
github.com/jackc/puddle/v2 v2.2.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.20.4 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.5.0 // indirect
github.com/mfridman/interpolate v0.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pandatix/go-abnf v0.5.5 // indirect
github.com/prometheus/client_golang v1.25.0 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.74.0 // indirect
github.com/prometheus/procfs v0.23.0 // indirect
github.com/sethvargo/go-retry v0.5.0 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.2.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/txix-open/bellows v1.2.0 // indirect
github.com/txix-open/etp/v4 v4.1.3 // indirect
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 // indirect
go.opentelemetry.io/otel v1.47.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
go.opentelemetry.io/otel/log v1.47.0 // indirect
go.opentelemetry.io/otel/metric v1.47.0 // indirect
go.opentelemetry.io/otel/sdk v1.47.0 // indirect
go.opentelemetry.io/otel/trace v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.28.0 // indirect
golang.org/x/crypto v0.59.0 // indirect
golang.org/x/net v0.63.0 // indirect
golang.org/x/sync v0.25.0 // indirect
golang.org/x/sys v0.50.0 // indirect
golang.org/x/text v0.44.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f // indirect
google.golang.org/grpc v1.85.0 // indirect
google.golang.org/protobuf v1.36.12 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+216
View File
@@ -0,0 +1,216 @@
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-sql-driver/mysql v1.10.1 h1:arlSnNLq6a5yxGxV7qg9lF4j0C+KwD6NbQyKr9QL6ME=
github.com/go-sql-driver/mysql v1.10.1/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0/go.mod h1:FHXQZnW5pA0txiMr3jApv9uNJzZ+7mYZd+u+PPenCFU=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.13.0 h1:Hl08k64maU0nrRyVUEbwCnK6/gT0EhMrtAqBHz9/gA4=
github.com/jackc/pgx/v5 v5.13.0/go.mod h1:u2Fi6no03HCSBYE+ZVdLxbwdu3xyi2vU+K/YNJioSds=
github.com/jackc/puddle/v2 v2.2.4 h1:N6Mz6EGB9DL0bz3OEfxJ7eoOpjRHnnjpOh+G8kbLoG8=
github.com/jackc/puddle/v2 v2.2.4/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.47 h1:jOBI62gS7nKeZv+as1oGEy0+1qISgXwH/QBlR6KbfIo=
github.com/mattn/go-sqlite3 v1.14.47/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w=
github.com/mfridman/interpolate v0.2.0 h1:HM9ID8p6CUxoMJX+fECOtGQ2Mu7TW/GIMPyu48nnvUg=
github.com/mfridman/interpolate v0.2.0/go.mod h1:8SfDy95IaPNnIokZh9mvIppmc3fGl8fx+Gu7uusuO9Q=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
github.com/ncruces/go-strftime v1.1.0/go.mod h1:yVaq7iwCN09vHRrKBrrflXT0M9tTMG2KmZ9Fj7xeG/g=
github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM=
github.com/pandatix/go-abnf v0.5.5/go.mod h1:AE0KD3/VNoCjGzc1gqetRKshbI4SYErXQ/8kPenR5mc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pressly/goose/v3 v3.30.1 h1:KO28meBdbAUIdMbTP7bl9dp1FYZGXcYWb2O7miT09lE=
github.com/pressly/goose/v3 v3.30.1/go.mod h1:CHGwuG2acDerUaXwz2i5T18VSauXpYDiL4WxzDvcOIM=
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA=
github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/sethvargo/go-retry v0.5.0 h1:JYfFKmVJ8ER06GReN1efzc5cm52BrVsFVzmcHiKJwfY=
github.com/sethvargo/go-retry v0.5.0/go.mod h1:tvsjdKG6xfiCx4LSiUZ06kcv38xvdVQwv8R6/VnnVWg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM=
github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
github.com/txix-open/isp-kit v1.76.0 h1:kqhX2DuoTfeW7BIshedG26TRIfOgX0QOInm606ssGVg=
github.com/txix-open/isp-kit v1.76.0/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 h1:1jE11HLmMHDYYAcE+UmQ5VHgz4stzz0+daJbDWS+sEs=
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3/go.mod h1:Yf41v210LFyYAj+tGmDh7PHdGsTaZjdBzHG0ptUvihw=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0=
go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw=
go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw=
go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM=
go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0=
go.opentelemetry.io/proto/otlp v1.11.1 h1:SCrPqH9NE5CmBrOqpjNCiT0X5mGwMyGERXdogfR7Yjw=
go.opentelemetry.io/proto/otlp v1.11.1/go.mod h1:wq8W4aSf6bOy8RZyESOeQFr9Pu7wydWX/TY4sgvrTPg=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI=
go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f/go.mod h1:CPxXEEQ1S9iJmInAF/8MNc8tKWnya8I8Kni9Zh2hV0M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g=
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw=
google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/libc v1.80.2 h1:3+a4fJZvvzg920ZC0mOepnKPGn7cqCaVeDxm/UnrM1A=
modernc.org/libc v1.80.2/go.mod h1:pvo25Rs3OJEbDqhUV9jdEGevxeLJrJeDmNid/AcQV1g=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.62.0 h1:gMaCjSM1qpl+iOjiWhR1LYP3zqrYDI+5GYLGt6veP2g=
modernc.org/sqlite v1.62.0/go.mod h1:Jzjh1mt4s0HuQ0KvtB1LIuHiGRmU2D5pgj8dUhW7/SE=
+204
View File
@@ -0,0 +1,204 @@
package main
import (
"context"
"database/sql"
"fmt"
"os"
"time"
"github.com/pressly/goose/v3"
"github.com/txix-open/isp-kit/config"
"github.com/txix-open/isp-kit/dbx"
"github.com/txix-open/isp-kit/http/httpcli"
"github.com/txix-open/isp-kit/http/httpclix"
"github.com/txix-open/isp-kit/log"
"github.com/txix-open/isp-kit/validator"
"isp-config-service/service/rqlite/goose_store"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
"github.com/txix-open/isp-kit/app"
"github.com/txix-open/isp-kit/db"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/entity"
"isp-config-service/entity/xtypes"
"isp-config-service/migrate/migration"
"isp-config-service/migrations"
"isp-config-service/repository"
)
type Cfg struct {
Db dbx.Config
NewConfigService struct {
Address string
Username string
Password string
}
}
type dbClient struct {
*db.Client
}
func (d dbClient) ExecTransaction(ctx context.Context, requests [][]any) ([]sql.Result, error) {
panic("implement me")
}
func main() {
app, err := app.New(app.WithConfigOptions(
config.WithValidator(validator.Default),
config.WithExtraSource(config.NewYamlConfig("config.yml")),
))
if err != nil {
panic(err)
}
logger := app.Logger()
logger.SetLevel(log.DebugLevel)
ctx := app.Context()
cfg := Cfg{}
err = app.Config().Read(&cfg)
if err != nil {
panic(errors.WithMessage(err, "read config"))
}
pgDb, err := dbx.Open(ctx, cfg.Db, dbx.WithQueryTracer(dbx.NewLogTracer(logger)))
if err != nil {
panic(err)
}
defer pgDb.Close()
fileName := fmt.Sprintf("db_%d.sqlite", time.Now().Unix())
dbClient := dbClient{&db.Client{}}
dbClient.DB, err = sqlx.Open("sqlite3", fileName)
dbClient.DB.MapperFunc(db.ToSnakeCase)
if err != nil {
panic(errors.WithMessage(err, "err opening db"))
}
defer dbClient.Close()
migrationStore := goose_store.NewStore(dbClient.DB.DB)
mr := migration.NewRunner("", migrations.Migrations, logger)
err = mr.Run(ctx, dbClient.DB.DB, goose.WithStore(migrationStore))
if err != nil {
panic(errors.WithMessage(err, "err connecting to db"))
}
moduleRepo := repository.NewModule(dbClient)
configRepo := repository.NewConfig(dbClient)
configSchemaRepo := repository.NewConfigSchema(dbClient)
configHistoryRepo := repository.NewConfigHistory(dbClient)
logger.Info(ctx, "start modules migration")
modules := make([]Module, 0)
err = pgDb.Select(ctx, &modules, "select * from modules")
if err != nil {
panic(errors.WithMessage(err, "err selecting modules"))
}
for _, module := range modules {
result := entity.Module{
Id: module.Id,
Name: module.Name,
CreatedAt: xtypes.Time(module.CreatedAt),
}
_, _ = moduleRepo.Upsert(ctx, result)
}
logger.Info(ctx, "modules migrated")
logger.Info(ctx, "start configs migration")
configs := make([]Config, 0)
err = pgDb.Select(ctx, &configs, "select id, module_id, version, active, created_at, updated_at, data, name from configs")
if err != nil {
panic(errors.WithMessage(err, "err selecting configs"))
}
for _, config := range configs {
result := entity.Config{
Id: config.Id,
Name: config.Name,
ModuleId: config.ModuleId,
Data: config.Data,
Version: config.Version,
Active: xtypes.Bool(config.Active),
AdminId: 0,
CreatedAt: xtypes.Time(config.CreatedAt),
UpdatedAt: xtypes.Time(config.UpdatedAt),
}
err := configRepo.Insert(ctx, result)
if err != nil {
panic(errors.WithMessagef(err, "err inserting config: %s", config.Id))
}
}
logger.Info(ctx, "configs migrated")
logger.Info(ctx, "start config schemas migration")
schemas := make([]ConfigSchema, 0)
err = pgDb.Select(ctx, &schemas, "select * from config_schemas")
if err != nil {
panic(errors.WithMessage(err, "err selecting schemas"))
}
for _, schema := range schemas {
result := entity.ConfigSchema{
Id: schema.Id,
ModuleId: schema.ModuleId,
Data: schema.Schema,
ModuleVersion: schema.Version,
CreatedAt: xtypes.Time(schema.CreatedAt),
UpdatedAt: xtypes.Time(schema.UpdatedAt),
}
err := configSchemaRepo.Upsert(ctx, result)
if err != nil {
panic(errors.WithMessagef(err, "err upserting config_schema: %s", schema.Id))
}
}
logger.Info(ctx, "config schemas migrated")
logger.Info(ctx, "start config history migration")
configHistories := make([]ConfigHistory, 0)
err = pgDb.Select(ctx, &configHistories, "select * from version_config")
if err != nil {
panic(errors.WithMessage(err, "err selecting configs"))
}
for _, history := range configHistories {
result := entity.ConfigHistory{
Id: history.Id,
ConfigId: history.ConfigId,
Data: history.Data,
Version: history.ConfigVersion,
AdminId: 0,
CreatedAt: xtypes.Time(history.CreatedAt),
}
err := configHistoryRepo.InsertV2(ctx, result)
if err != nil {
panic(errors.WithMessagef(err, "err inserting config_history: %s", history.Id))
}
}
logger.Info(ctx, "config history migrated")
logger.Info(ctx, "close sqlite db")
_ = dbClient.Close()
logger.Info(ctx, "loading db to isp-config-service")
sqliteFile, err := os.ReadFile(fileName)
if err != nil {
panic(errors.WithMessage(err, "err opening sqlite file"))
}
cli := httpcli.New(httpcli.WithMiddlewares(httpclix.Log(logger)))
cli.GlobalRequestConfig().BaseUrl = cfg.NewConfigService.Address
cli.GlobalRequestConfig().BasicAuth = &httpcli.BasicAuth{
Username: cfg.NewConfigService.Username,
Password: cfg.NewConfigService.Password,
}
ctx = httpclix.LogConfigToContext(ctx, false, true)
err = cli.Post("/db/load").
Header("Content-Type", "application/octet-stream").
RequestBody(sqliteFile).
StatusCodeToError().
Timeout(120 * time.Second).
DoWithoutResponse(ctx)
if err != nil {
panic(errors.WithMessage(err, "load sqlite file"))
}
logger.Info(ctx, "done!")
}
+86
View File
@@ -0,0 +1,86 @@
package migration
import (
"context"
"database/sql"
"fmt"
"io/fs"
"path/filepath"
"strings"
"time"
"github.com/pressly/goose/v3"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/log"
)
const (
DialectPostgreSQL = goose.DialectPostgres
DialectSqlite3 = goose.DialectSQLite3
DialectClickhouse = goose.DialectClickHouse
)
type Runner struct {
dialect goose.Dialect
fs fs.FS
logger log.Logger
}
func NewRunner(
dialect goose.Dialect,
fs fs.FS,
logger log.Logger,
) Runner {
return Runner{
dialect: dialect,
fs: fs,
logger: logger,
}
}
func (r Runner) Run(ctx context.Context, db *sql.DB, gooseOpts ...goose.ProviderOption) error {
ctx = log.ToContext(ctx, log.String("worker", "goose_db_migration"))
provider, err := goose.NewProvider(r.dialect, db, r.fs, gooseOpts...)
if err != nil {
return errors.WithMessage(err, "get goose provider")
}
dbVersion, err := provider.GetDBVersion(ctx)
if err != nil {
return errors.WithMessage(err, "get db version")
}
r.logger.Info(ctx, fmt.Sprintf("current db version: %d", dbVersion))
migrations, err := provider.Status(ctx)
if err != nil {
return errors.WithMessage(err, "get status migrations")
}
r.logger.Info(ctx, "print migration list")
if len(migrations) == 0 {
r.logger.Info(ctx, "no migrations")
}
for _, migration := range migrations {
appliedAt := "Pending"
if !migration.AppliedAt.IsZero() {
appliedAt = migration.AppliedAt.Format(time.RFC3339)
}
msg := fmt.Sprintf(
"migration: %s %s %s",
filepath.Base(migration.Source.Path),
strings.ToUpper(string(migration.State)),
appliedAt,
)
r.logger.Info(ctx, msg)
}
result, err := provider.Up(ctx)
if err != nil {
return errors.WithMessage(err, "apply pending migrations")
}
for _, migrationResult := range result {
r.logger.Info(ctx, fmt.Sprintf("applied migration: %s", migrationResult.String()))
}
return nil
}
-42
View File
@@ -1,42 +0,0 @@
package codes
const (
// Common
StartHttpServerError = 1001
ShutdownHttpServerError = 1002
ShutdownHttpServerInfo = 1003
WebsocketError = 1004
WebsocketEmitError = 1005
DatabaseOperationError = 1006
// Raft
InitRaftError = 1007
RestoreFromRepositoryError = 1008
RaftLoggerCode = 1009
BootstrapClusterError = 1010
RaftShutdownError = 1011
RaftShutdownInfo = 1012
// Raft Log
ApplyLogCommandError = 1013
PrepareLogCommandError = 1014
SyncApplyError = 1015
// Raft Cluster
SendDeclarationToLeader = 1016
LeaderClientConnectionError = 1017
LeaderClientDisconnected = 1018
LeaderClientConnected = 1023
LeaderStateChanged = 1024
LeaderManualDeleteLeader = 1025
// Services
DiscoveryServiceSendModulesError = 1019
RoutesServiceSendRoutesError = 1020
ConfigServiceBroadcastConfigError = 1021
// Mux
InitMuxError = 1022
)
+46 -34
View File
@@ -1,39 +1,51 @@
database:
address: "127.0.0.1"
schema: "config_service"
database: "test"
port: "5432"
username: "test"
password: "password"
createSchema: true
moduleName: "config"
configServiceAddress:
ip: localhost
port: 9001
grpcOuterAddress:
ip: ""
ip: isp-config-service
port: 9002
grpcInnerAddress:
ip: 0.0.0.0
port: 9002
moduleName: isp-config-service
ws:
rest:
port: "9001"
ip: "0.0.0.0"
grpc:
port: "9002"
ip: "0.0.0.0"
infraServerPort: 9006
metrics:
gc: true
memory: true
address:
addressConfiguration:
ip: "0.0.0.0"
port: "9551"
path: "/metrics"
logLevel: debug
cluster:
dataDir: ./data
inMemory: true
outerAddress: 127.0.0.1:9001
connectTimeoutSeconds: 5
bootstrapCluster: true
peers:
- 127.0.0.1:9001
maintenanceMode: false
keepConfigVersions: 64
credentials:
- username: default
password: 38kPk0upqI5j
perms: ["all"]
- username: monitor
password: monitor
perms: ["ready"]
internalClientCredential: default
rqlite:
DataPath: "data"
NodeID: 1
BootstrapExpect: 1
RaftAddr: "127.0.0.1:9008"
JoinAddrs: "127.0.0.1:9008"
FKConstraints: true
AutoVacInterval: 12h
AutoOptimizeInterval: 23h
JoinAs: default
backup:
Enable: true
Amount: 5
Interval: "24h"
ClearInterval: "168h"
Sub:
Dir: "/app/data/backups/rqlite"
Name: "backup.sqlite.gz"
metricsAutodiscovery:
enable: true
-10
View File
@@ -1,10 +0,0 @@
moduleName: config
instanceUuid: bf482806-0c3d-4e0d-b9d4-12c037b12d70
registry:
host: nexus.msp.mobi
username: mp3deployer
password: ScjKLQuvqfAXu2bs8ysLAvRt
images:
module: nexus.msp.mobi/msp2/dev/isp-config-service:latest
-30
View File
@@ -1,30 +0,0 @@
//nolint lll
package conf
import (
"github.com/integration-system/isp-lib/v2/structure"
)
type Configuration struct {
Database structure.DBConfiguration `valid:"required~Required" schema:"База данных,настройка параметров подключения к базе данных"`
GrpcOuterAddress structure.AddressConfiguration `valid:"required~Required" json:"grpcOuterAddress"`
ModuleName string `valid:"required~Required"`
WS WebService `valid:"required~Required" schema:"Конфигурация веб сервиса"`
Metrics structure.MetricConfiguration
Cluster ClusterConfiguration `valid:"required~Required"`
}
type ClusterConfiguration struct {
InMemory bool `schema:"Хранить логи и снэпшоты только в памяти"`
BootstrapCluster bool `schema:"Поднимать кластер и объявлять лидером"`
DataDir string `valid:"required~Required" schema:"Пусть до директории для логов и снэпшотов рафта"`
Peers []string `valid:"required~Required" schema:"Адреса всех нод в кластере,формат address:port"`
OuterAddress string `valid:"required~Required" schema:"Внешний адрес ноды"`
ConnectTimeoutSeconds int `valid:"required~Required" schema:"Таймаут подключения"`
}
type WebService struct {
Rest structure.AddressConfiguration `valid:"required~Required"`
Grpc structure.AddressConfiguration `valid:"required~Required"`
WsConnectionReadLimitKB int64 `schema:"Максимальное количество килобайт на чтение по вебсокету,при превышении соединение закрывается с ошибкой"`
}
+1
View File
@@ -0,0 +1 @@
{}
+22
View File
@@ -0,0 +1,22 @@
package conf
import (
"isp-config-service/service/rqlite"
"github.com/rqlite/rqlite/v10/auth"
"github.com/txix-open/isp-kit/bootstrap"
)
type Local struct {
ConfigServiceAddress bootstrap.ConfigServiceAddr
MaintenanceMode bool
Credentials []auth.Credential
KeepConfigVersions int
InternalClientCredential string `validate:"required"`
Rqlite Rqlite
Backup rqlite.Backup
}
type Rqlite struct {
NodeId string `validate:"required"`
}
+4
View File
@@ -0,0 +1,4 @@
package conf
type Remote struct {
}
-336
View File
@@ -1,336 +0,0 @@
package main
import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"strconv"
"strings"
"testing"
"time"
"github.com/integration-system/isp-lib-test/ctx"
"github.com/integration-system/isp-lib-test/docker"
"github.com/integration-system/isp-lib-test/utils"
"github.com/integration-system/isp-lib-test/utils/postgres"
"github.com/integration-system/isp-lib/v2/backend"
"github.com/integration-system/isp-lib/v2/structure"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
"isp-config-service/conf"
"isp-config-service/domain"
)
const (
configServiceHttpPort = "9001"
configServiceGrpcPort = "9002"
configServiceSchema = "config_service"
configsNumber = 3
maxAwaitingTime = 25 * time.Second
attemptTimeout = 300 * time.Millisecond
deleteCommonConfigsCommand = "config/common_config/delete_config"
getRoutesCommand = "config/routing/get_routes"
)
var (
pgCfg structure.DBConfiguration
configsHttpAddrs = make([]structure.AddressConfiguration, configsNumber)
configsGrpcAddrs = make([]structure.AddressConfiguration, configsNumber)
configsCtxs = make([]*docker.ContainerContext, configsNumber)
)
func TestMain(m *testing.M) {
cfg := ctx.BaseTestConfiguration{}
test, err := ctx.NewIntegrationTest(m, &cfg, setup)
if err != nil {
panic(err)
}
test.PrepareAndRun()
}
func setup(testCtx *ctx.TestContext, runTest func() int) int {
cfg := testCtx.BaseConfiguration()
cli, err := docker.NewClient()
if err != nil {
panic(err)
}
defer cli.Close()
env := docker.NewTestEnvironment(testCtx, cli)
defer env.Cleanup()
_, pgCfg = env.RunPGContainer()
_, err = postgres.Wait(pgCfg, 10*time.Second)
if err != nil {
panic(err)
}
pgCfg.Schema = configServiceSchema
configs := make([]conf.Configuration, configsNumber)
peersAddrs := make([]string, configsNumber)
for i := 0; i < configsNumber; i++ {
httpAddr := getConfigServiceAddress(i, configServiceHttpPort)
grpcAddr := getConfigServiceAddress(i, configServiceGrpcPort)
cfg := conf.Configuration{
Database: pgCfg,
ModuleName: moduleName,
GrpcOuterAddress: grpcAddr,
WS: conf.WebService{
Rest: httpAddr,
Grpc: grpcAddr,
},
Cluster: conf.ClusterConfiguration{
InMemory: false,
DataDir: "./data",
Peers: nil,
OuterAddress: httpAddr.GetAddress(),
ConnectTimeoutSeconds: 10,
BootstrapCluster: false,
},
}
configsGrpcAddrs[i] = grpcAddr
configsHttpAddrs[i] = httpAddr
configs[i] = cfg
peersAddrs[i] = httpAddr.GetAddress()
}
configs[0].Cluster.BootstrapCluster = true
for i := 0; i < configsNumber; i++ {
c := configs[i]
peersAddrsEnv := generatePeersConfigEnv(peersAddrs)
peersAddrsEnv["LOG_LEVEL"] = "debug"
ctx := env.RunAppContainer(
cfg.Images.Module, c, nil,
docker.WithName(c.GrpcOuterAddress.IP),
docker.WithLogger(NewWriteLogger(strconv.Itoa(i)+"_config:", ioutil.Discard, "DeleteCommonConfigsCommand")),
//docker.WithLogger(NewWriteLogger(strconv.Itoa(i)+"_config:", ioutil.Discard, "Apply 10 command")),
//docker.PullImage(cfg.Registry.Username, cfg.Registry.Password),
docker.WithEnv(peersAddrsEnv),
)
grpcAddr := configsGrpcAddrs[i]
grpcAddr.IP = ctx.GetIPAddress()
configsGrpcAddrs[i] = grpcAddr
httpAddr := configsHttpAddrs[i]
httpAddr.IP = ctx.GetIPAddress()
configsHttpAddrs[i] = httpAddr
configsCtxs[i] = ctx
}
//time.Sleep(3 * time.Second)
return runTest()
}
func TestClusterElection(t *testing.T) {
defer func() {
err := recover()
if err != nil {
log.Println(err)
}
}()
a := assert.New(t)
var ready bool
ready = testClusterReady(a, -1)
if !ready {
return
}
for i := 0; i < configsNumber; i++ {
fmt.Print("\n\n\n")
log.Printf("stopping %d container\n", i)
a.NoError(configsCtxs[i].StopContainer(20 * time.Second))
time.Sleep(5 * time.Second)
fmt.Print("\n\n\n")
log.Printf("checking cluster except %d\n", i)
ready = testClusterReady(a, i)
if !ready {
return
}
fmt.Print("\n\n\n")
log.Printf("starting %d container\n", i)
a.NoError(configsCtxs[i].StartContainer())
time.Sleep(3 * time.Second)
log.Printf("checking cluster, iteration %d\n", i+1)
ready = testClusterReady(a, -1)
if !ready {
return
}
}
}
func getConfigServiceAddress(num int, port string) structure.AddressConfiguration {
lastIP := pgCfg.Address
ip := net.ParseIP(lastIP).To4()
ip[3] = byte(int(ip[3]) + num + 1)
return structure.AddressConfiguration{
//IP: fmt.Sprintf("%s-%d", "isp-config-service", num),
IP: ip.String(),
Port: port,
}
}
func testClusterReady(a *assert.Assertions, except int) bool {
var clients []*backend.InternalGrpcClient
defer func() {
for _, client := range clients {
client.CloseQuietly()
}
}()
for j := 0; j < configsNumber; j++ {
if j == except {
continue
}
configAddr := configsGrpcAddrs[j]
client := testGrpcReady(configAddr, a)
if client == nil {
a.Fail(fmt.Sprintf("unable to connect to %d config", j))
return false
}
clients = append(clients, client)
ready := testRaftReady(client, a)
if !ready {
return ready
}
}
prevRoutes := getRoutes(clients[0], a)
routesLen := len(clients)
for i := 1; i < len(clients); i++ {
routes := getRoutes(clients[i], a)
t := a.Len(routes, routesLen, "invalid length")
if !t {
return t
}
match := a.ElementsMatch(prevRoutes, routes, "different backend declarations")
if !match {
return match
}
}
return true
}
func testGrpcReady(configAddr structure.AddressConfiguration, a *assert.Assertions) *backend.InternalGrpcClient {
start := time.Now()
var client *backend.InternalGrpcClient
var err error
_, _ = await(func() (interface{}, error) {
client, err = backend.NewGrpcClient(
configAddr.GetAddress(),
grpc.WithBlock(),
grpc.WithInsecure(),
)
//log.Println("connect to grpc err:", err)
return nil, err
}, maxAwaitingTime, attemptTimeout)
if !a.NoError(err) {
return nil
}
log.Println("waiting until grpc ready:", time.Since(start).Round(time.Second))
return client
}
func testRaftReady(client *backend.InternalGrpcClient, a *assert.Assertions) bool {
var err error
req := new(domain.ConfigIdRequest)
req.Id = "33"
response := new(structure.GrpcError)
start := time.Now()
f := func() (interface{}, error) {
err = client.Invoke(
deleteCommonConfigsCommand,
-1,
req,
response,
)
//log.Println("send grpc request. response: ", response, "err: ", err)
return nil, err
}
_, _ = await(f, maxAwaitingTime, attemptTimeout)
log.Println("waiting until raft ready:", time.Since(start).Round(time.Second))
return a.NoError(err)
}
func getRoutes(client *backend.InternalGrpcClient, a *assert.Assertions) []structure.BackendDeclaration {
var response []structure.BackendDeclaration
var err error
f := func() (interface{}, error) {
err = client.Invoke(
getRoutesCommand,
-1,
nil,
&response,
)
if err != nil {
return nil, err
} else if len(response) == 0 {
return nil, errors.New("zero routes")
}
//log.Println("routes:", response)
return nil, nil
}
_, _ = await(f, time.Second, 50*time.Millisecond)
a.NoError(err)
return response
}
func await(dialer func() (interface{}, error), timeout, attemptTimeout time.Duration) (interface{}, error) {
retryer := utils.NewRetryer(dialer, timeout)
retryer.AttemptTimeout = attemptTimeout
return retryer.Do()
}
func generatePeersConfigEnv(peers []string) map[string]string {
key := "LC_ISP_CLUSTER.PEERS"
val := strings.Join(peers, ",")
return map[string]string{
key: val,
}
}
type writeLogger struct {
prefix string
w io.Writer
filter string
}
func (l *writeLogger) Write(p []byte) (int, error) {
lines := bytes.SplitAfter(p, []byte("\n"))
for _, line := range lines {
s := string(line)
if l.filter != "" && strings.Contains(s, l.filter) || strings.TrimSpace(s) == "" {
continue
}
_, err := l.w.Write(p)
if err != nil {
fmt.Printf("%s %s: %v", l.prefix, s, err)
} else {
fmt.Printf("%s %s", l.prefix, s)
}
}
return len(p), nil
}
// NewWriteLogger returns a writer that behaves like w except
// that it logs (using fmt.Printf) each write to standard error,
// printing the prefix and the string data written.
func NewWriteLogger(prefix string, w io.Writer, filter string) io.Writer {
return &writeLogger{prefix, w, filter}
}
+292
View File
@@ -0,0 +1,292 @@
//nolint:lll
package api
import (
"context"
"strconv"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/apierrors"
"google.golang.org/grpc/metadata"
"isp-config-service/domain"
"isp-config-service/entity"
)
type ConfigService interface {
GetActiveConfigByModuleName(ctx context.Context, moduleName string) (*domain.Config, error)
GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error)
CreateUpdateConfig(ctx context.Context, adminId int, req domain.CreateUpdateConfigRequest) (*domain.CreateUpdateConfigResponse, error)
GetConfigById(ctx context.Context, configId string) (*domain.Config, error)
MarkConfigAsActive(ctx context.Context, configId string) error
DeleteConfig(ctx context.Context, id string) error
UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) error
SyncConfig(ctx context.Context, moduleName string) error
}
type Config struct {
service ConfigService
}
func NewConfig(service ConfigService) Config {
return Config{
service: service,
}
}
// GetActiveConfigByModuleName
// @Summary Метод получения объекта конфигурации по названию модуля
// @Description Возвращает активную конфиграцию по названию модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleNameRequest true "название модуля"
// @Success 200 {object} domain.Config
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден<br/>`errorCode: 2002` - конфиг не найден"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_active_config_by_module_name [POST]
func (c Config) GetActiveConfigByModuleName(ctx context.Context, req domain.GetByModuleNameRequest) (*domain.Config, error) {
config, err := c.service.GetActiveConfigByModuleName(ctx, req.ModuleName)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeModuleNotFound,
"module not found",
err,
)
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"active config not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return config, nil
}
}
// GetConfigsByModuleId
// @Summary Метод получения списка конфигураций по ID модуля
// @Description Возвращает список конфиграции по ID модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleIdRequest true "ID модуля"
// @Success 200 {array} domain.Config
// @Failure 400 {object} apierrors.Error "если идентификатор не указан"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_configs_by_module_id [POST]
func (c Config) GetConfigsByModuleId(ctx context.Context, req domain.GetByModuleIdRequest) ([]domain.Config, error) {
configs, err := c.service.GetConfigsByModuleId(ctx, req.ModuleId)
switch {
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return configs, nil
}
}
// CreateUpdateConfig
// @Summary Метод обновления конфигурации
// @Description Если конфиг с таким id существует, то обновляет данные, если нет, то добавляет данные в базу
// @Description В случае обновления рассылает всем подключенным модулям актуальную конфигурацию
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.CreateUpdateConfigRequest true "объект для сохранения"
// @Success 200 {object} domain.CreateUpdateConfigResponse
// @Failure 400 {object} apierrors.Error "`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode: 2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже обновил конфигурацию<br/>`errorCode: 2005` - схема конфигурации не найдена<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/create_update_config [POST]
func (c Config) CreateUpdateConfig(
ctx context.Context,
authData grpc.AuthData,
req domain.CreateUpdateConfigRequest,
) (*domain.CreateUpdateConfigResponse, error) {
adminIdValue, _ := grpc.StringFromMd("x-admin-id", metadata.MD(authData))
var adminId int
if adminIdValue != "" {
adminId, _ = strconv.Atoi(adminIdValue)
}
resp, err := c.service.CreateUpdateConfig(ctx, adminId, req)
var validationError domain.ConfigValidationError
switch {
case errors.As(err, &validationError):
details := map[string]any{}
for key, value := range validationError.Details {
details[key] = value
}
return nil, apierrors.NewBusinessError(
domain.ErrorCodeInvalidConfig,
"invalid config",
err,
).WithDetails(details)
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case errors.Is(err, entity.ErrConfigConflictUpdate):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigVersionConflict,
"someone has updated the config",
err,
)
case errors.Is(err, entity.ErrSchemaNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeSchemaNotFound,
"config schema not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return resp, nil
}
}
// GetConfigById
// @Summary Метод получение конфигурации по id
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id конфигурации"
// @Success 200 {object} domain.Config
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_config_by_id [POST]
func (c Config) GetConfigById(ctx context.Context, req domain.IdRequest) (*domain.Config, error) {
config, err := c.service.GetConfigById(ctx, req.Id)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return config, nil
}
}
// MarkConfigAsActive
// @Summary Метод активации конфигурации для модуля
// @Description Активирует указанную конфигурацию и деактивирует остальные, возвращает активированную конфигурацию
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id конфигурации для изменения"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/mark_config_as_active [POST]
func (c Config) MarkConfigAsActive(ctx context.Context, identity domain.IdRequest) error {
err := c.service.MarkConfigAsActive(ctx, identity.Id)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
// DeleteConfigs
// @Summary Метод удаления объектов конфигурации по идентификаторам
// @Description Возвращает количество удаленных модулей
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body []string true "массив идентификаторов конфигураций"
// @Success 200 {object} domain.DeleteResponse
// @Failure 400 {object} apierrors.Error "если не указан массив идентификаторов"
// @Failure 500 {object} apierrors.Error
// @Router /config/delete_config [POST]
func (c Config) DeleteConfigs(ctx context.Context, identities []string) (*domain.DeleteResponse, error) {
configId, err := getSingleId(identities)
if err != nil {
return nil, err
}
err = c.service.DeleteConfig(ctx, configId)
switch {
case errors.Is(err, entity.ErrConfigNotFoundOrActive):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found or is active",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return &domain.DeleteResponse{
Deleted: 1,
}, nil
}
}
// UpdateConfigName
// @Summary Метод переименования объекта конфигурации
// @Description Изменеяет название конфигурации без повышения версии и без рассылки события
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.UpdateConfigNameRequest true "id конфигурации и новое название"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/update_config_name [POST]
func (c Config) UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) error {
err := c.service.UpdateConfigName(ctx, req)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
// SyncConfig
// @Summary Метод синхронизации актуальной конфигурации пришедешего модуля
// @Description Метод синхронизации актуальной конфигурации пришедешего модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.SyncConfigRequest true "название модуля"
// @Success 200 {object} domain.Config
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден<br/>`errorCode: 2002` - конфиг не найден"
// @Failure 500 {object} apierrors.Error
// @Router /config/sync_config [POST]
func (c Config) SyncConfig(ctx context.Context, req domain.SyncConfigRequest) error {
err := c.service.SyncConfig(ctx, req.ModuleName)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeModuleNotFound,
"module not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
+102
View File
@@ -0,0 +1,102 @@
package api
import (
"context"
"isp-config-service/domain"
"isp-config-service/entity"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/grpc/apierrors"
)
type ConfigHistoryService interface {
GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error)
Delete(ctx context.Context, id string) error
Purge(ctx context.Context, moduleName string, keepVersions int) (map[string]int, error)
}
type ConfigHistory struct {
service ConfigHistoryService
}
func NewConfigHistory(service ConfigHistoryService) ConfigHistory {
return ConfigHistory{
service: service,
}
}
// GetAllVersion
// @Summary Метод получение старых версий конфигурации
// @Description Возвращает предыдущие версии конфигураций
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id конфигурации"
// @Success 200 {array} domain.ConfigVersion
// @Failure 400 {object} apierrors.Error "если не указан массив идентификаторов"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_all_version [POST]
func (c ConfigHistory) GetAllVersion(ctx context.Context, req domain.IdRequest) ([]domain.ConfigVersion, error) {
versions, err := c.service.GetAllVersions(ctx, req.Id)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return versions, nil
}
}
// DeleteConfigVersion
// @Summary Метод удаления версии конфигурации
// @Description Возвращает количество удаленных версий
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id версии конфигурации"
// @Success 200 {object} domain.DeleteResponse
// @Failure 400 {object} apierrors.Error "не указан массив идентификаторов"
// @Failure 500 {object} apierrors.Error
// @Router /config/delete_version [POST]
func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, req domain.IdRequest) (*domain.DeleteResponse, error) {
err := c.service.Delete(ctx, req.Id)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return &domain.DeleteResponse{
Deleted: 1,
}, nil
}
// PurgeConfigVersions
// @Summary Метод удаления старых версий всех конфигураций модуля, оставляет keepVersions последних версий каждой конфигурации
// @Description Возвращает количество удаленных версий каждой конфигурации
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.PurgeConfigVersionsRequest true "Название модуля, количество оставленных версий конфигурации"
// @Success 200 {object} map[string]int
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден"
// @Failure 500 {object} apierrors.Error
// @Router /config/purge_versions [POST]
func (c ConfigHistory) PurgeConfigVersions(ctx context.Context, req domain.PurgeConfigVersionsRequest) (map[string]int, error) {
result, err := c.service.Purge(ctx, req.ModuleName, req.KeepVersions)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeModuleNotFound,
"module not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return result, nil
}
}
+80
View File
@@ -0,0 +1,80 @@
package api
import (
"context"
"isp-config-service/domain"
"isp-config-service/entity"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/grpc/apierrors"
)
type ConfigSchemaService interface {
SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error)
UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error
}
type ConfigSchema struct {
service ConfigSchemaService
}
func NewConfigSchema(service ConfigSchemaService) ConfigSchema {
return ConfigSchema{
service: service,
}
}
// SchemaByModuleId
// @Summary Метод получения схемы конфигурации модуля
// @Description Возвращает текущую json схему конфигурации модуля
// @Tags Схема
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleIdRequest true "идентификатор модуля"
// @Success 200 {object} domain.ConfigSchema
// @Failure 400 {object} apierrors.Error "`errorCode: 2005` - схема для модуля не найдена"
// @Failure 500 {object} apierrors.Error
// @Router /schema/get_by_module_id [POST]
func (c ConfigSchema) SchemaByModuleId(ctx context.Context, request domain.GetByModuleIdRequest) (*domain.ConfigSchema, error) {
schema, err := c.service.SchemaByModuleId(ctx, request.ModuleId)
switch {
case errors.Is(err, entity.ErrSchemaNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeSchemaNotFound,
"config schema not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return schema, nil
}
}
// UpdateSchemaByModuleName
// @Summary Метод обновления схемы конфигурации модуля
// @Description Меняет схему конфигурации модуля на переданную
// @Tags Схема
// @Accept json
// @Produce json
// @Param body body domain.UpdateSchemaRequest true "название модуля и схема конфига"
// @Success 200 {object} any
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден"
// @Failure 500 {object} apierrors.Error
// @Router /schema/update_by_module_name [POST]
func (c ConfigSchema) UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error {
err := c.service.UpdateSchemaByModuleName(ctx, request)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeModuleNotFound,
"module not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
+111
View File
@@ -0,0 +1,111 @@
package api
import (
"context"
"github.com/txix-open/isp-kit/grpc/apierrors"
"isp-config-service/domain"
)
type ModuleService interface {
Status(ctx context.Context) ([]domain.ModuleInfo, error)
Delete(ctx context.Context, id string) error
Connections(ctx context.Context) ([]domain.Connection, error)
RequiredModules(ctx context.Context) ([]domain.ModuleRelation, error)
}
type Module struct {
service ModuleService
}
func NewModule(service ModuleService) Module {
return Module{
service: service,
}
}
// Status
// @Summary Метод полчения полной информации о состоянии модулей
// @Description Возвращает полное состояние всех модулей в кластере (схема конфигурации, подключенные экземпляры)
// @Tags Модули
// @Accept json
// @Produce json
// @Success 200 {array} domain.ModuleInfo
// @Failure 500 {object} apierrors.Error
// @Router /module/get_modules_info [POST]
func (c Module) Status(ctx context.Context) ([]domain.ModuleInfo, error) {
modulesInfo, err := c.service.Status(ctx)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return modulesInfo, nil
}
// DeleteModule
// @Summary Метод удаления объектов модулей по идентификаторам
// @Description Возвращает количество удаленных модулей
// @Tags Модули
// @Accept json
// @Produce json
// @Param body body []string true "массив идентификаторов модулей"
// @Success 200 {object} domain.DeleteResponse
// @Failure 500 {object} apierrors.Error
// @Router /module/delete_module [POST]
func (c Module) DeleteModule(ctx context.Context, identities []string) (*domain.DeleteResponse, error) {
id, err := getSingleId(identities)
if err != nil {
return nil, err
}
err = c.service.Delete(ctx, id)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return &domain.DeleteResponse{
Deleted: len(identities),
}, nil
}
// RequiredModules
// @Summary Метод для получения зависимостей модулей
// @Description Возвращает список модулей с их зависимостями
// @Tags Модули
// @Accept json
// @Produce json
// @Success 200 {array} domain.ModuleRelation
// @Failure 500 {object} apierrors.Error
// @Router /module/get_required_modules [POST]
func (c Module) RequiredModules(ctx context.Context) ([]domain.ModuleRelation, error) {
relations, err := c.service.RequiredModules(ctx)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return relations, nil
}
// Connections
// @Summary Метод получения маршрутов
// @Description Возвращает все доступные роуты
// @Tags Модули
// @Accept json
// @Produce json
// @Success 200 {array} domain.Connection
// @Failure 500 {object} apierrors.Error
// @Router /routing/get_routes [POST]
func (c Module) Connections(ctx context.Context) ([]domain.Connection, error) {
connections, err := c.service.Connections(ctx)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return connections, nil
}
func getSingleId(identities []string) (string, error) {
if len(identities) == 0 {
return "", apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "at least one id is required", nil)
}
if len(identities) > 1 {
return "", apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "accept only single identity", nil)
}
return identities[0], nil
}
+151
View File
@@ -0,0 +1,151 @@
//nolint:lll
package api
import (
"context"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/grpc/apierrors"
_ "github.com/txix-open/isp-kit/grpc/apierrors"
"isp-config-service/domain"
"isp-config-service/entity"
)
type Service interface {
All(ctx context.Context) ([]domain.Variable, error)
GetByName(ctx context.Context, name string) (*domain.Variable, error)
Create(ctx context.Context, req domain.CreateVariableRequest) error
Update(ctx context.Context, req domain.UpdateVariableRequest) error
Upsert(ctx context.Context, req []domain.UpsertVariableRequest) error
Delete(ctx context.Context, name string) error
}
type Variable struct {
service Service
}
func NewVariable(service Service) Variable {
return Variable{
service: service,
}
}
// All
// @Summary Метод получения списка всех переменных
// @Tags Переменные
// @Accept json
// @Produce json
// @Success 200 {array} domain.Variable
// @Failure 500 {object} apierrors.Error
// @Router /variable/all [POST]
func (c Variable) All(ctx context.Context) ([]domain.Variable, error) {
return c.service.All(ctx)
}
// GetByName
// @Summary Метод получения переменной по точному совпадению имени
// @Tags Переменные
// @Accept json
// @Produce json
// @Param body body domain.VariableByNameRequest true "тело запроса"
// @Success 200 {object} domain.Variable
// @Failure 400 {object} apierrors.Error "`errorCode: 2006` - переменная по имени не найдена<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /variable/get_by_name [POST]
func (c Variable) GetByName(ctx context.Context, req domain.VariableByNameRequest) (*domain.Variable, error) {
v, err := c.service.GetByName(ctx, req.Name)
switch {
case errors.Is(err, entity.ErrVariableNotFound):
return nil, apierrors.NewBusinessError(domain.ErrorCodeVariableNotFound, "variable by name not found", err)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
}
return v, nil
}
// Create
// @Summary Метод создания новой переменной
// @Description Создает новую переменную с указанным наименованием и значением
// @Tags Переменные
// @Accept json
// @Produce json
// @Param body body domain.CreateVariableRequest true "тело запроса"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2007` - переменная с таким именем уже существует<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /variable/create [POST]
func (c Variable) Create(ctx context.Context, req domain.CreateVariableRequest) error {
err := c.service.Create(ctx, req)
switch {
case errors.Is(err, entity.ErrVariableAlreadyExists):
return apierrors.NewBusinessError(domain.ErrorCodeVariableAlreadyExists, "variable with the same name already exists", err)
case err != nil:
return apierrors.NewInternalServiceError(err)
}
return nil
}
// Update
// @Summary Метод обновления переменной
// @Description Выполняет обновление переменной по ее названию
// @Tags Переменные
// @Accept json
// @Produce json
// @Param body body domain.UpdateVariableRequest true "тело запроса"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2006` - переменная по имени не найдена<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /variable/update [POST]
func (c Variable) Update(ctx context.Context, req domain.UpdateVariableRequest) error {
err := c.service.Update(ctx, req)
switch {
case errors.Is(err, entity.ErrVariableNotFound):
return apierrors.NewBusinessError(domain.ErrorCodeVariableNotFound, "variable by name not found", err)
case err != nil:
return apierrors.NewInternalServiceError(err)
}
return nil
}
// Upsert
// @Summary Метод добавления/обновления переменных
// @Description Выполняет безусловное добавление/обновление указанных в теле запроса переменных
// @Description Операция выполняется не в транзакции
// @Tags Переменные
// @Accept json
// @Produce json
// @Param body body []domain.UpsertVariableRequest true "тело запроса"
// @Success 200
// @Failure 500 {object} apierrors.Error
// @Router /variable/upsert [POST]
func (c Variable) Upsert(ctx context.Context, req []domain.UpsertVariableRequest) error {
err := c.service.Upsert(ctx, req)
if err != nil {
return apierrors.NewInternalServiceError(err)
}
return nil
}
// Delete
// @Summary Метод удаления переменной
// @Description Переменная связанная с конфигурациями, не может быть удалена
// @Tags Переменные
// @Accept json
// @Produce json
// @Param body body domain.VariableByNameRequest true "тело запроса"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2006` - переменная по имени не найдена<br/>`errorCode: 2008` - переменная используется в конфигурациях<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /variable/delete [POST]
func (c Variable) Delete(ctx context.Context, req domain.VariableByNameRequest) error {
err := c.service.Delete(ctx, req.Name)
switch {
case errors.Is(err, entity.ErrVariableNotFound):
return apierrors.NewBusinessError(domain.ErrorCodeVariableNotFound, "variable by name not found", err)
case errors.Is(err, entity.ErrVariableUsedInConfigs):
return apierrors.NewBusinessError(domain.ErrorCodeVariableUsedInConfigs, "variable used in configs", err)
case err != nil:
return apierrors.NewInternalServiceError(err)
}
return nil
}
-128
View File
@@ -1,128 +0,0 @@
package controller
import (
"isp-config-service/cluster"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/service"
"isp-config-service/store"
"isp-config-service/store/state"
)
var CommonConfig *commonConfig
type commonConfig struct {
rstore *store.Store
}
// GetConfigs godoc
// @Summary Метод получения объектов конфигурации по идентификаторам
// @Description Возвращает массив конфигураций по запрошенным идентификаторам (все, если массив пустой)
// @Tags Общие конфигурации
// @Accept json
// @Produce json
// @Success 200 {array} entity.CommonConfig
// @Router /common_config/get_configs [POST]
func (c *commonConfig) GetConfigs(identities []string) []entity.CommonConfig {
var response []entity.CommonConfig
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
if len(identities) > 0 {
response = state.CommonConfigs().GetByIds(identities)
} else {
response = state.CommonConfigs().GetAll()
}
})
return response
}
// CreateUpdateConfig godoc
// @Summary Метод обновления общей конфигурации
// @Description Если конфиг с таким id существует, то обновляет данные, если нет, то добавляет данные в базу
// В случае обновления рассылает все подключенным модулям актуальную конфигурацию
// @Tags Общие конфигурации
// @Accept json
// @Produce json
// @Param body body entity.CommonConfig true "объект для сохранения"
// @Success 200 {object} entity.CommonConfig
// @Failure 404 {object} structure.GrpcError "если конфигурация не найдена"
// @Failure 500 {object} structure.GrpcError
// @Router /common_config/create_update_config [POST]
func (c *commonConfig) CreateUpdateConfig(config entity.CommonConfig) (*entity.CommonConfig, error) {
var response entity.CommonConfig
now := state.GenerateDate()
config.CreatedAt = now
config.UpdatedAt = now
upsertConfig := cluster.UpsertCommonConfig{
Config: config,
}
if config.Id == "" {
upsertConfig.Config.Id = state.GenerateId()
upsertConfig.Create = true
}
command := cluster.PrepareUpsertCommonConfigCommand(upsertConfig)
err := PerformSyncApplyWithError(command, "UpsertCommonConfigCommand", &response)
if err != nil {
return nil, err
}
return &response, nil
}
// DeleteConfigs godoc
// @Summary Метод удаления объектов общей конфигурации по идентификаторам
// @Description Возвращает флаг удаления и набор связей с модулями и конфигурациями, в случае наличия связей deleted всегда false
// @Tags Общие конфигурации
// @Accept json
// @Produce json
// @Param body body domain.ConfigIdRequest true "id общей конфигурации"
// @Success 200 {object} domain.DeleteCommonConfigResponse
// @Failure 500 {object} structure.GrpcError
// @Router /common_config/delete_config [POST]
func (c *commonConfig) DeleteConfigs(req domain.ConfigIdRequest) (*domain.DeleteCommonConfigResponse, error) {
var response domain.DeleteCommonConfigResponse
command := cluster.PrepareDeleteCommonConfigsCommand(req.Id)
err := PerformSyncApplyWithError(command, "DeleteCommonConfigsCommand", &response)
if err != nil {
return nil, err
}
return &response, nil
}
// CompileConfigs godoc
// @Summary Метод компиляции итоговой конфигурации для модулей
// @Description Возвращает скомпилированный объект конфигурации
// @Tags Общие конфигурации
// @Accept json
// @Produce json
// @Param body body domain.CompileConfigsRequest true "перечисление идентификаторов общей конфигурации и исхдных конфиг"
// @Success 200 {object} domain.CompiledConfigResponse
// @Router /common_config/compile [POST]
func (c *commonConfig) CompileConfigs(req domain.CompileConfigsRequest) domain.CompiledConfigResponse {
var result map[string]interface{}
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
result = service.ConfigService.CompileConfig(req.Data, state, req.CommonConfigsIdList...)
})
return result
}
// GetLinks godoc
// @Summary Метод получения связей общей конфигурациями с конфигурацией модулей
// @Description Возвращает ассоциативный массив, ключами которого являются название модулей, а значения - название конфигурации модуля
// @Tags Общие конфигурации
// @Accept json
// @Produce json
// @Param body body domain.ConfigIdRequest true "id общей конфигурации"
// @Success 200 {object} domain.CommonConfigLinks
// @Router /common_config/get_links [POST]
func (c *commonConfig) GetLinks(req domain.ConfigIdRequest) domain.CommonConfigLinks {
var result domain.CommonConfigLinks
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
result = service.CommonConfigService.GetCommonConfigLinks(req.Id, state)
})
return result
}
func NewCommonConfig(rstore *store.Store) *commonConfig {
return &commonConfig{
rstore: rstore,
}
}
-139
View File
@@ -1,139 +0,0 @@
package controller
import (
"github.com/integration-system/isp-lib/v2/utils"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"isp-config-service/cluster"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/store"
"isp-config-service/store/state"
)
var Config *config
type config struct {
rstore *store.Store
}
// GetActiveConfigByModuleName godoc
// @Summary Метод получения объекта конфигурации по названию модуля
// @Description Возвращает активную конфиграцию по названию модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleNameRequest true "название модуля"
// @Success 200 {object} entity.Config
// @Failure 404 {object} structure.GrpcError "если конфигурация не найдена"
// @Failure 500 {object} structure.GrpcError
// @Router /config/get_active_config_by_module_name [POST]
func (c *config) GetActiveConfigByModuleName(request domain.GetByModuleNameRequest) (*entity.Config, error) {
var (
module *entity.Module
config *entity.Config
)
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
module = state.Modules().GetByName(request.ModuleName)
if module != nil {
config = state.Configs().GetActiveByModuleId(module.Id)
}
})
if module == nil {
return nil, status.Errorf(codes.NotFound, "module with name '%s' not found", request.ModuleName)
}
if config == nil {
return nil, status.Errorf(codes.NotFound, "active config for module '%s' not found", request.ModuleName)
}
return config, nil
}
// CreateUpdateConfig godoc
// @Summary Метод обновления конфигурации
// @Description Если конфиг с таким id существует, то обновляет данные, если нет, то добавляет данные в базу
// В случае обновления рассылает все подключенным модулям актуальную конфигурацию
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.CreateUpdateConfigRequest true "объект для сохранения"
// @Success 200 {object} domain.ConfigModuleInfo
// @Failure 404 {object} structure.GrpcError "если конфигурация не найдена"
// @Failure 500 {object} structure.GrpcError
// @Router /config/create_update_config [POST]
func (c *config) CreateUpdateConfig(config domain.CreateUpdateConfigRequest) (*domain.ConfigModuleInfo, error) {
var response domain.CreateUpdateConfigResponse
now := state.GenerateDate()
config.CreatedAt = now
config.UpdatedAt = now
upsertConfig := cluster.UpsertConfig{
Config: config.Config,
Unsafe: config.Unsafe,
}
if config.Id == "" {
upsertConfig.Config.Id = state.GenerateId()
upsertConfig.Create = true
}
command := cluster.PrepareUpsertConfigCommand(upsertConfig)
err := PerformSyncApplyWithError(command, "UpsertConfigCommand", &response)
if err != nil {
return nil, err
} else if response.ErrorDetails != nil {
return nil, utils.CreateValidationErrorDetails(codes.InvalidArgument, utils.ValidationError, response.ErrorDetails)
}
return response.Config, nil
}
// MarkConfigAsActive godoc
// @Summary Метод активации конфигурации для модуля
// @Description Активирует указанную конфигурацию и деактивирует остальные, возвращает активированную конфигурацию
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.ConfigIdRequest true "id конфигурации для изменения"
// @Success 200 {object} entity.Config "активированная конфигурация"
// @Failure 404 {object} structure.GrpcError "если конфигурация не найдена"
// @Failure 500 {object} structure.GrpcError
// @Router /config/mark_config_as_active [POST]
func (c *config) MarkConfigAsActive(identity domain.ConfigIdRequest) (*entity.Config, error) {
var response entity.Config
command := cluster.PrepareActivateConfigCommand(identity.Id, state.GenerateDate())
err := PerformSyncApplyWithError(command, "ActivateConfigCommand", &response)
if err != nil {
return nil, err
}
return &response, nil
}
// DeleteConfigs godoc
// @Summary Метод удаления объектов конфигурации по идентификаторам
// @Description Возвращает количество удаленных модулей
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body []string true "массив идентификаторов конфигураций"
// @Success 200 {object} domain.DeleteResponse
// @Failure 400 {object} structure.GrpcError "если не указан массив идентификаторов"
// @Failure 500 {object} structure.GrpcError
// @Router /config/delete_config [POST]
func (c *config) DeleteConfigs(identities []string) (*domain.DeleteResponse, error) {
if len(identities) == 0 {
validationErrors := map[string]string{
"ids": "Required",
}
return nil, utils.CreateValidationErrorDetails(codes.InvalidArgument, utils.ValidationError, validationErrors)
}
var response domain.DeleteResponse
command := cluster.PrepareDeleteConfigsCommand(identities)
err := PerformSyncApply(command, "DeleteConfigsCommand", &response)
if err != nil {
return nil, err
}
return &response, nil
}
func NewConfig(rstore *store.Store) *config {
return &config{
rstore: rstore,
}
}
-66
View File
@@ -1,66 +0,0 @@
package controller
import (
"github.com/integration-system/isp-lib/v2/utils"
log "github.com/integration-system/isp-log"
jsoniter "github.com/json-iterator/go"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"isp-config-service/cluster"
codes2 "isp-config-service/codes"
"isp-config-service/holder"
)
var json = jsoniter.ConfigFastest
func unknownError() error {
return status.Error(codes.Unknown, utils.ServiceError)
}
func PerformSyncApply(command []byte, commandName string, responsePtr interface{}) error {
applyLogResponse, err := holder.ClusterClient.SyncApply(command)
if err != nil {
log.Warnf(codes2.SyncApplyError, "apply %s: %v", commandName, err)
return unknownError()
}
if applyLogResponse != nil && applyLogResponse.ApplyError != "" {
log.WithMetadata(map[string]interface{}{
"result": string(applyLogResponse.Result),
"applyError": applyLogResponse.ApplyError,
"commandName": commandName,
}).Warnf(codes2.SyncApplyError, "apply command")
return unknownError()
}
err = json.Unmarshal(applyLogResponse.Result, responsePtr)
if err != nil {
return unknownError()
}
return nil
}
func PerformSyncApplyWithError(command []byte, commandName string, responsePtr interface{}) error {
applyLogResponse, err := holder.ClusterClient.SyncApply(command)
if err != nil {
log.Warnf(codes2.SyncApplyError, "apply %s: %v", commandName, err)
return unknownError()
}
if applyLogResponse != nil && applyLogResponse.ApplyError != "" {
log.WithMetadata(map[string]interface{}{
"result": string(applyLogResponse.Result),
"applyError": applyLogResponse.ApplyError,
"commandName": commandName,
}).Warnf(codes2.SyncApplyError, "apply command")
return unknownError()
}
clusterResp := cluster.ResponseWithError{
Response: responsePtr,
}
err = json.Unmarshal(applyLogResponse.Result, &clusterResp)
if err != nil {
return unknownError()
}
if clusterResp.Error != "" {
return status.Error(clusterResp.ErrorCode, clusterResp.Error)
}
return nil
}
+37
View File
@@ -0,0 +1,37 @@
package controller
import (
"context"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/http/apierrors"
"isp-config-service/domain"
)
type metricsService interface {
Autodiscovery(ctx context.Context) (domain.AutodiscoveryResponse, error)
}
type Metrics struct {
svc metricsService
}
func NewMetrics(svc metricsService) Metrics {
return Metrics{svc: svc}
}
// Autodiscovery
// @Summary Метод получения конфигурации для HTTP-based service discovery механизма Prometheus
// @Tags Метрики
// @Accept json
// @Produce json
// @Success 200 {object} domain.AutodiscoveryResponse
// @Failure 500 {object} apierrors.Error
// @Router /internal/metrics/autodiscovery [POST]
func (c Metrics) Autodiscovery(ctx context.Context) (domain.AutodiscoveryResponse, error) {
resp, err := c.svc.Autodiscovery(ctx)
if err != nil {
return nil, apierrors.NewInternalServiceError(errors.WithMessage(err, "autodiscovery"))
}
return resp, nil
}
+121 -70
View File
@@ -1,92 +1,143 @@
package controller
import (
"google.golang.org/grpc/status"
"isp-config-service/cluster"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/service"
"isp-config-service/store"
"isp-config-service/store/state"
"context"
"github.com/integration-system/isp-lib/v2/utils"
"google.golang.org/grpc/codes"
"github.com/txix-open/etp/v4"
"github.com/txix-open/etp/v4/msg"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/json"
"github.com/txix-open/isp-kit/log"
"isp-config-service/helpers"
)
var Module *module
var (
ok = []byte("ok") //nolint:gochecknoglobals
)
type module struct {
rstore *store.Store
type ModuleService interface {
OnConnect(ctx context.Context, conn *etp.Conn, moduleName string) error
OnDisconnect(ctx context.Context, conn *etp.Conn, moduleName string, isNormalClose bool, err error) error
OnError(ctx context.Context, conn *etp.Conn, err error)
OnModuleReady(
ctx context.Context,
conn *etp.Conn,
backend cluster.BackendDeclaration,
) error
OnModuleRequirements(
ctx context.Context,
conn *etp.Conn,
requirements cluster.ModuleRequirements,
) error
OnModuleConfigSchema(
ctx context.Context,
conn *etp.Conn,
data cluster.ConfigData,
) error
}
// GetModulesAggregatedInfo godoc
// @Summary Метод получения полной информации о состоянии модуля
// @Description Возвращает полное состояние всех модулей в кластере (конфигурация, схема конфигурации, подключенные экземпляры)
// @Tags Модули
// @Accept json
// @Produce json
// @Success 200 {array} domain.ModuleInfo
// @Failure 500 {object} structure.GrpcError
// @Router /module/get_modules_info [POST]
func (c *module) GetModulesAggregatedInfo() ([]domain.ModuleInfo, error) {
var response []domain.ModuleInfo
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
response = service.ModuleRegistryService.GetAggregatedModuleInfo(state)
})
return response, nil
type Module struct {
service ModuleService
logger log.Logger
}
// DeleteModules godoc
// @Summary Метод удаления объектов модулей по идентификаторам
// @Description Возвращает количество удаленных модулей
// @Tags Модули
// @Accept json
// @Produce json
// @Param body body []string true "массив идентификаторов модулей"
// @Success 200 {object} domain.DeleteResponse
// @Failure 500 {object} structure.GrpcError
// @Router /module/delete_module [POST]
func (*module) DeleteModules(identities []string) (*domain.DeleteResponse, error) {
if len(identities) == 0 {
validationErrors := map[string]string{
"ids": "Required",
}
return nil, utils.CreateValidationErrorDetails(codes.InvalidArgument, utils.ValidationError, validationErrors)
func NewModule(service ModuleService, logger log.Logger) Module {
return Module{
service: service,
logger: logger,
}
}
var deleteResponse domain.DeleteResponse
command := cluster.PrepareDeleteModulesCommand(identities)
err := PerformSyncApply(command, "DeleteCommonConfigsCommand", &deleteResponse)
func (m Module) OnConnect(conn *etp.Conn) {
ctx := conn.HttpRequest().Context()
err := conn.HttpRequest().ParseForm()
if err != nil {
return nil, err
m.handleError(ctx, errors.WithMessage(err, "parse form"))
_ = conn.Close()
return
}
moduleName := helpers.ModuleName(conn)
if moduleName == "" {
m.handleError(ctx, errors.New("module_name is required query param"))
_ = conn.Close()
return
}
err = m.service.OnConnect(ctx, conn, moduleName)
if err != nil {
m.handleError(ctx, errors.WithMessage(err, "handle onConnect"))
}
return &deleteResponse, err
}
// GetModuleByName godoc
// @Summary Метод получения модуля по имени
// @Description Модуль
// @Tags Модули
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleNameRequest true "название модуля"
// @Success 200 {object} entity.Module
// @Failure 500 {object} structure.GrpcError
// @Failure 404 {object} structure.GrpcError "модуль с указанным названием не найден"
// @Router /module/get_by_name [POST]
func (c *module) GetModuleByName(req domain.GetByModuleNameRequest) (*entity.Module, error) {
var module *entity.Module
c.rstore.VisitReadonlyState(func(readonlyState state.ReadonlyState) {
module = readonlyState.Modules().GetByName(req.ModuleName)
})
if module == nil {
return nil, status.Errorf(codes.NotFound, "module with name '%s' not found", req.ModuleName)
func (m Module) OnDisconnect(conn *etp.Conn, err error) {
ctx := conn.HttpRequest().Context()
handleDisconnectErr := m.service.OnDisconnect(
ctx,
conn,
helpers.ModuleName(conn),
etp.IsNormalClose(err),
err,
)
if handleDisconnectErr != nil {
m.handleError(ctx, errors.WithMessage(handleDisconnectErr, "handle onDisconnect"))
}
return module, nil
}
func NewModule(rstore *store.Store) *module {
return &module{
rstore: rstore,
func (m Module) OnError(conn *etp.Conn, err error) {
m.service.OnError(conn.HttpRequest().Context(), conn, err)
}
func (m Module) OnModuleReady(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
backend := cluster.BackendDeclaration{}
err := json.Unmarshal(event.Data, &backend)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "unmarshal event data"))
}
err = m.service.OnModuleReady(ctx, conn, backend)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "handle onModuleReady"))
}
return ok
}
func (m Module) OnModuleRequirements(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
requirements := cluster.ModuleRequirements{}
err := json.Unmarshal(event.Data, &requirements)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "unmarshal event data"))
}
err = m.service.OnModuleRequirements(ctx, conn, requirements)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "handle onModuleRequirements"))
}
return ok
}
func (m Module) OnModuleConfigSchema(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
configData := cluster.ConfigData{}
err := json.Unmarshal(event.Data, &configData)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "unmarshal event data"))
}
err = m.service.OnModuleConfigSchema(ctx, conn, configData)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "handle onModuleConfigSchema"))
}
return ok
}
func (m Module) handleError(
ctx context.Context,
err error,
) []byte {
m.logger.Error(ctx, err)
return []byte(err.Error())
}
-37
View File
@@ -1,37 +0,0 @@
package controller
import (
"github.com/integration-system/isp-lib/v2/structure"
"isp-config-service/store"
"isp-config-service/store/state"
)
var (
Routes *routes
)
type routes struct {
rstore *store.Store
}
// GetRoutes godoc
// @Summary Метод получения маршрутов
// @Description Возвращает все доступные модули
// @Tags Роуты
// @Accept json
// @Produce json
// @Success 200 {array} structure.BackendDeclaration
// @Router /routing/get_routes [POST]
func (c *routes) GetRoutes() ([]structure.BackendDeclaration, error) {
var response structure.RoutingConfig
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
response = state.Mesh().GetRoutes()
})
return response, nil
}
func NewRoutes(rstore *store.Store) *routes {
return &routes{
rstore: rstore,
}
}
-44
View File
@@ -1,44 +0,0 @@
package controller
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/store"
"isp-config-service/store/state"
)
var Schema *schema
type schema struct {
rstore *store.Store
}
// GetByModuleId godoc
// @Summary Метод получения схемы конфигурации модуля
// @Description Возвращает текущую json схему конфигурации модуля
// @Tags Схема
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleIdRequest true "идентификатор модуля"
// @Success 200 {object} entity.ConfigSchema
// @Failure 404 {object} structure.GrpcError "если схема для модуля не найдена"
// @Failure 500 {object} structure.GrpcError
// @Router /schema/get_by_module_id [POST]
func (c *schema) GetByModuleId(request domain.GetByModuleIdRequest) (*entity.ConfigSchema, error) {
var result []entity.ConfigSchema
c.rstore.VisitReadonlyState(func(state state.ReadonlyState) {
result = state.Schemas().GetByModuleIds([]string{request.ModuleId})
})
if len(result) == 0 {
return nil, status.Errorf(codes.NotFound, "schema with moduleId %s not found", request.ModuleId)
}
return &result[0], nil
}
func NewSchema(rstore *store.Store) *schema {
return &schema{
rstore: rstore,
}
}
+40
View File
@@ -0,0 +1,40 @@
services:
isp-config-service-1:
image: "isp-config-service:latest"
container_name: "isp-config-service-1"
hostname: "isp-config-service-1"
restart: unless-stopped
environment:
grpcOuterAddress.ip: isp-config-service-1
rqlite.NodeID: 1
rqlite.BootstrapExpect: 3
rqlite.RaftAddr: "isp-config-service-1:4002"
rqlite.JoinAddrs: "isp-config-service-1:4002,isp-config-service-2:4002,isp-config-service-3:4002"
volumes:
- "./isp-config-service-1/data:/app/data"
isp-config-service-2:
image: "isp-config-service:latest"
container_name: "isp-config-service-2"
hostname: "isp-config-service-2"
restart: unless-stopped
environment:
grpcOuterAddress.ip: isp-config-service-2
rqlite.NodeID: 2
rqlite.BootstrapExpect: 3
rqlite.RaftAddr: "isp-config-service-2:4002"
rqlite.JoinAddrs: "isp-config-service-1:4002,isp-config-service-2:4002,isp-config-service-3:4002"
volumes:
- "./isp-config-service-2/data:/app/data"
isp-config-service-3:
image: "isp-config-service:latest"
container_name: "isp-config-service-3"
hostname: "isp-config-service-3"
restart: unless-stopped
environment:
grpcOuterAddress.ip: isp-config-service-3
rqlite.NodeID: 3
rqlite.BootstrapExpect: 3
rqlite.RaftAddr: "isp-config-service-3:4002"
rqlite.JoinAddrs: "isp-config-service-1:4002,isp-config-service-2:4002,isp-config-service-3:4002"
volumes:
- "./isp-config-service-3/data:/app/data"
+30
View File
@@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
name: isp-config-service-internal
spec:
clusterIP: None
publishNotReadyAddresses: True
selector:
app: isp-config-service
ports:
- protocol: TCP
port: 4001
targetPort: 4001
---
apiVersion: v1
kind: Service
metadata:
name: isp-config-service
spec:
selector:
app: isp-config-service
ports:
- protocol: TCP
name: ws
port: 9001
targetPort: 9001
- protocol: TCP
name: grpc
port: 9002
targetPort: 9002
+87
View File
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: isp-config-service
spec:
selector:
matchLabels:
app: isp-config-service # has to match .spec.template.metadata.labels
serviceName: isp-config-service-internal
replicas: 3
podManagementPolicy: "Parallel"
template:
metadata:
labels:
app: isp-config-service # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
imagePullSecrets:
- name: regcred
containers:
- name: isp-config-service
image: isp-config-service:latest
imagePullPolicy: Always
env:
- name: rqlite.NodeID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: rqlite.BootstrapExpect
value: "3"
- name: rqlite.HttpAddr
value: "0.0.0.0:4001"
- name: rqlite.HttpAdv
value: "$HOSTNAME:4001"
- name: rqlite.RaftAddr
value: "0.0.0.0:4002"
- name: rqlite.RaftAdv
value: "$HOSTNAME:4002"
- name: rqlite.JoinAddrs
value: ""
- name: rqlite.DiscoMode
value: "dns"
- name: rqlite.DiscoConfig
value: "{\"name\":\"isp-config-service-internal\"}"
- name: rqlite.JoinInterval
value: "1s"
- name: rqlite.JoinAttempts
value: "120"
- name: rqlite.RaftClusterRemoveOnShutdown
value: "true"
ports:
- containerPort: 4001
name: rqlite
readinessProbe:
httpGet:
scheme: HTTP
path: /readyz
port: rqlite
httpHeaders:
- name: Authorization
value: Basic bW9uaXRvcjptb25pdG9y
periodSeconds: 5
timeoutSeconds: 2
initialDelaySeconds: 2
livenessProbe:
httpGet:
scheme: HTTP
path: /readyz?noleader
port: rqlite
httpHeaders:
- name: Authorization
value: Basic bW9uaXRvcjptb25pdG9y
initialDelaySeconds: 5
timeoutSeconds: 2
failureThreshold: 3
volumeMounts:
- name: isp-config-service-data
mountPath: /app/data
volumeClaimTemplates:
- metadata:
name: isp-config-service-data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "local-path"
resources:
requests:
storage: 1Gi
+719 -611
View File
File diff suppressed because it is too large. Load diff
+36
View File
@@ -0,0 +1,36 @@
package domain
import (
"fmt"
"strings"
)
const (
ErrorCodeBadRequest = 400
ErrorCodeModuleNotFound = 2001
ErrorCodeConfigNotFound = 2002
ErrorCodeInvalidConfig = 2003
ErrorCodeConfigVersionConflict = 2004
ErrorCodeSchemaNotFound = 2005
ErrorCodeVariableNotFound = 2006
ErrorCodeVariableAlreadyExists = 2007
ErrorCodeVariableUsedInConfigs = 2008
)
type ConfigValidationError struct {
Details map[string]string
}
func NewConfigValidationError(details map[string]string) ConfigValidationError {
return ConfigValidationError{
Details: details,
}
}
func (e ConfigValidationError) Error() string {
descriptions := make([]string, 0, len(e.Details))
for field, err := range e.Details {
descriptions = append(descriptions, fmt.Sprintf("%s -> %s", field, err))
}
return strings.Join(descriptions, "; ")
}
+37 -10
View File
@@ -1,25 +1,52 @@
package domain
import "isp-config-service/entity"
import (
"github.com/txix-open/isp-kit/json"
)
type ConfigIdRequest struct {
Id string `json:"id" valid:"required~Required"`
type IdRequest struct {
Id string `validate:"required"`
}
type CompileConfigsRequest struct {
Data map[string]interface{}
CommonConfigsIdList []string
type PurgeConfigVersionsRequest struct {
ModuleName string `validate:"required"`
KeepVersions int `validate:"required"`
}
type GetByModuleIdRequest struct {
ModuleId string `valid:"required~Required"`
ModuleId string `validate:"required"`
}
type GetByModuleNameRequest struct {
ModuleName string `valid:"required~Required"`
ModuleName string `validate:"required"`
}
type UpdateSchemaRequest struct {
ModuleName string `validate:"required"`
Schema json.RawMessage `validate:"required" swaggertype:"object"`
}
type CreateUpdateConfigRequest struct {
entity.Config
Unsafe bool
Id string
Name string `validate:"required"`
ModuleId string `validate:"required"`
Version int
Data json.RawMessage `swaggertype:"object"`
Unsafe bool
}
type UpdateConfigNameRequest struct {
Id string `validate:"required"`
NewConfigName string `validate:"required"`
}
type SyncConfigRequest struct {
ModuleName string `validate:"required"`
}
type PrometheusTargets struct {
Targets []string
Labels map[string]string
}
type AutodiscoveryResponse []PrometheusTargets
+65 -26
View File
@@ -3,50 +3,89 @@ package domain
import (
"time"
"github.com/integration-system/isp-lib/v2/config/schema"
"github.com/integration-system/isp-lib/v2/structure"
"isp-config-service/entity"
"github.com/txix-open/isp-kit/json"
)
type DeleteResponse struct {
Deleted int
}
type CreateUpdateConfigResponse struct {
Config
IsChanged bool
}
type ModuleInfo struct {
Id string
Name string
Active bool
LastConnectedAt *time.Time
LastDisconnectedAt *time.Time
ConfigSchema json.RawMessage `swaggertype:"object"`
Status []Connection
CreatedAt time.Time
LastConnectedAt time.Time
LastDisconnectedAt time.Time
Configs []ConfigModuleInfo `json:",omitempty"`
ConfigSchema *schema.Schema `json:",omitempty"`
Status []Connection `json:",omitempty"`
}
type Connection struct {
LibVersion string
Version string
Address structure.AddressConfiguration
Endpoints []structure.EndpointDescriptor `json:",omitempty"`
EstablishedAt time.Time
Id string
ModuleName string
LibVersion string
Version string
Address Address
IsModuleLeader bool
Transport string
Endpoints []EndpointDescriptor
EstablishedAt time.Time
}
type CommonConfigLinks map[string][]string
type CompiledConfigResponse map[string]interface{}
type DeleteCommonConfigResponse struct {
Deleted bool
Links CommonConfigLinks
type Address struct {
Ip string
Port string
}
type CreateUpdateConfigResponse struct {
ErrorDetails map[string]string
Config *ConfigModuleInfo
type EndpointDescriptor struct {
HttpMethod string
Path string
Inner bool
}
type ConfigModuleInfo struct {
entity.Config
Valid bool
type Config struct {
Id string
Name string
ModuleId string
Valid bool
Data json.RawMessage `swaggertype:"object"`
Version int
Active bool
CreatedAt time.Time
UpdatedAt time.Time
}
type ConfigVersion struct {
Id string
ConfigId string
ConfigVersion int
Data json.RawMessage `swaggertype:"object"`
CreatedAt time.Time
}
type ConfigSchema struct {
Id string
Version string
ModuleId string
Schema json.RawMessage `swaggertype:"object"`
CreatedAt time.Time
UpdatedAt time.Time
}
type ModuleRelation struct {
Id string
Name string
RequiredModules []RequiredModuleType
}
type RequiredModuleType struct {
Id string
Name string
}
+52
View File
@@ -0,0 +1,52 @@
package domain
import (
"time"
"isp-config-service/entity"
)
type Variable struct {
Name string
Description string
Type string
Value string
CreatedAt time.Time
UpdatedAt time.Time
ContainsInConfigs []LinkedConfig
}
type LinkedConfig struct {
Id string
ModuleId string
Name string
}
type CreateVariableRequest struct {
Name string `validate:"required"`
Description string
Type string `validate:"required,oneof=SECRET TEXT"`
Value string `validate:"required"`
}
type UpdateVariableRequest struct {
Name string `validate:"required"`
Description string
Value string `validate:"required"`
}
type UpsertVariableRequest struct {
Name string `validate:"required"`
Description string
Type string `validate:"required,oneof=SECRET TEXT"`
Value string `validate:"required"`
}
type VariableByNameRequest struct {
Name string `validate:"required"`
}
type VariableExtractionResult struct {
VariableLinks []entity.ConfigHasVariable
AbsentVariables []string
}
+28
View File
@@ -0,0 +1,28 @@
package entity
import (
"github.com/txix-open/isp-kit/cluster"
"isp-config-service/entity/xtypes"
)
// nolint: tagliatelle
type Backend struct {
WsConnectionId string `json:"ws_connection_id"`
ModuleId string `json:"module_id"`
Address string `json:"address"`
Version string `json:"version"`
LibVersion string `json:"lib_version"`
ModuleName string `json:"module_name"`
Transport string `json:"transport"`
ModuleLeaderMode string `json:"module_leader_mode"`
ConfigServiceNodeId string `json:"config_service_node_id"`
Endpoints xtypes.Json[[]cluster.EndpointDescriptor] `json:"endpoints"`
RequiredModules xtypes.Json[[]cluster.ModuleDependency] `json:"required_modules"`
CreatedAt xtypes.Time `json:"created_at"`
MetricsAutodiscovery *xtypes.Json[cluster.MetricsAutodiscovery] `json:"metrics_autodiscovery"`
}
// nolint: tagliatelle
type MetricsAdWrapper struct {
MetricsAutodiscovery xtypes.Json[cluster.MetricsAutodiscovery] `json:"metrics_autodiscovery"`
}
+32 -34
View File
@@ -1,46 +1,44 @@
// nolint: tagliatelle
package entity
import (
"time"
"github.com/integration-system/isp-lib/v2/config/schema"
"isp-config-service/entity/xtypes"
)
type ConfigData map[string]interface{}
type Config struct {
//nolint
tableName string `sql:"?db_schema.configs" json:"-"`
Id string `json:"id"`
Name string `json:"name" valid:"required~Required"`
CommonConfigs []string `json:"commonConfigs" pg:",array"`
Description string `json:"description"`
ModuleId string `json:"moduleId" valid:"required~Required"`
Version int32 `json:"version" sql:",null"`
Active bool `json:"active" sql:",null"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
UpdatedAt time.Time `json:"updatedAt" sql:",null"`
Data ConfigData `json:"data" sql:",notnull"`
Id string `json:"id"`
Name string `json:"name"`
ModuleId string `json:"module_id"`
Data []byte `json:"data"`
Version int `json:"version"`
Active xtypes.Bool `json:"active"`
AdminId int `json:"admin_id"`
CreatedAt xtypes.Time `json:"created_at"`
UpdatedAt xtypes.Time `json:"updated_at"`
}
type CommonConfig struct {
//nolint
tableName string `sql:"?db_schema.common_configs" json:"-"`
Id string `json:"id"`
Name string `json:"name" valid:"required~Required"`
Description string `json:"description"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
UpdatedAt time.Time `json:"updatedAt" sql:",null"`
Data ConfigData `json:"data" sql:",notnull"`
type ConfigMetaWithVariable struct {
Id string `json:"id"`
Name string `json:"name"`
ModuleId string `json:"module_id"`
VariableName string `json:"variable_name"`
Active xtypes.Bool `json:"active"`
}
type ConfigHistory struct {
Id string `json:"id"`
ConfigId string `json:"config_id"`
Data []byte `json:"data"`
Version int `json:"version"`
AdminId int `json:"admin_id"`
CreatedAt xtypes.Time `json:"created_at"`
}
type ConfigSchema struct {
//nolint
tableName string `sql:"?db_schema.config_schemas" json:"-"`
Id string `json:"id"`
Version string
ModuleId string
Schema schema.Schema
CreatedAt time.Time
UpdatedAt time.Time
Id string `json:"id"`
ModuleId string `json:"module_id"`
Data []byte `json:"data"`
ModuleVersion string `json:"module_version"`
CreatedAt xtypes.Time `json:"created_at"`
UpdatedAt xtypes.Time `json:"updated_at"`
}
+16
View File
@@ -0,0 +1,16 @@
package entity
import (
"github.com/txix-open/isp-kit/errors"
)
var (
ErrConfigNotFound = errors.New("no active config")
ErrModuleNotFound = errors.New("module not found")
ErrSchemaNotFound = errors.New("config schema not found")
ErrConfigNotFoundOrActive = errors.New("config not found or markers as active")
ErrConfigConflictUpdate = errors.New("config conflict update")
ErrVariableNotFound = errors.New("variable not found")
ErrVariableAlreadyExists = errors.New("variable already exists")
ErrVariableUsedInConfigs = errors.New("variable used in configs")
)
+52
View File
@@ -0,0 +1,52 @@
package entity
import (
"fmt"
"isp-config-service/entity/xtypes"
)
type Event struct {
Id int `json:"id"`
Payload xtypes.Json[EventPayload] `json:"payload"`
}
func NewEvent(payload EventPayload) Event {
return Event{
Payload: xtypes.Json[EventPayload]{
Value: payload,
},
}
}
func (e Event) Key() string {
switch {
case e.Payload.Value.ConfigUpdated != nil:
return fmt.Sprintf("config_updated_%s", e.Payload.Value.ConfigUpdated.ModuleId)
case e.Payload.Value.ModuleReady != nil:
return fmt.Sprintf("module_lifecycle_%s", e.Payload.Value.ModuleReady.ModuleId)
case e.Payload.Value.ModuleDisconnected != nil:
return fmt.Sprintf("module_lifecycle_%s", e.Payload.Value.ModuleDisconnected.ModuleId)
default:
return ""
}
}
// nolint:tagliatelle
type EventPayload struct {
ConfigUpdated *PayloadConfigUpdated `json:",omitempty"`
ModuleReady *PayloadModuleReady `json:",omitempty"`
ModuleDisconnected *PayloadModuleDisconnected `json:",omitempty"`
}
type PayloadConfigUpdated struct {
ModuleId string
}
type PayloadModuleReady struct {
ModuleId string
}
type PayloadModuleDisconnected struct {
ModuleId string
}
+9 -8
View File
@@ -1,13 +1,14 @@
package entity
import "time"
import (
"isp-config-service/entity/xtypes"
)
// nolint:tagliatelle
type Module struct {
//nolint
tableName string `sql:"?db_schema.modules" json:"-"`
Id string `json:"id"`
Name string `json:"name" valid:"required~Required"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
LastConnectedAt time.Time `json:"lastConnectedAt"`
LastDisconnectedAt time.Time `json:"lastDisconnectedAt"`
Id string `json:"id"`
Name string `json:"name"`
LastConnectedAt *xtypes.Time `json:"last_connected_at"`
LastDisconnectedAt *xtypes.Time `json:"last_disconnected_at"`
CreatedAt xtypes.Time `json:"created_at"`
}
+20
View File
@@ -0,0 +1,20 @@
// nolint:tagliatelle
package entity
import (
"isp-config-service/entity/xtypes"
)
type Variable struct {
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
Value string `json:"value"`
CreatedAt xtypes.Time `json:"created_at"`
UpdatedAt xtypes.Time `json:"updated_at"`
}
type ConfigHasVariable struct {
ConfigId string `json:"config_id"`
VariableName string `json:"variable_name"`
}
+23
View File
@@ -0,0 +1,23 @@
package xtypes
type Bool bool
func (l Bool) MarshalJSON() ([]byte, error) {
return l.MarshalText()
}
func (l *Bool) UnmarshalJSON(data []byte) error {
return l.UnmarshalText(data)
}
func (l Bool) MarshalText() ([]byte, error) {
if l {
return []byte("1"), nil
}
return []byte("0"), nil
}
func (l *Bool) UnmarshalText(data []byte) error {
*l = string(data) == "1"
return nil
}
+44
View File
@@ -0,0 +1,44 @@
package xtypes
import (
"strconv"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/json"
)
type Json[T any] struct {
Value T
}
func (l Json[T]) MarshalJSON() ([]byte, error) {
data, err := l.MarshalText()
if err != nil {
return nil, err
}
return []byte(strconv.Quote(string(data))), nil
}
func (l *Json[T]) UnmarshalJSON(data []byte) error {
s, err := strconv.Unquote(string(data))
if err != nil {
return errors.WithMessage(err, "unquote text")
}
return l.UnmarshalText([]byte(s))
}
func (l Json[T]) MarshalText() ([]byte, error) {
data, err := json.Marshal(l.Value)
if err != nil {
return nil, errors.WithMessage(err, "marshal json")
}
return data, nil
}
func (l *Json[T]) UnmarshalText(data []byte) error {
err := json.Unmarshal(data, &l.Value)
if err != nil {
return errors.WithMessage(err, "unmarshal json")
}
return nil
}
+36
View File
@@ -0,0 +1,36 @@
package xtypes
import (
"strconv"
"time"
"github.com/txix-open/isp-kit/errors"
)
type Time time.Time
func (l Time) MarshalJSON() ([]byte, error) {
return l.MarshalText()
}
func (l *Time) UnmarshalJSON(data []byte) error {
return l.UnmarshalText(data)
}
func (l Time) MarshalText() ([]byte, error) {
t := time.Time(l)
value := strconv.Itoa(int(t.Unix()))
return []byte(value), nil
}
func (l *Time) UnmarshalText(data []byte) error {
if string(data) == "null" {
return nil
}
value, err := strconv.Atoi(string(data))
if err != nil {
return errors.WithMessagef(err, "parse int: %s", string(data))
}
*l = Time(time.Unix(int64(value), 0))
return nil
}
+118 -19
View File
@@ -1,25 +1,124 @@
module isp-config-service
go 1.13
go 1.27
replace (
github.com/armon/go-metrics => github.com/hashicorp/go-metrics v0.5.1
github.com/mattn/go-sqlite3 => github.com/rqlite/go-sqlite3 v1.48.0
)
require (
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f
github.com/cenkalti/backoff/v4 v4.0.0
github.com/go-pg/pg/v9 v9.1.3
github.com/hashicorp/raft v1.1.2
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c
github.com/integration-system/isp-etp-go/v2 v2.1.0
github.com/integration-system/isp-lib-test v1.5.0
github.com/integration-system/isp-lib/v2 v2.2.0
github.com/integration-system/isp-log v1.1.2
github.com/integration-system/net-mux v1.0.0
github.com/json-iterator/go v1.1.9
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/pkg/errors v0.9.1
github.com/satori/go.uuid v1.2.0
github.com/stretchr/testify v1.5.1
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3
github.com/Masterminds/squirrel v1.5.4
github.com/google/uuid v1.6.0
github.com/pressly/goose/v3 v3.30.1
github.com/prometheus/client_golang v1.25.0
github.com/rqlite/gorqlite v0.0.0-20250609141355-ac86a4a1c9a8
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099
github.com/rqlite/rqlite/v10 v10.2.7
github.com/stretchr/testify v1.12.1
github.com/tidwall/gjson v1.18.0
github.com/txix-open/etp/v4 v4.1.3
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60
github.com/txix-open/isp-kit v1.76.0
github.com/xeipuuv/gojsonschema v1.2.0
google.golang.org/grpc v1.27.1
golang.org/x/sync v0.25.0
google.golang.org/grpc v1.85.0
)
require (
github.com/armon/go-metrics v0.6.0 // indirect
github.com/aws/aws-sdk-go-v2 v1.42.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.13 // indirect
github.com/aws/aws-sdk-go-v2/config v1.32.25 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.19.24 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.28 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.22 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.29 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.104.0 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.2.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.31.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.6 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect
github.com/aws/smithy-go v1.27.2 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/buger/jsonparser v1.6.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.15 // indirect
github.com/fatih/color v1.19.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
github.com/getsentry/sentry-go v0.50.0 // indirect
github.com/go-faker/faker/v4 v4.12.0 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.2 // indirect
github.com/go-playground/universal-translator v0.18.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-metrics v0.6.0 // indirect
github.com/hashicorp/go-msgpack v1.1.5 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.5 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/raft v1.7.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.20.4 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.5.0 // indirect
github.com/mailru/easyjson v0.9.2 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/mattn/go-sqlite3 v1.14.47 // indirect
github.com/mfridman/interpolate v0.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pandatix/go-abnf v0.5.5 // indirect
github.com/prometheus/client_model v0.6.3 // indirect
github.com/prometheus/common v0.74.0 // indirect
github.com/prometheus/procfs v0.23.0 // indirect
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 // indirect
github.com/rqlite/sql v0.0.0-20260224021119-1b2524a41372 // indirect
github.com/sethvargo/go-retry v0.5.0 // indirect
github.com/tidwall/match v1.2.0 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/txix-open/bellows v1.2.0 // indirect
github.com/txix-open/jsonschema v1.3.0 // indirect
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
go.etcd.io/bbolt v1.5.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 // indirect
go.opentelemetry.io/otel v1.47.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
go.opentelemetry.io/otel/log v1.47.0 // indirect
go.opentelemetry.io/otel/metric v1.47.0 // indirect
go.opentelemetry.io/otel/sdk v1.47.0 // indirect
go.opentelemetry.io/otel/trace v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.28.0 // indirect
go.yaml.in/yaml/v3 v3.0.6 // indirect
golang.org/x/crypto v0.59.0 // indirect
golang.org/x/net v0.63.0 // indirect
golang.org/x/sys v0.50.0 // indirect
golang.org/x/text v0.44.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f // indirect
google.golang.org/protobuf v1.36.12 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+314 -343
View File
@@ -1,427 +1,398 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878 h1:EFSB7Zo9Eg91v7MJPVsifUysc/wPdN+NOnVe6bWbdBM=
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg=
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f h1:y2hSFdXeA1y5z5f0vfNO0Dg5qVY036qzlz3Pds0B92o=
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/aws/aws-sdk-go-v2 v1.42.0 h1:XvXMJTkFQtpBKIWZnmr9ZEOc2InWM2yldjXEJ/bymhA=
github.com/aws/aws-sdk-go-v2 v1.42.0/go.mod h1:27+ACypSLljLAEKsCYOmrjKh83vuTRkuAe9Uv/3A4bg=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.13 h1:p1BBrg/Hhp6uK7zpejeI8QFXHJeC/mynzi04Sl03k9g=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.13/go.mod h1:8cIfkE9MDhkRZGpQ22aV6/lkYeYSozpz16Smrs5x4Ls=
github.com/aws/aws-sdk-go-v2/config v1.32.25 h1:ACCejvStYoilgwrfegSt5ZntCbPrk52qfwyNcnl3omM=
github.com/aws/aws-sdk-go-v2/config v1.32.25/go.mod h1:LJyU8sDRbXUxFn8xMJIGP+v9QYYwveNLI8a/giAOiAs=
github.com/aws/aws-sdk-go-v2/credentials v1.19.24 h1:2hQqYCV9yqyePQ9o6dCrZc/zO8U3TwPr9mIKlZnPu/I=
github.com/aws/aws-sdk-go-v2/credentials v1.19.24/go.mod h1:IDwpACtwqHLISdzfwUUNq4P9DsB/h5BLg4FwJPNfqFY=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29 h1:r6qZHbT+wxgWO/e9vYNUEtg7lv5+UN3pRqKhLXvnArg=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.29/go.mod h1:QRnaRcTVGKPGRy8w78HMQtKUGRYcnMZAANATkeVA6Mo=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.28 h1:ez4y5o7sa0uaRI8BquYOXtZpioUPhbQEh7Igm88oV9U=
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.28/go.mod h1:TpmZOrQA12XKEpVypgBGZSQBsm1WUTndCiSnbDsbvug=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29 h1:f3vKqSo13fhTYb+JEcXwXefZQE26I1FB5eTSniU67ko=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.29/go.mod h1:MzoLFUArKGpGD+ukmPiTPG1X5x4o6M2kq4v2dr1FiEc=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29 h1:RdwIf/CuUsvJX3RgJagbOyotl/cxoLY4xviKuE7p2GY=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.29/go.mod h1:71wt8W2EgswdZy9Mf9KNnzxZ3TiZlv4caKghPktDOkA=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30 h1:VTGy885W5DKBxWRUJbym9hytNaYzsyaPkCHGRRMAOhU=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.30/go.mod h1:AS0HycUvJRFvTt613AYDOgO2jzw+00cVSMny8XB3yMY=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12 h1:ZD2+BSw9vFsNlKYIasSNt3uDbjqqXIBcM13UJv/Lx2k=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.12/go.mod h1:Ms4zlcVBbXbiP7EVLhl+lgjvA/a7YphqQ3Ih3174EmI=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.22 h1:V51LGlOq/1VsDsHUdoklAQi7rMmx4qQubvFYAlP2254=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.22/go.mod h1:4Pzhyz8hJOm2bepgl+NjvRx8vlUFAIIvJnZ/MkcNPpU=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29 h1:DRebniUGZ2MqiiIVmQJ04vIXr918hubdHMnarSLEWyU=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.29/go.mod h1:LfRkPCD8YHDM2E5eTkos2UpwYeZnBcVarTa8L59bJHA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.29 h1:hiME6pBzC7OTl9LMtlyTWBuEl1f4QBcUmFDKC7MLXtc=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.29/go.mod h1:G7RP+uhagpKtKhd1BM9N6JQqjCcGEU47K5lBVZQyRQw=
github.com/aws/aws-sdk-go-v2/service/s3 v1.104.0 h1:ta8csKy5vN91F3i5gGR85lFV0srBqySEji7Jroes6rE=
github.com/aws/aws-sdk-go-v2/service/s3 v1.104.0/go.mod h1:77ZAgynvx1txMvDG8gGWoWkO1augYDxkp9JElWFgjQU=
github.com/aws/aws-sdk-go-v2/service/signin v1.2.0 h1:3nXpRcFwRCW8n7HgO2QGy0Dc20eQNfBuUemGQhpF8m8=
github.com/aws/aws-sdk-go-v2/service/signin v1.2.0/go.mod h1:LxYujSTLPRlp2vTtcUO/+1ilrew8ytt6SvQyOgejzFQ=
github.com/aws/aws-sdk-go-v2/service/sso v1.31.3 h1:ey1XLTYXb9PcLt4535632o5kCGXNXEhNb620Dqwuylo=
github.com/aws/aws-sdk-go-v2/service/sso v1.31.3/go.mod h1:Lk7PlmoTYryQmyBG0EXqj5BcUbj3whXdU2s3yGI3EAc=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.6 h1:yLr03zQE/5Eu5l3QU0Si+xMbLMbSDF2YXsigqXngs6g=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.36.6/go.mod h1:Q5N6icH+KJZDLh+ESNwzdv6cZ6vLFF/egy3IOxWhmz4=
github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 h1:VrIhKRCSK1umelSgB9RghvA9RTUYeQffyAS5ApXehNI=
github.com/aws/aws-sdk-go-v2/service/sts v1.43.3/go.mod h1:r8wkDOuLaaMFqFiYAb8dGY2A3gJCOujMc6CFOVC4Zhc=
github.com/aws/smithy-go v1.27.2 h1:y9NPmSE6am6LjEFPfqHqG/jJk7AauQvhCJONKh7kpzk=
github.com/aws/smithy-go v1.27.2/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/buaazp/fasthttprouter v0.1.1 h1:4oAnN0C3xZjylvZJdP35cxfclyn4TYkW6Y+DSvS+h8Q=
github.com/buaazp/fasthttprouter v0.1.1/go.mod h1:h/Ap5oRVLeItGKTVBb+heQPks+HdIUtGmI4H5WCYijM=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.0.0 h1:6VeaLF9aI+MAUQ95106HwWzYZgJJpZ4stumjj6RFYAU=
github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs=
github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/codemodus/kace v0.5.1 h1:4OCsBlE2c/rSJo375ggfnucv9eRzge/U5LrrOZd47HA=
github.com/codemodus/kace v0.5.1/go.mod h1:coddaHoX1ku1YFSe4Ip0mL9kQjJvKkzb9CfIdG1YR04=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-faker/faker/v4 v4.12.0 h1:yZXxuoQjxN+C2PVgYoDSHGiD9wj6dX1/Ful4p7QQV0k=
github.com/go-faker/faker/v4 v4.12.0/go.mod h1:VFIEwWDd16EdYDLF6NJ5gAAzEp7vz5LgKgJ2iZ17Tdg=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-pg/pg/v9 v9.0.0-beta.14/go.mod h1:T2Sr6bpTCOr2lUqOUMiXLMJqZHSUBKk1LdgSqjwhZfA=
github.com/go-pg/pg/v9 v9.0.3/go.mod h1:Tm/Q3Vt6gdQOH6TTN1H/xLlIXc+Qrka7TZ6uREtu/eA=
github.com/go-pg/pg/v9 v9.1.2/go.mod h1:AOJqkP8C4YfJgLOA5zSoV0DGHGo+M3G2nXXLeXkiyNs=
github.com/go-pg/pg/v9 v9.1.3 h1:gmE7k5ib45+NcRJBGUDPD/keJGCMqhH7TPqbd9xbdz4=
github.com/go-pg/pg/v9 v9.1.3/go.mod h1:QM13HBLkdml4zcKOfUfGLymM6hb72aKTJLrmaH8rsFg=
github.com/go-pg/urlstruct v0.1.0/go.mod h1:2Nag+BIny6G/KYCkdt++ZnqU/VinzimGapKfs4kwlN0=
github.com/go-pg/urlstruct v0.2.6/go.mod h1:dxENwVISWSOX+k87hDt0ueEJadD+gZWv3tHzwfmZPu8=
github.com/go-pg/urlstruct v0.2.8/go.mod h1:/XKyiUOUUS3onjF+LJxbfmSywYAdl6qMfVbX33Q8rgg=
github.com/go-pg/urlstruct v0.3.0 h1:ORiTb205uT7v7lvq4VUOQ4ddJ5TjFRlVRWqWsMBgek4=
github.com/go-pg/urlstruct v0.3.0/go.mod h1:/XKyiUOUUS3onjF+LJxbfmSywYAdl6qMfVbX33Q8rgg=
github.com/go-pg/zerochecker v0.1.1 h1:av77Qe7Gs+1oYGGh51k0sbZ0bUaxJEdeP0r8YE64Dco=
github.com/go-pg/zerochecker v0.1.1/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo=
github.com/go-redis/redis v6.15.6+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0/go.mod h1:FHXQZnW5pA0txiMr3jApv9uNJzZ+7mYZd+u+PPenCFU=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM=
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-metrics v0.6.0 h1:+kjWqHRH2HxAocneVfB/BI6EeWUUHyPhyQZozMT8Ed4=
github.com/hashicorp/go-metrics v0.6.0/go.mod h1:0B52B5pZ7+qm5Zhzs8Fygr87isvmUgr0Zv9rmJ9qsnQ=
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs=
github.com/hashicorp/go-msgpack v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4=
github.com/hashicorp/go-msgpack/v2 v2.1.5 h1:Ue879bPnutj/hXfmUk6s/jtIK90XxgiUIcXRl656T44=
github.com/hashicorp/go-msgpack/v2 v2.1.5/go.mod h1:bjCsRXpZ7NsJdk45PoCQnzRGDaK8TKm5ZnDI/9y3J4M=
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM=
github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
github.com/hashicorp/raft v1.1.2 h1:oxEL5DDeurYxLd3UbcY/hccgSPhLLpiBZ1YxtWEq59c=
github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk=
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617 h1:CJDRE/2tBNFOrcoexD2nvTRbQEox3FDxl4NxIezp1b8=
github.com/hashicorp/raft-boltdb v0.0.0-20191021154308-4207f1bf0617/go.mod h1:aUF6HQr8+t3FC/ZHAC+pZreUBhTaxumuu3L+d37uRxk=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c h1:yyIH4qCFf5LD5PKhXoX4BZh3wRjd59xBV4eAQTBwS6k=
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c/go.mod h1:6cf4ZNvtzZ/KMiuc+d5Y7rSHjzlYBWEqbVyDfUDhqIE=
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f h1:52UOJguw5yqe1y2JjmyVxGcZf3kv2BQeUodR363MkiQ=
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f/go.mod h1:w+dmaWojuIwNujSYg6qt1wKHhSdorLOivCEl/XuLzbM=
github.com/integration-system/gowsdl v1.0.0/go.mod h1:ZwTCE+Av5aQLnPj2/3PIop6mzCs1FY7jXrcWDvSjrBA=
github.com/integration-system/isp-etp-go v2.0.2+incompatible h1:+aQiqH/aMy9pUsifIxfWU/DD8cwbMo24AAIV7Ab6aP4=
github.com/integration-system/isp-etp-go v2.0.2+incompatible/go.mod h1:NdgczkoFCer9SZOx674EVXCcKRIhFe8LYnwNwoIMDhI=
github.com/integration-system/isp-etp-go/v2 v2.1.0 h1:qRw4J04vwYxSm52OUIt6lKWpxEQE2aZjUT7kZDG/A4Q=
github.com/integration-system/isp-etp-go/v2 v2.1.0/go.mod h1:Ndq5DMM3sDJjZn4cyKKvZrVED0FMeoXMRWHZTq+2Z1o=
github.com/integration-system/isp-lib-test v1.5.0 h1:5Q2qYpesVA0zj0d0ZbWPZgBM0cS+cHf2vH6MxXvNA10=
github.com/integration-system/isp-lib-test v1.5.0/go.mod h1:GAk7oPXp9KEuNeav2oaun5E/rlh5iomM/F/b2CqEycc=
github.com/integration-system/isp-lib/v2 v2.2.0 h1:qabF1/Q66Z0ldOIlsztD/P4WEuskYICFJHjMoJhUi08=
github.com/integration-system/isp-lib/v2 v2.2.0/go.mod h1:s3UWKnmCns7uaxAX1i04Le32+FFuoDgp8QLhOZAmNZE=
github.com/integration-system/isp-log v1.0.0/go.mod h1:omfVcb7djvmc0MYWpRq32D9jxRYhyBL518IcdBL9jKY=
github.com/integration-system/isp-log v1.1.2 h1:bnWxPjDOC1Y/tEzFxa42aG+xaPRWizuJADAwXgp2i5U=
github.com/integration-system/isp-log v1.1.2/go.mod h1:VVMr3cHW+RuFurPUSeVz71KUnOGQxogxO5atV9N8ISs=
github.com/integration-system/jsonschema v1.0.0 h1:Lci4sHGhOX27qCgZo5rvJ37Bjcfm+qCwU0yvw6ImEX4=
github.com/integration-system/jsonschema v1.0.0/go.mod h1:EoqDH7RmC8Epg5EgjboIxDo7Udv3WX2exGqtIVB4hI0=
github.com/integration-system/net-mux v1.0.0 h1:UY5y9cDq4ngfYaVzwqcIZ2FDw2l0H4slVDXp1E2gopc=
github.com/integration-system/net-mux v1.0.0/go.mod h1:R2PRrXFCOQRbjYIeiJFA6y2/3CfMYEX20H6yrIN6c7g=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/hashicorp/raft v1.7.3 h1:DxpEqZJysHN0wK+fviai5mFcSYsCkNpFUl1xpAW8Rbo=
github.com/hashicorp/raft v1.7.3/go.mod h1:DfvCGFxpAUPE0L4Uc8JLlTPtc3GzSbdH0MTJCLgnmJQ=
github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea/go.mod h1:qRd6nFJYYS6Iqnc/8HcUmko2/2Gw8qTFEmxDLii6W5I=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
github.com/klauspost/compress v1.20.4/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
github.com/mailru/easyjson v0.9.2/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/mfridman/interpolate v0.2.0 h1:HM9ID8p6CUxoMJX+fECOtGQ2Mu7TW/GIMPyu48nnvUg=
github.com/mfridman/interpolate v0.2.0/go.mod h1:8SfDy95IaPNnIokZh9mvIppmc3fGl8fx+Gu7uusuO9Q=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
github.com/nats-io/nats-server/v2 v2.1.4/go.mod h1:Jw1Z28soD/QasIA2uWjXyM9El1jly3YwyFOuR8tH1rg=
github.com/nats-io/nats-streaming-server v0.17.0/go.mod h1:ewPBEsmp62Znl3dcRsYtlcfwudxHEdYMtYqUQSt4fE0=
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olivere/elastic v6.2.26+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
github.com/ncruces/go-strftime v1.1.0/go.mod h1:yVaq7iwCN09vHRrKBrrflXT0M9tTMG2KmZ9Fj7xeG/g=
github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM=
github.com/pandatix/go-abnf v0.5.5/go.mod h1:AE0KD3/VNoCjGzc1gqetRKshbI4SYErXQ/8kPenR5mc=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pressly/goose v2.6.0+incompatible h1:3f8zIQ8rfgP9tyI0Hmcs2YNAqUCL1c+diLe3iU8Qd/k=
github.com/pressly/goose v2.6.0+incompatible/go.mod h1:m+QHWCqxR3k8D9l7qfzuC/djtlfzxr34mozWDYEu1z8=
github.com/pressly/goose/v3 v3.30.1 h1:KO28meBdbAUIdMbTP7bl9dp1FYZGXcYWb2O7miT09lE=
github.com/pressly/goose/v3 v3.30.1/go.mod h1:CHGwuG2acDerUaXwz2i5T18VSauXpYDiL4WxzDvcOIM=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 h1:dY6ETXrvDG7Sa4vE8ZQG4yqWg6UnOcbqTAahkV813vQ=
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/segmentio/encoding v0.1.8/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
github.com/segmentio/encoding v0.1.10 h1:0b8dva47cSuNQR5ZcU3d0pfi9EnPpSK6q7y5ZGEW36Q=
github.com/segmentio/encoding v0.1.10/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
github.com/rabbitmq/amqp091-go v1.17.0 h1:6KmTqrnJq93cGIE3Q3UnXgsqw6NtLu8MNfFoIbfBAIQ=
github.com/rabbitmq/amqp091-go v1.17.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rqlite/go-sqlite3 v1.48.0 h1:3z/QU1WEFrywWvhjhLvZ+SBkaoIQZtkNcHgpCaxE1eg=
github.com/rqlite/go-sqlite3 v1.48.0/go.mod h1:XIq9SQymduohsJwPy++jWepF9QJ5gT/S3SkUivYSVZ0=
github.com/rqlite/gorqlite v0.0.0-20250609141355-ac86a4a1c9a8 h1:BoxiqWvhprOB2isgM59s8wkgKwAoyQH66Twfmof41oE=
github.com/rqlite/gorqlite v0.0.0-20250609141355-ac86a4a1c9a8/go.mod h1:xF/KoXmrRyahPfo5L7Szb5cAAUl53dMWBh9cMruGEZg=
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 h1:NZ62M+kT0JqhyFUMc8I4SMmfmD4NGJxhb2ePJQXjryc=
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48/go.mod h1:CRnsxgy5G8fAf5J+AM0yrsSdxXHKkIYOaq2sm+Q4DYc=
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099 h1:5cqkVLdl6sGJSY3kiF2dqaA3bD+8OS5FUdZqO0BxXLU=
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099/go.mod h1:6SVI8KegsW9Fyu2UQ+uvw0JI5CAILRYRyiQ/OFSJPrs=
github.com/rqlite/rqlite/v10 v10.2.7 h1:fUsbbgoELw+MrKfQ9EkVrm8tA0rdVUe/bYYdtOOsnx4=
github.com/rqlite/rqlite/v10 v10.2.7/go.mod h1:iTG1rLhR0zBBWTHiN33b9o/HXVwaC71xrcdoFaUJecE=
github.com/rqlite/sql v0.0.0-20260224021119-1b2524a41372 h1:2V0y6mzmPj7vQKad76nTL7sZ/lFLj5VKvNjpa6IRxYE=
github.com/rqlite/sql v0.0.0-20260224021119-1b2524a41372/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg=
github.com/sethvargo/go-retry v0.5.0 h1:JYfFKmVJ8ER06GReN1efzc5cm52BrVsFVzmcHiKJwfY=
github.com/sethvargo/go-retry v0.5.0/go.mod h1:tvsjdKG6xfiCx4LSiUZ06kcv38xvdVQwv8R6/VnnVWg=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/streadway/amqp v0.0.0-20190312223743-14f78b41ce6d/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3 h1:COy7ekr2jBEd34npP2LvMTqk9UtiLkuvkjiJFHihlTo=
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3/go.mod h1:ehwM4AFY4byYSorQbigh79cKUOUNL3pAOz5eCAQNlGI=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM=
github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw=
github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
github.com/vmihailenco/bufpool v0.1.5 h1:mEO/biwhAgiY97yPMmAdH4PvaIu63C6uGBdfSdoMo/I=
github.com/vmihailenco/bufpool v0.1.5/go.mod h1:fL9i/PRTuS7AELqAHwSU1Zf1c70xhkhGe/cD5ud9pJk=
github.com/vmihailenco/msgpack/v4 v4.3.1/go.mod h1:DuaveEe48abshDmz5UBKyZ+yDugvaeFk5ayfrewUOaw=
github.com/vmihailenco/msgpack/v4 v4.3.5/go.mod h1:DuaveEe48abshDmz5UBKyZ+yDugvaeFk5ayfrewUOaw=
github.com/vmihailenco/msgpack/v4 v4.3.7 h1:Aj4eMY2qXTRfWRwHKJ2n/CWKVy15pCYN327QMJ/OUVs=
github.com/vmihailenco/msgpack/v4 v4.3.7/go.mod h1:Ii+PksJlvFT5ZRcB/4YLAInMIp6a0WOCm0L3BU0aNG4=
github.com/vmihailenco/tagparser v0.1.0/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60 h1:7SZ72lNU69g8eiT5rcRh1ubATZPs/J05NEIN7E47TYM=
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60/go.mod h1:jzpq0uwcdGq0OSNXZ6vv6UJkCOU/fLPgeoz+KkGDYgo=
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
github.com/txix-open/grmq v1.12.0/go.mod h1:6m9CCTQao/HAFalu5rFOZGJ5KLEP6WzzIwj80Ml3KGE=
github.com/txix-open/isp-kit v1.76.0 h1:kqhX2DuoTfeW7BIshedG26TRIfOgX0QOInm606ssGVg=
github.com/txix-open/isp-kit v1.76.0/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 h1:1jE11HLmMHDYYAcE+UmQ5VHgz4stzz0+daJbDWS+sEs=
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3/go.mod h1:Yf41v210LFyYAj+tGmDh7PHdGsTaZjdBzHG0ptUvihw=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/bbolt v1.5.0 h1:S7GAl7Fxv12yohbwFfIbQCGDWbQbtDGPET4P/bD4lxU=
go.etcd.io/bbolt v1.5.0/go.mod h1:mkltfYE5aUHQxUct9N9V+Kp7aSjFqjgrhcXIS70Lrdk=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
go.opentelemetry.io/otel/sdk v1.47.0/go.mod h1:VUc24kiOeoGsxG8G9ULx3fWKvB7jMhnGE8Oi607lgR0=
go.opentelemetry.io/otel/sdk/metric v1.47.0 h1:lfISg2j93VT6yqdk9OfUaZmw/GfcZqCCV3jdXtsPnKw=
go.opentelemetry.io/otel/sdk/metric v1.47.0/go.mod h1:ypLp+mW1Nt2x+Szt3b5/i1syodyts49lMOwxpDI3VGw=
go.opentelemetry.io/otel/trace v1.47.0 h1:JOjX/Oci8K94QHddo+bbfya/Ai/nf6/dt9ZfrFNWSrM=
go.opentelemetry.io/otel/trace v1.47.0/go.mod h1:jNaSLa2PZEYFG6fRjJABAu+bw4FS08uDmPg28lTghu0=
go.opentelemetry.io/proto/otlp v1.11.1 h1:SCrPqH9NE5CmBrOqpjNCiT0X5mGwMyGERXdogfR7Yjw=
go.opentelemetry.io/proto/otlp v1.11.1/go.mod h1:wq8W4aSf6bOy8RZyESOeQFr9Pu7wydWX/TY4sgvrTPg=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI=
go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20191128160524-b544559bb6d1/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200222033325-078779b8f2d8 h1:4l6HGmcZuPkox4Zl1b7SZQfYo8KIKvPe+5VG6ibuUEg=
golang.org/x/net v0.0.0-20200222033325-078779b8f2d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 h1:sfkvUWPNGwSV+8/fNqctR5lS2AqCSqYwXdrjCxp/dXo=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20200211111953-2dc5924e3898 h1:bKX1IGaSj2XD9yfWNts9HKRdQRH0lOZ0S7Nb8meQSlY=
google.golang.org/genproto v0.0.0-20200211111953-2dc5924e3898/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s=
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f/go.mod h1:CPxXEEQ1S9iJmInAF/8MNc8tKWnya8I8Kni9Zh2hV0M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g=
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw=
google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ=
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
nhooyr.io/websocket v1.7.4 h1:w/LGB2sZT0RV8lZYR7nfyaYz4PUbYZ5oF7NBon2M0NY=
nhooyr.io/websocket v1.7.4/go.mod h1:PxYxCwFdFYQ0yRvtQz3s/dC+VEm7CSuC/4b9t8MQQxw=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/libc v1.80.2 h1:3+a4fJZvvzg920ZC0mOepnKPGn7cqCaVeDxm/UnrM1A=
modernc.org/libc v1.80.2/go.mod h1:pvo25Rs3OJEbDqhUV9jdEGevxeLJrJeDmNid/AcQV1g=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.62.0 h1:gMaCjSM1qpl+iOjiWhR1LYP3zqrYDI+5GYLGt6veP2g=
modernc.org/sqlite v1.62.0/go.mod h1:Jzjh1mt4s0HuQ0KvtB1LIuHiGRmU2D5pgj8dUhW7/SE=
-57
View File
@@ -1,57 +0,0 @@
//nolint lll
package helper
import (
"github.com/integration-system/isp-lib/v2/structure"
"isp-config-service/controller"
"isp-config-service/domain"
"isp-config-service/entity"
)
type Handlers struct {
// ===== MODULE =====
DeleteModules func(identities []string) (*domain.DeleteResponse, error) `method:"delete_module" group:"module" inner:"true"`
GetModulesInfo func() ([]domain.ModuleInfo, error) `method:"get_modules_info" group:"module" inner:"true"`
GetModuleByName func(req domain.GetByModuleNameRequest) (*entity.Module, error) `method:"get_by_name" group:"module" inner:"true"`
// ===== CONFIG =====
GetActiveConfigByModuleName func(request domain.GetByModuleNameRequest) (*entity.Config, error) `method:"get_active_config_by_module_name" group:"config" inner:"true"`
CreateUpdateConfig func(config domain.CreateUpdateConfigRequest) (*domain.ConfigModuleInfo, error) `method:"create_update_config" group:"config" inner:"true"`
MarkConfigAsActive func(identity domain.ConfigIdRequest) (*entity.Config, error) `method:"mark_config_as_active" group:"config" inner:"true"`
DeleteConfig func(identities []string) (*domain.DeleteResponse, error) `method:"delete_config" group:"config" inner:"true"`
// ===== COMMON CONFIG =====
GetCommonConfigs func(identities []string) []entity.CommonConfig `method:"get_configs" group:"common_config" inner:"true"`
CreateUpdateCommonConfig func(config entity.CommonConfig) (*entity.CommonConfig, error) `method:"create_update_config" group:"common_config" inner:"true"`
DeleteCommonConfig func(req domain.ConfigIdRequest) (*domain.DeleteCommonConfigResponse, error) `method:"delete_config" group:"common_config" inner:"true"`
CompileConfigs func(req domain.CompileConfigsRequest) domain.CompiledConfigResponse `method:"compile" group:"common_config" inner:"true"`
GetLinks func(req domain.ConfigIdRequest) domain.CommonConfigLinks `method:"get_links" group:"common_config" inner:"true"`
// ===== ROUTING =====
GetRoutes func() ([]structure.BackendDeclaration, error) `method:"get_routes" group:"routing" inner:"true"`
// ===== SCHEMA =====
GetSchemaByModuleId func(domain.GetByModuleIdRequest) (*entity.ConfigSchema, error) `method:"get_by_module_id" group:"schema" inner:"true"`
}
func GetHandlers() *Handlers {
return &Handlers{
DeleteModules: controller.Module.DeleteModules,
GetModulesInfo: controller.Module.GetModulesAggregatedInfo,
GetModuleByName: controller.Module.GetModuleByName,
GetActiveConfigByModuleName: controller.Config.GetActiveConfigByModuleName,
CreateUpdateConfig: controller.Config.CreateUpdateConfig,
MarkConfigAsActive: controller.Config.MarkConfigAsActive,
DeleteConfig: controller.Config.DeleteConfigs,
GetCommonConfigs: controller.CommonConfig.GetConfigs,
CreateUpdateCommonConfig: controller.CommonConfig.CreateUpdateConfig,
DeleteCommonConfig: controller.CommonConfig.DeleteConfigs,
CompileConfigs: controller.CommonConfig.CompileConfigs,
GetLinks: controller.CommonConfig.GetLinks,
GetRoutes: controller.Routes.GetRoutes,
GetSchemaByModuleId: controller.Schema.GetByModuleId,
}
}
+33
View File
@@ -0,0 +1,33 @@
package helpers
import (
"net"
"github.com/txix-open/etp/v4"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/log"
"isp-config-service/entity"
)
func ModuleName(conn *etp.Conn) string {
return conn.HttpRequest().Form.Get("module_name")
}
func SplitAddress(backend entity.Backend) (cluster.AddressConfiguration, error) {
host, port, err := net.SplitHostPort(backend.Address)
if err != nil {
return cluster.AddressConfiguration{}, errors.WithMessagef(err, "split backend %s address: %s", backend.ModuleId, backend.Address)
}
return cluster.AddressConfiguration{
IP: host,
Port: port,
}, nil
}
func LogFields(conn *etp.Conn) []log.Field {
return []log.Field{
log.String("moduleName", ModuleName(conn)),
log.String("connId", conn.Id()),
}
}
-14
View File
@@ -1,14 +0,0 @@
package holder
import (
"net/http"
etp "github.com/integration-system/isp-etp-go/v2"
"isp-config-service/cluster"
)
var (
ClusterClient *cluster.Client
EtpServer etp.Server
HTTPServer *http.Server
)
+30 -203
View File
@@ -1,228 +1,55 @@
package main
import (
"context"
"fmt"
"net"
"net/http"
"os"
"github.com/integration-system/isp-etp-go/v2"
"github.com/integration-system/isp-lib/v2/backend"
"github.com/integration-system/isp-lib/v2/bootstrap"
"github.com/integration-system/isp-lib/v2/config"
"github.com/integration-system/isp-lib/v2/structure"
"github.com/integration-system/isp-lib/v2/utils"
log "github.com/integration-system/isp-log"
mux "github.com/integration-system/net-mux"
"github.com/thecodeteam/goodbye"
"isp-config-service/cluster"
"isp-config-service/codes"
"isp-config-service/conf"
"isp-config-service/controller"
"isp-config-service/helper"
"isp-config-service/holder"
"isp-config-service/model"
"isp-config-service/raft"
"isp-config-service/service"
"isp-config-service/store"
"isp-config-service/store/state"
"isp-config-service/subs"
)
"isp-config-service/routes"
"isp-config-service/service/startup"
const (
moduleName = "config"
defaultWsConnectionReadLimit int64 = 4 << 20 // 4 MB
"github.com/txix-open/isp-kit/bootstrap"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/shutdown"
)
var (
version = "0.1.0"
shutdownChan = make(chan struct{})
muxer mux.Mux
version = "1.0.0"
)
func init() {
config.InitConfig(&conf.Configuration{})
if utils.LOG_LEVEL != "" {
_ = log.SetLevel(utils.LOG_LEVEL)
}
}
// @title ISP configuration service
// @version 2.0.0
// @description Сервис управления конфигурацией модулей ISP кластера
// @title isp-config-service
// @version 3.0.0
// @description Модуль управления конфигурациями
// @license.name GNU GPL v3.0
// @host localhost:9003
// @host localhost:9000
// @BasePath /api/config
//go:generate swag init --parseVendor
//go:generate rm -f docs/docs.go docs/swagger.json
//go:generate swag init --parseDependency
//go:generate rm -f docs/swagger.json docs/docs.go
func main() {
ctx := context.Background()
cfg := config.Get().(*conf.Configuration)
handlers := helper.GetHandlers()
endpoints := backend.GetEndpoints(cfg.ModuleName, handlers)
address := cfg.GrpcOuterAddress
if address.IP == "" {
ip, err := getOutboundIP()
if err != nil {
panic(err)
}
address.IP = ip
}
declaration := structure.BackendDeclaration{
ModuleName: cfg.ModuleName,
Version: version,
LibVersion: bootstrap.LibraryVersion,
Endpoints: endpoints,
Address: address,
}
boot := bootstrap.New(
version,
conf.Remote{},
cluster.Endpoints(routes.EndpointDescriptors()),
cluster.GrpcTransport,
)
app := boot.App
logger := app.Logger()
connectionReadLimit := defaultWsConnectionReadLimit
if cfg.WS.WsConnectionReadLimitKB > 0 {
//nolint gomnd
connectionReadLimit = cfg.WS.WsConnectionReadLimitKB << 10
}
cluster.WsConnectionReadLimit = connectionReadLimit
model.DbClient.ReceiveConfiguration(cfg.Database)
httpListener, raftListener, err := initMultiplexer(cfg.WS.Rest)
startup, err := startup.New(boot)
if err != nil {
log.Fatalf(codes.InitMuxError, "init mux: %v", err)
boot.Fatal(err)
}
app.AddRunners(startup)
app.AddClosers(startup.Closers()...)
_, raftStore := initRaft(raftListener, cfg.Cluster, declaration)
initWebsocket(ctx, connectionReadLimit, httpListener, raftStore)
initGrpc(cfg.WS.Grpc, raftStore)
defer goodbye.Exit(ctx, -1)
goodbye.Notify(ctx)
goodbye.Register(onShutdown)
<-shutdownChan
}
func initMultiplexer(addressConfiguration structure.AddressConfiguration) (net.Listener, net.Listener, error) {
outerAddr, err := net.ResolveTCPAddr("tcp4", addressConfiguration.GetAddress())
if err != nil {
return nil, nil, fmt.Errorf("resolve outer address: %v", err)
}
tcpListener, err := net.ListenTCP("tcp4", outerAddr)
if err != nil {
return nil, nil, fmt.Errorf("create tcp transport: %v", err)
}
muxer = mux.New(tcpListener)
httpListener := muxer.Match(mux.HTTP1())
raftListener := muxer.Match(mux.Any())
go func() {
if err := muxer.Serve(); err != nil {
log.Fatalf(codes.InitMuxError, "serve mux: %v", err)
}
}()
return httpListener, raftListener, nil
}
func initWebsocket(ctx context.Context, connectionReadLimit int64, listener net.Listener, raftStore *store.Store) {
etpConfig := etp.ServerConfig{
InsecureSkipVerify: true,
ConnectionReadLimit: connectionReadLimit,
}
etpServer := etp.NewServer(ctx, etpConfig)
subs.NewSocketEventHandler(etpServer, raftStore).SubscribeAll()
mux := http.NewServeMux()
mux.HandleFunc("/isp-etp/", etpServer.ServeHttp)
httpServer := &http.Server{Handler: mux}
go func() {
if err := httpServer.Serve(listener); err != nil && err != http.ErrServerClosed {
log.Fatalf(codes.StartHttpServerError, "http server closed: %v", err)
}
}()
holder.EtpServer = etpServer
holder.HTTPServer = httpServer
}
func initRaft(listener net.Listener, clusterCfg conf.ClusterConfiguration,
declaration structure.BackendDeclaration) (*cluster.Client, *store.Store) {
raftState, err := store.NewStateFromRepository()
if err != nil {
log.Fatal(codes.RestoreFromRepositoryError, err)
return nil, nil
}
raftStore := store.NewStateStore(raftState)
r, err := raft.NewRaft(listener, clusterCfg, raftStore)
if err != nil {
log.Fatalf(codes.InitRaftError, "unable to create raft server. %v", err)
return nil, nil
}
clusterClient := cluster.NewRaftClusterClient(r, declaration, func(address string) {
raftStore.VisitState(func(s state.WritableState) {
cfg := config.Get().(*conf.Configuration)
addr, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
panic(err) // must never occurred
}
port := cfg.GrpcOuterAddress.Port
addressConfiguration := structure.AddressConfiguration{Port: port, IP: addr.IP.String()}
back := structure.BackendDeclaration{ModuleName: cfg.ModuleName, Address: addressConfiguration}
log.WithMetadata(map[string]interface{}{"declaration": back}).
Infof(codes.LeaderManualDeleteLeader, "manually delete disconnected leader's declaration")
service.ClusterMeshService.HandleDeleteBackendDeclarationCommand(back, s)
})
shutdown.On(func() {
logger.Info(app.Context(), "starting shutdown")
app.Shutdown()
logger.Info(app.Context(), "shutdown completed")
})
holder.ClusterClient = clusterClient
if clusterCfg.BootstrapCluster {
err = r.BootstrapCluster() // err can be ignored
if err != nil {
log.Errorf(codes.BootstrapClusterError, "bootstrap cluster. %v", err)
}
}
return clusterClient, raftStore
}
func initGrpc(bindAddress structure.AddressConfiguration, raftStore *store.Store) {
controller.Routes = controller.NewRoutes(raftStore)
controller.Schema = controller.NewSchema(raftStore)
controller.Module = controller.NewModule(raftStore)
controller.Config = controller.NewConfig(raftStore)
controller.CommonConfig = controller.NewCommonConfig(raftStore)
defaultService := backend.GetDefaultService(moduleName, helper.GetHandlers())
backend.StartBackendGrpcServer(bindAddress, defaultService)
}
func onShutdown(ctx context.Context, _ os.Signal) {
defer close(shutdownChan)
backend.StopGrpcServer()
holder.EtpServer.Close()
if err := holder.HTTPServer.Shutdown(ctx); err != nil {
log.Warnf(codes.ShutdownHttpServerError, "http server shutdown err: %v", err)
} else {
log.Info(codes.ShutdownHttpServerInfo, "http server shutdown success")
}
if err := holder.ClusterClient.Shutdown(); err != nil {
log.Warnf(codes.RaftShutdownError, "raft shutdown err: %v", err)
} else {
log.Info(codes.RaftShutdownInfo, "raft shutdown success")
}
_ = muxer.Close()
}
func getOutboundIP() (string, error) {
conn, err := net.Dial("udp", "9.9.9.9:80")
err = app.Run()
if err != nil {
return "", err
boot.Fatal(err)
}
defer conn.Close()
return conn.LocalAddr().(*net.UDPAddr).IP.To4().String(), nil
}
+33
View File
@@ -0,0 +1,33 @@
package middlewares
import (
"context"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/txix-open/isp-kit/http/httpcli"
"github.com/txix-open/isp-kit/metrics"
"isp-config-service/middlewares/sql_metrics"
)
func SqlOperationMiddleware() httpcli.Middleware {
//nolint:promlinter
sqlQueryDuration := metrics.GetOrRegister(metrics.DefaultRegistry, prometheus.NewSummaryVec(prometheus.SummaryOpts{
Subsystem: "sql",
Name: "query_duration_ms",
Help: "The latencies of sql query",
Objectives: metrics.DefaultObjectives,
}, []string{"operation"}))
return func(next httpcli.RoundTripper) httpcli.RoundTripper {
return httpcli.RoundTripperFunc(func(ctx context.Context, request *httpcli.Request) (*httpcli.Response, error) {
label := sql_metrics.OperationLabelFromContext(ctx)
now := time.Now()
resp, err := next.RoundTrip(ctx, request)
if label != "" {
duration := time.Since(now)
sqlQueryDuration.WithLabelValues(label).Observe(metrics.Milliseconds(duration))
}
return resp, err //nolint:wrapcheck
})
}
}
+20
View File
@@ -0,0 +1,20 @@
package sql_metrics
import (
"context"
)
type tracerContextKey int
const (
labelContextKey = tracerContextKey(2)
)
func OperationLabelToContext(ctx context.Context, label string) context.Context {
return context.WithValue(ctx, labelContextKey, label)
}
func OperationLabelFromContext(ctx context.Context) string {
value, _ := ctx.Value(labelContextKey).(string)
return value
}
+35
View File
@@ -0,0 +1,35 @@
package middlewares
import (
"context"
"slices"
"github.com/txix-open/etp/v4"
"github.com/txix-open/etp/v4/msg"
"github.com/txix-open/isp-kit/log"
"isp-config-service/helpers"
)
type EtpMiddleware func(next etp.Handler) etp.Handler
func EtpLogger(logger log.Logger) EtpMiddleware {
return func(next etp.Handler) etp.Handler {
return etp.HandlerFunc(func(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
fields := append(
helpers.LogFields(conn),
log.String("event", event.Name),
)
logger.Debug(ctx, "event received", fields...)
return next.Handle(ctx, conn, event)
})
}
}
//nolint:ireturn
func EtpChain(root etp.Handler, middlewares ...EtpMiddleware) etp.Handler {
for i := range slices.Backward(middlewares) {
root = middlewares[i](root)
}
return root
}
@@ -1,5 +0,0 @@
-- +goose Up
CREATE schema if NOT EXISTS "config_service";
-- +goose Down
DROP schema if EXISTS config_service CASCADE;
@@ -1,47 +0,0 @@
-- +goose Up
CREATE TABLE instances (
id serial4 NOT NULL PRIMARY KEY,
uuid UUID NOT NULL,
"name" varchar(255) NOT NULL,
created_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL
);
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION update_created_modified_column_date()
RETURNS TRIGGER AS
$body$
BEGIN
IF TG_OP = 'UPDATE' THEN
NEW.created_at = OLD.created_at;
NEW.updated_at = (now() at time zone 'utc');
ELSIF TG_OP = 'INSERT' THEN
NEW.updated_at = (now() at time zone 'utc');
END IF;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql;
-- +goose StatementEnd
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION update_created_column_date()
RETURNS TRIGGER AS
$body$
BEGIN
IF TG_OP = 'UPDATE' THEN
NEW.created_at = OLD.created_at;
ELSIF TG_OP = 'INSERT' THEN
NEW.created_at = (now() at time zone 'utc');
END IF;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql;
-- +goose StatementEnd
CREATE TRIGGER update_customer_modtime BEFORE INSERT OR UPDATE ON instances
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
ALTER TABLE instances ADD CONSTRAINT "UQ_instances_uuid" UNIQUE ("uuid");
-- +goose Down
DROP TABLE instances;
@@ -1,24 +0,0 @@
-- +goose Up
CREATE TABLE modules (
id serial4 NOT NULL PRIMARY KEY,
instance_id int4 NOT NULL,
"name" varchar(255) NOT NULL,
"active" bool DEFAULT true,
created_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL,
last_connected_at timestamp,
last_disconnected_at timestamp
);
ALTER TABLE modules
ADD CONSTRAINT "FK_modules_instanceId_instances_id"
FOREIGN KEY ("instance_id") REFERENCES instances ("id")
ON DELETE CASCADE ON UPDATE CASCADE;
CREATE INDEX IX_modules_instanceId ON modules USING hash (instance_id);
CREATE TRIGGER update_customer_modtime BEFORE INSERT OR UPDATE ON modules
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
ALTER TABLE modules ADD CONSTRAINT "UQ_modules_instanceId_name" UNIQUE ("instance_id", "name");
-- +goose Down
DROP TABLE modules;
@@ -1,70 +0,0 @@
-- +goose Up
CREATE TABLE configs (
id serial8 NOT NULL PRIMARY KEY,
module_id int4 NOT NULL,
"version" int4 NOT NULL,
"active" bool DEFAULT false,
created_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL,
updated_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL,
"data" jsonb NOT NULL DEFAULT '{}'
);
ALTER TABLE configs
ADD CONSTRAINT "FK_configs_moduleId_modules_id"
FOREIGN KEY ("module_id") REFERENCES modules ("id")
ON DELETE CASCADE ON UPDATE CASCADE;
CREATE INDEX IX_configs_moduleId ON configs USING hash (module_id);
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION deactivate_config()
RETURNS TRIGGER AS
$body$
DECLARE
last_version integer;
BEGIN
NEW.updated_at = (now() at time zone 'utc');
IF TG_OP = 'INSERT'
THEN
EXECUTE format('
SELECT version
FROM %I.configs
WHERE module_id = ' || NEW.module_id || '
ORDER BY created_at DESC
LIMIT 1;
', TG_TABLE_SCHEMA) INTO last_version;
IF last_version IS NOT NULL
THEN
NEW.version = last_version + 1;
ELSE
NEW.version = 1;
END IF;
ELSE
NEW.version = OLD.version;
NEW.created_at = OLD.created_at;
END IF;
IF NEW.active = TRUE
THEN
EXECUTE format('
UPDATE %I.configs
SET active = FALSE,
updated_at = (now() at time zone ''utc'')
WHERE active = TRUE AND ' || NEW.id || ' != id AND module_id = ' || NEW.module_id || ';
', TG_TABLE_SCHEMA);
END IF;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql;
-- +goose StatementEnd
CREATE TRIGGER "deactivate_config"
BEFORE INSERT OR UPDATE ON configs
FOR EACH ROW EXECUTE PROCEDURE deactivate_config();
CREATE TRIGGER update_config_create_time BEFORE INSERT OR UPDATE ON configs
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
-- +goose Down
DROP TABLE configs;
DROP FUNCTION deactivate_config;
@@ -1,9 +0,0 @@
-- +goose Up
ALTER TABLE configs
ADD COLUMN name VARCHAR(255) NOT NULL DEFAULT 'unnamed',
ADD COLUMN description TEXT;
-- +goose Down
ALTER TABLE configs
DROP COLUMN name,
DROP COLUMN description;
@@ -1,23 +0,0 @@
-- +goose Up
CREATE TABLE config_schemas (
id SERIAL4 PRIMARY KEY,
module_id INTEGER NOT NULL,
version VARCHAR(255) NOT NULL,
schema JSONB NOT NULL DEFAULT '{}',
created_at TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
updated_at TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
CONSTRAINT FK_module_id__module_id FOREIGN KEY (module_id)
REFERENCES modules (id) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TRIGGER update_schema_create_time
BEFORE INSERT OR UPDATE
ON config_schemas
FOR EACH ROW EXECUTE PROCEDURE update_created_modified_column_date();
CREATE INDEX IX_schemes_moduleId
ON config_schemas
USING hash (module_id);
-- +goose Down
DROP TABLE config_schemas;
-46
View File
@@ -1,46 +0,0 @@
-- +goose Up
DROP TABLE instances CASCADE;
DROP TRIGGER update_config_create_time ON configs;
DROP TRIGGER deactivate_config on configs;
DROP TRIGGER update_schema_create_time ON config_schemas;
DROP TRIGGER update_customer_modtime ON modules;
ALTER TABLE configs
DROP CONSTRAINT "FK_configs_moduleId_modules_id";
ALTER TABLE config_schemas
DROP CONSTRAINT "fk_module_id__module_id";
ALTER TABLE configs
ALTER COLUMN id TYPE varchar(255),
ALTER COLUMN module_id TYPE varchar(255),
ADD COLUMN common_configs varchar(255)[] NOT NULL DEFAULT '{}';
ALTER TABLE config_schemas
ALTER COLUMN module_id TYPE varchar(255),
ALTER COLUMN id TYPE varchar(255);
ALTER TABLE modules
ALTER COLUMN id TYPE varchar(255),
DROP COLUMN active,
DROP COLUMN instance_id;
CREATE TABLE common_configs
(
id VARCHAR(255) NOT NULL PRIMARY KEY,
name VARCHAR(255) NOT NULL DEFAULT 'unnamed',
description TEXT,
created_at timestamp NOT NULL DEFAULT (now() at time zone 'utc'),
updated_at timestamp NOT NULL DEFAULT (now() at time zone 'utc'),
data jsonb NOT NULL DEFAULT '{}'
);
-- +goose Down
DROP TABLE common_configs;
+81
View File
@@ -0,0 +1,81 @@
-- +goose Up
-- +goose NO TRANSACTION
create table isp_config_service__module
(
id text not null primary key,
name text not null unique,
last_connected_at integer,
last_disconnected_at integer,
created_at integer not null default (unixepoch())
);
create table isp_config_service__config
(
id text not null primary key,
name text not null,
module_id text not null,
data blob not null,
version int not null default 1,
active int not null default 0,
admin_id int not null default 0,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch()),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create index IX_isp_config_service__config__module_id on isp_config_service__config (module_id);
create table isp_config_service__config_history
(
id text not null primary key,
config_id text not null,
data blob not null,
version int not null default 1,
admin_id int not null default 0,
created_at integer not null default (unixepoch()),
foreign key (config_id) references isp_config_service__config (id) on delete cascade on update cascade
);
create index IX_isp_config_service__config_history__config_id on isp_config_service__config_history (config_id);
create table isp_config_service__config_schema
(
id text not null primary key,
module_id text not null unique,
data blob not null,
module_version text not null default 1,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch()),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create table isp_config_service__backend
(
module_id text not null,
address text not null,
version text not null,
lib_version text not null,
module_name text not null,
endpoints blob not null,
required_modules blob not null,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch()),
primary key (module_id, address),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create table isp_config_service__event
(
id integer,
payload blob not null,
created_at integer not null default (unixepoch()),
primary key (id)
);
-- +goose Down
drop table isp_config_service__module;
drop table isp_config_service__config;
drop table isp_config_service__config_history;
drop table isp_config_service__config_schema;
drop table isp_config_service__backend;
drop table isp_config_service__event;
@@ -0,0 +1,17 @@
-- +goose Up
-- +goose NO TRANSACTION
CREATE TABLE isp_config_service__event_autoincrement (
id integer primary key autoincrement,
payload blob not null,
created_at integer not null default (unixepoch())
);
INSERT INTO
isp_config_service__event_autoincrement (id, payload, created_at)
SELECT id, payload, created_at
FROM isp_config_service__event;
DROP TABLE isp_config_service__event;
ALTER TABLE isp_config_service__event_autoincrement RENAME TO isp_config_service__event;
-- +goose Down
@@ -0,0 +1,24 @@
-- +goose Up
-- +goose NO TRANSACTION
drop table isp_config_service__backend;
create table isp_config_service__backend
(
ws_connection_id text not null,
module_id text not null,
address text not null,
version text not null,
lib_version text not null,
module_name text not null,
config_service_node_id text not null,
endpoints blob not null,
required_modules blob not null,
created_at integer not null default (unixepoch()),
primary key (ws_connection_id),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create index IX_isp_config_service__backend__module_id on isp_config_service__backend (module_id);
create index IX_isp_config_service__backend__node_id on isp_config_service__backend(config_service_node_id);
-- +goose Down
@@ -0,0 +1,26 @@
-- +goose Up
-- +goose NO TRANSACTION
create table isp_config_service__variable
(
name text primary key,
description text not null,
type text not null,
value text not null,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch())
);
create table isp_config_service__config_has_variable
(
config_id text not null,
variable_name text not null,
primary key (config_id, variable_name),
foreign key (config_id) references isp_config_service__config (id) on delete cascade on update cascade,
foreign key (variable_name) references isp_config_service__variable (name)
);
create index IX_isp_config_service__config_has_variable__variable_name on isp_config_service__config_has_variable (variable_name);
-- +goose Down
drop table isp_config_service__config_has_variable;
drop table isp_config_service__variable;
@@ -0,0 +1,6 @@
-- +goose Up
-- +goose NO TRANSACTION
alter table isp_config_service__backend add column metrics_autodiscovery blob;
-- +goose Down
alter table isp_config_service__backend drop column metrics_autodiscovery;
@@ -0,0 +1,6 @@
-- +goose Up
-- +goose NO TRANSACTION
alter table isp_config_service__backend add column transport text;
-- +goose Down
alter table isp_config_service__backend drop column transport;
@@ -0,0 +1,6 @@
-- +goose Up
-- +goose NO TRANSACTION
alter table isp_config_service__backend add column module_leader_mode text;
-- +goose Down
alter table isp_config_service__backend drop column module_leader_mode;
+10
View File
@@ -0,0 +1,10 @@
package migrations
import (
"embed"
)
var (
//go:embed *
Migrations embed.FS
)
-22
View File
@@ -1,22 +0,0 @@
package model
import (
"github.com/integration-system/isp-lib/v2/database"
log "github.com/integration-system/isp-log"
"github.com/integration-system/isp-log/stdcodes"
)
var (
DbClient = database.NewRxDbClient(
database.WithSchemaEnsuring(),
database.WithSchemaAutoInjecting(),
database.WithMigrationsEnsuring(),
database.WithInitializingErrorHandler(func(err *database.ErrorEvent) {
log.Fatal(stdcodes.InitializingDbError, err.Error())
}),
)
ConfigRep ConfigRepository = &configRepPg{rxClient: DbClient}
CommonConfigRep CommonConfigRepository = &commonConfigRepPg{rxClient: DbClient}
SchemaRep SchemaRepository = &schemaRepPg{rxClient: DbClient}
ModuleRep ModulesRepository = &modulesRepPg{rxClient: DbClient}
)
-55
View File
@@ -1,55 +0,0 @@
//nolint dupl
package model
import (
"github.com/go-pg/pg/v9"
"github.com/integration-system/isp-lib/v2/database"
"isp-config-service/entity"
)
type CommonConfigRepository interface {
Snapshot() ([]entity.CommonConfig, error)
Upsert(config entity.CommonConfig) (*entity.CommonConfig, error)
Delete(identities []string) (int, error)
}
type commonConfigRepPg struct {
rxClient *database.RxDbClient
}
func (r *commonConfigRepPg) Snapshot() ([]entity.CommonConfig, error) {
configs := make([]entity.CommonConfig, 0)
err := r.rxClient.Visit(func(db *pg.DB) error {
return db.Model(&configs).Select()
})
return configs, err
}
func (r *commonConfigRepPg) Upsert(config entity.CommonConfig) (*entity.CommonConfig, error) {
err := r.rxClient.Visit(func(db *pg.DB) error {
_, err := db.Model(&config).
OnConflict("(id) DO UPDATE").
Returning("*").
Insert()
return err
})
if err != nil {
return nil, err
}
return &config, err
}
func (r *commonConfigRepPg) Delete(identities []string) (int, error) {
var err error
var res pg.Result
err = r.rxClient.Visit(func(db *pg.DB) error {
res, err = db.Model(&entity.CommonConfig{}).
Where("id IN (?)", pg.In(identities)).
Delete()
return err
})
if err != nil {
return 0, err
}
return res.RowsAffected(), err
}
-55
View File
@@ -1,55 +0,0 @@
//nolint dupl
package model
import (
"github.com/go-pg/pg/v9"
"github.com/integration-system/isp-lib/v2/database"
"isp-config-service/entity"
)
type ConfigRepository interface {
Snapshot() ([]entity.Config, error)
Upsert(config entity.Config) (*entity.Config, error)
Delete(identities []string) (int, error)
}
type configRepPg struct {
rxClient *database.RxDbClient
}
func (r *configRepPg) Snapshot() ([]entity.Config, error) {
configs := make([]entity.Config, 0)
err := r.rxClient.Visit(func(db *pg.DB) error {
return db.Model(&configs).Select()
})
return configs, err
}
func (r *configRepPg) Upsert(config entity.Config) (*entity.Config, error) {
err := r.rxClient.Visit(func(db *pg.DB) error {
_, err := db.Model(&config).
OnConflict("(id) DO UPDATE").
Returning("*").
Insert()
return err
})
if err != nil {
return nil, err
}
return &config, err
}
func (r *configRepPg) Delete(identities []string) (int, error) {
var err error
var res pg.Result
err = r.rxClient.Visit(func(db *pg.DB) error {
res, err = db.Model(&entity.Config{}).
Where("id IN (?)", pg.In(identities)).
Delete()
return err
})
if err != nil {
return 0, err
}
return res.RowsAffected(), err
}
-54
View File
@@ -1,54 +0,0 @@
//nolint dupl
package model
import (
"github.com/go-pg/pg/v9"
"github.com/integration-system/isp-lib/v2/database"
"isp-config-service/entity"
)
type ModulesRepository interface {
Snapshot() ([]entity.Module, error)
Upsert(module entity.Module) (*entity.Module, error)
Delete(identities []string) (int, error)
}
type modulesRepPg struct {
rxClient *database.RxDbClient
}
func (r *modulesRepPg) Snapshot() ([]entity.Module, error) {
modules := make([]entity.Module, 0)
err := r.rxClient.Visit(func(db *pg.DB) error {
return db.Model(&modules).Select()
})
return modules, err
}
func (r *modulesRepPg) Upsert(module entity.Module) (*entity.Module, error) {
err := r.rxClient.Visit(func(db *pg.DB) error {
_, err := db.Model(&module).
OnConflict("(id) DO UPDATE").
Returning("*").
Insert()
return err
})
if err != nil {
return nil, err
}
return &module, err
}
func (r *modulesRepPg) Delete(identities []string) (int, error) {
var err error
var res pg.Result
err = r.rxClient.Visit(func(db *pg.DB) error {
res, err = db.Model(&entity.Module{}).
Where("id IN (?)", pg.In(identities)).Delete()
return err
})
if err != nil {
return 0, err
}
return res.RowsAffected(), err
}
-54
View File
@@ -1,54 +0,0 @@
//nolint dupl
package model
import (
"github.com/go-pg/pg/v9"
"github.com/integration-system/isp-lib/v2/database"
"isp-config-service/entity"
)
type SchemaRepository interface {
Snapshot() ([]entity.ConfigSchema, error)
Upsert(schema entity.ConfigSchema) (*entity.ConfigSchema, error)
Delete(identities []string) (int, error)
}
type schemaRepPg struct {
rxClient *database.RxDbClient
}
func (r *schemaRepPg) Snapshot() ([]entity.ConfigSchema, error) {
schemas := make([]entity.ConfigSchema, 0)
err := r.rxClient.Visit(func(db *pg.DB) error {
return db.Model(&schemas).Select()
})
return schemas, err
}
func (r *schemaRepPg) Upsert(schema entity.ConfigSchema) (*entity.ConfigSchema, error) {
err := r.rxClient.Visit(func(db *pg.DB) error {
_, err := db.Model(&schema).
OnConflict("(id) DO UPDATE").
Returning("*").
Insert()
return err
})
if err != nil {
return nil, err
}
return &schema, err
}
func (r *schemaRepPg) Delete(identities []string) (int, error) {
var err error
var res pg.Result
err = r.rxClient.Visit(func(db *pg.DB) error {
res, err = db.Model(&entity.ConfigSchema{}).
Where("id IN (?)", pg.In(identities)).Delete()
return err
})
if err != nil {
return 0, err
}
return res.RowsAffected(), err
}
-175
View File
@@ -1,175 +0,0 @@
package raft
import (
"net"
"os"
"path/filepath"
"time"
"github.com/hashicorp/raft"
raftboltdb "github.com/hashicorp/raft-boltdb"
"github.com/integration-system/isp-log/adapter"
"github.com/pkg/errors"
"isp-config-service/codes"
"isp-config-service/conf"
)
const (
defaultSyncTimeout = 3 * time.Second
leaderNotificationChBuffer = 10
dbFile = "raft_db"
)
type ChangeLeaderNotification struct {
CurrentLeaderAddress string
IsLeader bool
LeaderElected bool
}
type Raft struct {
r *raft.Raft
cfg conf.ClusterConfiguration
leaderObs *raft.Observer
leaderObsCh chan raft.Observation
changeLeaderCh chan ChangeLeaderNotification
closer chan struct{}
}
func (r *Raft) BootstrapCluster() error {
peers := makeConfiguration(r.cfg.Peers)
if f := r.r.BootstrapCluster(peers); f.Error() != nil {
return errors.WithMessage(f.Error(), "bootstrap cluster")
}
return nil
}
func (r *Raft) SyncApply(command []byte) (interface{}, error) {
f := r.r.Apply(command, defaultSyncTimeout)
if err := f.Error(); err != nil {
return nil, err
}
return f.Response(), nil
}
func (r *Raft) LeaderCh() <-chan ChangeLeaderNotification {
return r.changeLeaderCh
}
func (r *Raft) GracefulShutdown() error {
r.r.DeregisterObserver(r.leaderObs)
close(r.closer)
close(r.leaderObsCh)
return r.r.Shutdown().Error()
}
func (r *Raft) listenLeader() {
defer close(r.changeLeaderCh)
for {
select {
case _, ok := <-r.leaderObsCh:
if !ok {
return
}
currentLeader := r.r.Leader()
select {
case r.changeLeaderCh <- ChangeLeaderNotification{
IsLeader: r.r.State() == raft.Leader,
CurrentLeaderAddress: string(currentLeader),
LeaderElected: currentLeader != "",
}:
case <-r.closer:
return
default:
continue
}
case <-r.closer:
return
}
}
}
func NewRaft(tcpListener net.Listener, configuration conf.ClusterConfiguration, state raft.FSM) (*Raft, error) {
logStore, store, snapshotStore, err := makeStores(configuration)
if err != nil {
return nil, err
}
netLogger := adapter.NewHcLogger("RAFT-NET", codes.RaftLoggerCode)
streamLayer := &StreamLayer{Listener: tcpListener}
timeout := time.Duration(configuration.ConnectTimeoutSeconds) * time.Second
config := &raft.NetworkTransportConfig{
Stream: streamLayer,
MaxPool: len(configuration.Peers),
Timeout: timeout,
Logger: netLogger,
ServerAddressProvider: transparentAddressProvider{},
}
trans := raft.NewNetworkTransportWithConfig(config)
cfg := raft.DefaultConfig()
cfg.Logger = adapter.NewHcLogger("RAFT", codes.RaftLoggerCode)
cfg.NoSnapshotRestoreOnStart = true
cfg.LocalID = raft.ServerID(configuration.OuterAddress)
r, err := raft.NewRaft(cfg, state, logStore, store, snapshotStore, trans)
if err != nil {
return nil, errors.WithMessage(err, "create raft")
}
leaderObs, leaderObsCh := makeLeaderObserver()
r.RegisterObserver(leaderObs)
raft := &Raft{
r: r,
cfg: configuration,
leaderObs: leaderObs,
leaderObsCh: leaderObsCh,
changeLeaderCh: make(chan ChangeLeaderNotification, leaderNotificationChBuffer),
closer: make(chan struct{}),
}
go raft.listenLeader()
return raft, nil
}
func makeLeaderObserver() (*raft.Observer, chan raft.Observation) {
ch := make(chan raft.Observation)
obs := raft.NewObserver(ch, false, func(o *raft.Observation) bool {
_, ok := o.Data.(raft.LeaderObservation)
return ok
})
return obs, ch
}
func makeConfiguration(peers []string) raft.Configuration {
servers := make([]raft.Server, len(peers))
for i, peer := range peers {
servers[i] = raft.Server{
ID: raft.ServerID(peer),
Address: raft.ServerAddress(peer),
}
}
return raft.Configuration{
Servers: servers,
}
}
func makeStores(configuration conf.ClusterConfiguration) (raft.LogStore, raft.StableStore, raft.SnapshotStore, error) {
if configuration.InMemory {
dbStore := raft.NewInmemStore()
snapStore := raft.NewInmemSnapshotStore()
return dbStore, dbStore, snapStore, nil
} else {
dbStore, err := raftboltdb.NewBoltStore(filepath.Join(configuration.DataDir, dbFile))
if err != nil {
return nil, nil, nil, errors.WithMessage(err, "create db")
}
snapStore, err := raft.NewFileSnapshotStore(configuration.DataDir, 1, os.Stdout)
if err != nil {
return nil, nil, nil, errors.WithMessage(err, "create snapshot store")
}
return dbStore, dbStore, snapStore, nil
}
}
-22
View File
@@ -1,22 +0,0 @@
package raft
import (
"github.com/hashicorp/raft"
"net"
"time"
)
type StreamLayer struct {
net.Listener
}
func (r *StreamLayer) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error) {
return net.DialTimeout("tcp", string(address), timeout)
}
type transparentAddressProvider struct {
}
func (t transparentAddressProvider) ServerAddr(id raft.ServerID) (raft.ServerAddress, error) {
return raft.ServerAddress(id), nil
}
+208
View File
@@ -0,0 +1,208 @@
package repository
import (
"context"
"fmt"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
)
type Backend struct {
db db.DB
}
func NewBackend(db db.DB) Backend {
return Backend{
db: db,
}
}
func (r Backend) Upsert(ctx context.Context, backend entity.Backend) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.Upsert")
query, args, err := squirrel.Insert(Table("backend")).
Columns("ws_connection_id", "module_id", "address",
"version", "lib_version", "module_name", "transport",
"module_leader_mode", "config_service_node_id", "endpoints",
"required_modules", "metrics_autodiscovery").
Values(backend.WsConnectionId, backend.ModuleId, backend.Address,
backend.Version, backend.LibVersion, backend.ModuleName, backend.Transport,
backend.ModuleLeaderMode, backend.ConfigServiceNodeId, backend.Endpoints,
backend.RequiredModules, backend.MetricsAutodiscovery,
).
Suffix(`on conflict (ws_connection_id) do update
set module_id = excluded.module_id, address = excluded.address,
version = excluded.version, lib_version = excluded.lib_version,
module_name = excluded.module_name, transport = excluded.transport,
module_leader_mode = excluded.module_leader_mode,
config_service_node_id = excluded.config_service_node_id,
endpoints = excluded.endpoints, required_modules = excluded.required_modules,
metrics_autodiscovery = excluded.metrics_autodiscovery`).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Backend) DeleteByWsConnectionIds(ctx context.Context, wsConnectionIds []string) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.DeleteByWsConnectionIds")
query, args, err := squirrel.Delete(Table("backend")).
Where(squirrel.Eq{
"ws_connection_id": wsConnectionIds,
}).ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Backend) DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.DeleteByConfigServiceNodeId")
query, args, err := squirrel.Delete(Table("backend")).
Where(squirrel.Eq{
"config_service_node_id": configServiceNodeId,
}).ToSql()
if err != nil {
return 0, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return 0, errors.WithMessagef(err, "exec: %s", query)
}
deleted, err := result.RowsAffected()
if err != nil {
return 0, errors.WithMessage(err, "rows affected")
}
return int(deleted), nil
}
func (r Backend) GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByConfigServiceNodeId")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("backend")).
Where(squirrel.Eq{
"config_service_node_id": configServiceNodeId,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Backend, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Backend) All(ctx context.Context) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.All")
result := make([]entity.Backend, 0)
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("backend")).
OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Backend) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByModuleId")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("backend")).
Where(squirrel.Eq{
"module_id": moduleId,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Backend, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Backend) GetForLeaderElection(ctx context.Context, moduleId string) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetForLeaderElection")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("backend")).
Where(squirrel.Eq{
"module_id": moduleId,
}).OrderBy("created_at asc", "ws_connection_id asc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Backend, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Backend) AllMetricsAutodiscovery(ctx context.Context) ([]entity.MetricsAdWrapper, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.AllMetricsAutodiscovery")
result := make([]entity.MetricsAdWrapper, 0)
query := fmt.Sprintf(`
SELECT metrics_autodiscovery FROM %s
WHERE metrics_autodiscovery IS NOT NULL
ORDER BY module_name, created_at DESC`,
Table("backend"),
)
err := r.db.Select(ctx, &result, query)
if err != nil {
return nil, errors.WithMessagef(err, "select %s", query)
}
return result, nil
}
+230
View File
@@ -0,0 +1,230 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/entity/xtypes"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type Config struct {
db db.DB
}
func NewConfig(db db.DB) Config {
return Config{
db: db,
}
}
func (r Config) Insert(ctx context.Context, cfg entity.Config) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.Insert")
query, args, err := squirrel.Insert(Table("config")).
Columns("id", "name", "module_id", "data", "version", "active", "admin_id").
Values(cfg.Id, cfg.Name, cfg.ModuleId, cfg.Data, cfg.Version, cfg.Active, cfg.AdminId).
Suffix("on conflict (id) do nothing").
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Config) GetActive(ctx context.Context, moduleId string) (*entity.Config, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetActive")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("config")).
Where(squirrel.Eq{
"module_id": moduleId,
"active": xtypes.Bool(true),
}).OrderBy("version DESC").
Limit(1).
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
return selectRow[entity.Config](ctx, r.db, query, args...)
}
func (r Config) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetByModuleId")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("config")).
Where(squirrel.Eq{
"module_id": moduleId,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Config, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Config) GetById(ctx context.Context, id string) (*entity.Config, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetById")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("config")).
Where(squirrel.Eq{
"id": id,
}).ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
return selectRow[entity.Config](ctx, r.db, query, args...)
}
func (r Config) DeleteNonActiveById(ctx context.Context, id string) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.DeleteNonActiveById")
query, args, err := squirrel.Delete(Table("config")).
Where(squirrel.Eq{
"id": id,
"active": xtypes.Bool(false),
}).ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
func (r Config) UpdateByVersion(ctx context.Context, cfg entity.Config) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.UpdateByVersion")
query, args, err := squirrel.Update(Table("config")).
SetMap(map[string]any{
"name": cfg.Name,
"data": cfg.Data,
"version": squirrel.Expr("version + 1"),
"updated_at": squirrel.Expr("unixepoch()"),
"admin_id": cfg.AdminId,
}).Where(squirrel.Eq{
"id": cfg.Id,
"version": cfg.Version,
}).ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
func (r Config) SetActive(ctx context.Context, configId string, active xtypes.Bool) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.SetActive")
query, args, err := squirrel.Update(Table("config")).
Set("active", active).
Set("updated_at", squirrel.Expr("unixepoch()")).
Where(squirrel.Eq{
"id": configId,
}).ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Config) GetMetaByVariables(ctx context.Context, variables []string) (map[string][]entity.ConfigMetaWithVariable, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetMetaByVariables")
query, args, err := squirrel.Select("c.id", "c.name", "c.module_id", "c.active", "l.variable_name").
From(Table("config c")).
Join(fmt.Sprintf("%s l on c.id = l.config_id", Table("config_has_variable"))).
Where(squirrel.Eq{
"l.variable_name": variables,
}).ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
list := make([]entity.ConfigMetaWithVariable, 0)
err = r.db.Select(ctx, &list, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
result := make(map[string][]entity.ConfigMetaWithVariable)
for _, variable := range list {
result[variable.VariableName] = append(result[variable.VariableName], variable)
}
return result, nil
}
func (r Config) UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.UpdateConfigName")
query, args, err := squirrel.Update(Table("config")).
Set("name", req.NewConfigName).
Where(squirrel.Eq{
"id": req.Id,
}).
ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
+113
View File
@@ -0,0 +1,113 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type ConfigHistory struct {
db db.DB
}
func NewConfigHistory(db db.DB) ConfigHistory {
return ConfigHistory{
db: db,
}
}
func (r ConfigHistory) GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.GetByConfigId")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("config_history")).
Where(squirrel.Eq{
"config_id": configId,
}).OrderBy("version desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.ConfigHistory, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r ConfigHistory) Delete(ctx context.Context, id string) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Delete")
query := fmt.Sprintf(`delete from %s where id = ?`, Table("config_history"))
_, err := r.db.Exec(ctx, query, id)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r ConfigHistory) InsertV2(ctx context.Context, history entity.ConfigHistory) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.InsertV2")
query, args, err := squirrel.Insert(Table("config_history")).
Columns("id", "config_id", "data", "version", "admin_id").
Values(history.Id, history.ConfigId, history.Data, history.Version, history.AdminId).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r ConfigHistory) Insert(ctx context.Context, history entity.ConfigHistory) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Insert")
query, args, err := squirrel.Insert(Table("config_history")).
Columns("id", "config_id", "data", "version", "admin_id", "created_at").
Values(history.Id, history.ConfigId, history.Data, history.Version, history.AdminId, history.CreatedAt).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r ConfigHistory) DeleteOld(ctx context.Context, configId string, keepVersions int) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.DeleteOld")
query := fmt.Sprintf(`delete from %s where config_id = ? and id not in (
select id from %s where config_id = ? order by version desc limit ?
)`, Table("config_history"), Table("config_history"))
result, err := r.db.Exec(ctx, query, configId, configId, keepVersions)
if err != nil {
return 0, errors.WithMessagef(err, "exec: %s", query)
}
rowsAffected, err := result.RowsAffected()
if err != nil {
return 0, errors.WithMessage(err, "get rows affected")
}
return int(rowsAffected), nil
}
+110
View File
@@ -0,0 +1,110 @@
package repository
import (
"context"
"database/sql"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type ConfigSchema struct {
db db.DB
}
func NewConfigSchema(db db.DB) ConfigSchema {
return ConfigSchema{
db: db,
}
}
func (r ConfigSchema) Upsert(ctx context.Context, schema entity.ConfigSchema) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.Upsert")
query, args, err := squirrel.Insert(Table("config_schema")).
Columns("id", "module_id", "data", "module_version").
Values(schema.Id, schema.ModuleId, schema.Data, schema.ModuleVersion).
Suffix(`on conflict (module_id) do update
set data = excluded.data, module_version = excluded.module_version, updated_at = unixepoch()`).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r ConfigSchema) All(ctx context.Context) ([]entity.ConfigSchema, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.All")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("config_schema")).
OrderBy("created_at").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.ConfigSchema, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r ConfigSchema) GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.GetByModuleId")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("config_schema")).
Where(squirrel.Eq{"module_id": moduleId}).
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
return selectRow[entity.ConfigSchema](ctx, r.db, query, args...)
}
func (r ConfigSchema) UpdateByModuleId(ctx context.Context, moduleId string, data []byte) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.UpdateByModuleId")
query, args, err := squirrel.Update(Table("config_schema")).
Set("data", data).
Set("updated_at", squirrel.Expr("unixepoch()")).
Where(squirrel.Eq{"module_id": moduleId}).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
//nolint:nilnil
func selectRow[T any](ctx context.Context, db db.DB, query string, args ...any) (*T, error) {
var result T
err := db.SelectRow(ctx, &result, query, args...)
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, errors.WithMessagef(err, "select row: %s", query)
}
return &result, nil
}
+76
View File
@@ -0,0 +1,76 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/entity"
"isp-config-service/entity/xtypes"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type Event struct {
db db.DB
}
func NewEvent(db db.DB) Event {
return Event{
db: db,
}
}
func (r Event) Insert(ctx context.Context, event entity.Event) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Event.Insert")
query := fmt.Sprintf("insert into %s (payload) values (?)", Table("event"))
_, err := r.db.Exec(ctx, query, event.Payload)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Event) Get(ctx context.Context, lastEventId int, limit int) ([]entity.Event, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Event.Get")
// nolint:unqueryvet,gosec
query, args, err := squirrel.Select("*").
From(Table("event")).
Where(squirrel.Gt{
"id": lastEventId,
}).
OrderBy("id").
Limit(uint64(limit)).
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Event, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Event) DeleteByCreatedAt(ctx context.Context, before xtypes.Time) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Event.DeleteByCreatedAt")
query := fmt.Sprintf("delete from %s where created_at < ?", Table("event"))
result, err := r.db.Exec(ctx, query, before)
if err != nil {
return 0, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return 0, errors.WithMessage(err, "get affected rows")
}
return int(affected), nil
}
+146
View File
@@ -0,0 +1,146 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type Module struct {
db db.DB
}
func NewModule(db db.DB) Module {
return Module{
db: db,
}
}
func (r Module) Upsert(ctx context.Context, module entity.Module) (string, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.Upsert")
query, args, err := squirrel.Insert(Table("module")).
Columns("id", "name", "last_connected_at").
Values(module.Id, module.Name, squirrel.Expr("unixepoch()")).
Suffix(`on conflict (name) do update set last_connected_at = unixepoch() returning id`).
ToSql()
if err != nil {
return "", errors.WithMessage(err, "build query")
}
result := make(map[string]string)
err = r.db.SelectRow(ctx, &result, query, args...)
if err != nil {
return "", errors.WithMessagef(err, "select: %s", query)
}
return result["id"], nil
}
func (r Module) SetDisconnectedAtNow(
ctx context.Context,
moduleId string,
) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.SetDisconnectedAtNow")
query, args, err := squirrel.Update(Table("module")).
Set("last_disconnected_at", squirrel.Expr("unixepoch()")).
Where(squirrel.Eq{"id": moduleId}).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Module) GetByNames(ctx context.Context, names []string) ([]entity.Module, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.GetByNames")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("module")).
Where(squirrel.Eq{
"name": names,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Module, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Module) GetById(ctx context.Context, id string) (*entity.Module, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.GetById")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("module")).
Where(squirrel.Eq{
"id": id,
}).
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
return selectRow[entity.Module](ctx, r.db, query, args...)
}
func (r Module) All(ctx context.Context) ([]entity.Module, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.All")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("module")).
OrderBy("name").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Module, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Module) Delete(ctx context.Context, id string) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.Delete")
query, args, err := squirrel.Delete(Table("module")).
Where(squirrel.Eq{"id": id}).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func Table(table string) string {
return fmt.Sprintf("isp_config_service__%s", table)
}
+195
View File
@@ -0,0 +1,195 @@
package repository
import (
"context"
"database/sql"
"strings"
"github.com/Masterminds/squirrel"
"github.com/txix-open/isp-kit/errors"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type Variable struct {
db db.DB
}
func NewVariable(db db.DB) Variable {
return Variable{
db: db,
}
}
func (r Variable) All(ctx context.Context) ([]entity.Variable, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.All")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("variable")).
OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Variable, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Variable) GetByName(ctx context.Context, name string) (*entity.Variable, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.GetByName")
// nolint:unqueryvet
query, args, err := squirrel.Select("*").
From(Table("variable")).
Where(squirrel.Eq{"name": name}).
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := entity.Variable{}
err = r.db.SelectRow(ctx, &result, query, args...)
if errors.Is(err, sql.ErrNoRows) {
return nil, nil //nolint:nilnil
}
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return &result, nil
}
func (r Variable) Insert(ctx context.Context, variable entity.Variable) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.Insert")
query, args, err := squirrel.Insert(Table("variable")).
Columns("name", "description", "type", "value").
Values(variable.Name, variable.Description, variable.Type, variable.Value).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
if strings.Contains(err.Error(), "UNIQUE constraint failed") {
return entity.ErrVariableAlreadyExists
}
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Variable) Update(ctx context.Context, variable entity.Variable) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.Update")
query, args, err := squirrel.Update(Table("variable")).
SetMap(map[string]any{
"description": variable.Description,
"value": variable.Value,
"updated_at": squirrel.Expr("unixepoch()"),
}).Where(squirrel.Eq{
"name": variable.Name,
}).ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
func (r Variable) Upsert(ctx context.Context, variables []entity.Variable) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.Upsert")
requests := make([][]any, 0, len(variables))
for _, variable := range variables {
query, args, err := squirrel.Insert(Table("variable")).
Columns("name", "description", "type", "value").
Values(variable.Name, variable.Description, variable.Type, variable.Value).
Suffix(`on conflict (name) do update
set description = excluded.description,
type = excluded.type,
value = excluded.value,
updated_at = unixepoch()`,
).ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
requests = append(requests, db.Request(query, args...))
}
_, err := r.db.ExecTransaction(ctx, requests)
if err != nil {
return errors.WithMessagef(err, "exec transaction: %v", requests)
}
return nil
}
func (r Variable) UpsertLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.UpsertLinks")
deleteQuery, args, err := squirrel.Delete(Table("config_has_variable")).Where(squirrel.Eq{
"config_id": configId,
}).ToSql()
if err != nil {
return errors.WithMessage(err, "build delete query")
}
requests := [][]any{
db.Request(deleteQuery, args...),
}
for _, variable := range links {
requests = append(requests, db.Request(
`insert or ignore into `+Table("config_has_variable")+` (config_id, variable_name) values (?, ?)`,
variable.ConfigId, variable.VariableName,
))
}
_, err = r.db.ExecTransaction(ctx, requests)
if err != nil {
return errors.WithMessagef(err, "exec transaction: %v", requests)
}
return nil
}
func (r Variable) Delete(ctx context.Context, name string) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Variable.Delete")
query, args, err := squirrel.Delete(Table("variable")).
Where(squirrel.Eq{
"name": name,
}).ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
+220
View File
@@ -0,0 +1,220 @@
package routes
import (
"net/http"
"isp-config-service/conf"
"github.com/txix-open/etp/v4"
"isp-config-service/controller"
"isp-config-service/controller/api"
mws "isp-config-service/middlewares"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/endpoint"
"github.com/txix-open/isp-kit/log"
)
type Controllers struct {
Module controller.Module
ModuleApi api.Module
ConfigApi api.Config
ConfigHistoryApi api.ConfigHistory
ConfigSchemaApi api.ConfigSchema
VariableApi api.Variable
}
func EndpointDescriptors() []cluster.EndpointDescriptor {
c := Controllers{}
return concatEndpoints(
modulesDescriptors(c),
configsDescriptors(c),
variablesDescriptors(c),
)
}
func GrpcHandler(wrapper endpoint.Wrapper, c Controllers) *grpc.Mux {
muxer := grpc.NewMux()
for _, descriptor := range modulesDescriptors(c) {
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
}
for _, descriptor := range configsDescriptors(c) {
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
}
for _, descriptor := range variablesDescriptors(c) {
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
}
return muxer
}
func BindEtp(etpSrv *etp.Server, c Controllers, logger log.Logger) {
middlewares := []mws.EtpMiddleware{
mws.EtpLogger(logger),
}
etpSrv.OnConnect(c.Module.OnConnect)
etpSrv.OnDisconnect(c.Module.OnDisconnect)
etpSrv.OnError(c.Module.OnError)
onConfigSchema := mws.EtpChain(etp.HandlerFunc(c.Module.OnModuleConfigSchema), middlewares...)
etpSrv.On(cluster.ModuleSendConfigSchema, onConfigSchema)
onRequirements := mws.EtpChain(etp.HandlerFunc(c.Module.OnModuleRequirements), middlewares...)
etpSrv.On(cluster.ModuleSendRequirements, onRequirements)
onModuleReady := mws.EtpChain(etp.HandlerFunc(c.Module.OnModuleReady), middlewares...)
etpSrv.On(cluster.ModuleReady, onModuleReady)
}
func HttpHandler(etpSrv *etp.Server, conf conf.Local, rqliteProxy, rqliteBackupProxy http.Handler) http.Handler {
httpMux := http.NewServeMux()
if conf.MaintenanceMode {
httpMux.Handle("/", rqliteProxy)
} else {
httpMux.Handle("/isp-etp/", etpSrv)
httpMux.Handle("/backup", rqliteBackupProxy)
}
return httpMux
}
func modulesDescriptors(c Controllers) []cluster.EndpointDescriptor {
return []cluster.EndpointDescriptor{
{
Path: "config/module/get_modules_info",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ModuleApi.Status,
}, {
Path: "config/module/delete_module",
Inner: true,
Extra: cluster.RequireAdminPermission("module_delete"),
Handler: c.ModuleApi.DeleteModule,
}, {
Path: "config/routing/get_routes",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ModuleApi.Connections,
}, {
Path: "config/module/get_required_modules",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ModuleApi.RequiredModules,
},
}
}
func configsDescriptors(c Controllers) []cluster.EndpointDescriptor {
return []cluster.EndpointDescriptor{
{
Path: "config/config/get_active_config_by_module_name",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ConfigApi.GetActiveConfigByModuleName,
}, {
Path: "config/config/get_configs_by_module_id",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ConfigApi.GetConfigsByModuleId,
}, {
Path: "config/config/create_update_config",
Inner: true,
Extra: cluster.RequireAdminPermission("module_configuration_edit"),
Handler: c.ConfigApi.CreateUpdateConfig,
}, {
Path: "config/config/get_config_by_id",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ConfigApi.GetConfigById,
}, {
Path: "config/config/mark_config_as_active",
Inner: true,
Extra: cluster.RequireAdminPermission("module_configuration_set_active"),
Handler: c.ConfigApi.MarkConfigAsActive,
}, {
Path: "config/config/update_config_name",
Inner: true,
Extra: cluster.RequireAdminPermission("module_configuration_edit"),
Handler: c.ConfigApi.UpdateConfigName,
}, {
Path: "config/config/delete_config",
Inner: true,
Extra: cluster.RequireAdminPermission("module_configuration_edit"),
Handler: c.ConfigApi.DeleteConfigs,
}, {
Path: "config/config/sync",
Inner: true,
Extra: cluster.RequireAdminPermission("module_configuration_edit"),
Handler: c.ConfigApi.SyncConfig,
}, {
Path: "config/config/get_all_version",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ConfigHistoryApi.GetAllVersion,
}, {
Path: "config/config/delete_version",
Inner: true,
Extra: cluster.RequireAdminPermission("module_history_delete_version"),
Handler: c.ConfigHistoryApi.DeleteConfigVersion,
}, {
Path: "config/config/purge_versions",
Inner: true,
Extra: cluster.RequireAdminPermission("module_history_delete_version"),
Handler: c.ConfigHistoryApi.PurgeConfigVersions,
}, {
Path: "config/schema/get_by_module_id",
Inner: true,
Extra: cluster.RequireAdminPermission("module_view"),
Handler: c.ConfigSchemaApi.SchemaByModuleId,
}, {
Path: "config/schema/update_by_module_name",
Inner: true,
Extra: cluster.RequireAdminPermission("module_configuration_edit"),
Handler: c.ConfigSchemaApi.UpdateSchemaByModuleName,
},
}
}
func variablesDescriptors(c Controllers) []cluster.EndpointDescriptor {
return []cluster.EndpointDescriptor{
{
Path: "config/variable/all",
Inner: true,
Extra: cluster.RequireAdminPermission("variable_view"),
Handler: c.VariableApi.All,
}, {
Path: "config/variable/get_by_name",
Inner: true,
Extra: cluster.RequireAdminPermission("variable_view"),
Handler: c.VariableApi.GetByName,
}, {
Path: "config/variable/create",
Inner: true,
Extra: cluster.RequireAdminPermission("variable_add"),
Handler: c.VariableApi.Create,
}, {
Path: "config/variable/update",
Inner: true,
Extra: cluster.RequireAdminPermission("variable_edit"),
Handler: c.VariableApi.Update,
}, {
Path: "config/variable/upsert",
Inner: true,
Extra: cluster.RequireAdminPermission("variable_edit"),
Handler: c.VariableApi.Upsert,
}, {
Path: "config/variable/delete",
Inner: true,
Extra: cluster.RequireAdminPermission("variable_delete"),
Handler: c.VariableApi.Delete,
},
}
}
func concatEndpoints(endpoints ...[]cluster.EndpointDescriptor) []cluster.EndpointDescriptor {
var result []cluster.EndpointDescriptor
for _, c := range endpoints {
result = append(result, c...)
}
return result
}
+416
View File
@@ -0,0 +1,416 @@
package api
import (
"context"
"time"
"github.com/google/uuid"
"github.com/txix-open/go-cmp/cmp"
"github.com/txix-open/isp-kit/errors"
"github.com/txix-open/isp-kit/json"
"github.com/txix-open/isp-kit/log"
"github.com/xeipuuv/gojsonschema"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/entity/xtypes"
)
type ConfigRepo interface {
GetActive(ctx context.Context, moduleId string) (*entity.Config, error)
GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error)
GetById(ctx context.Context, id string) (*entity.Config, error)
DeleteNonActiveById(ctx context.Context, id string) (bool, error)
Insert(ctx context.Context, cfg entity.Config) error
UpdateByVersion(ctx context.Context, cfg entity.Config) (bool, error)
SetActive(ctx context.Context, configId string, active xtypes.Bool) error
UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) (bool, error)
}
type EventRepo interface {
Insert(ctx context.Context, event entity.Event) error
}
type ConfigHistoryService interface {
OnUpdateConfig(ctx context.Context, oldConfig entity.Config) error
}
type VariableService interface {
ExtractVariables(ctx context.Context, configId string, input []byte) (*domain.VariableExtractionResult, error)
SaveVariableLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error
}
type Config struct {
configRepo ConfigRepo
moduleRepo ModuleRepo
schemaRepo SchemaRepo
eventRepo EventRepo
configHistoryService ConfigHistoryService
variableService VariableService
logger log.Logger
}
func NewConfig(
configRepo ConfigRepo,
moduleRepo ModuleRepo,
schemaRepo SchemaRepo,
eventRepo EventRepo,
configHistoryService ConfigHistoryService,
variableService VariableService,
logger log.Logger,
) Config {
return Config{
configRepo: configRepo,
moduleRepo: moduleRepo,
schemaRepo: schemaRepo,
eventRepo: eventRepo,
configHistoryService: configHistoryService,
variableService: variableService,
logger: logger,
}
}
func (c Config) GetActiveConfigByModuleName(ctx context.Context, moduleName string) (*domain.Config, error) {
modules, err := c.moduleRepo.GetByNames(ctx, []string{moduleName})
if err != nil {
return nil, errors.WithMessage(err, "get config by module name")
}
if len(modules) == 0 {
return nil, entity.ErrModuleNotFound
}
moduleId := modules[0].Id
config, err := c.configRepo.GetActive(ctx, moduleId)
if err != nil {
return nil, errors.WithMessage(err, "get active config")
}
if config == nil {
return nil, entity.ErrConfigNotFound
}
return new(configToDto(*config, nil)), nil
}
func (c Config) GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error) {
configs, err := c.configRepo.GetByModuleId(ctx, moduleId)
if err != nil {
return nil, errors.WithMessage(err, "get configs by module id")
}
if len(configs) == 0 {
return make([]domain.Config, 0), nil
}
schema, err := c.schemaRepo.GetByModuleId(ctx, moduleId)
if err != nil {
return nil, errors.WithMessage(err, "get config schema by module id")
}
var jsonSchema []byte
if schema != nil {
jsonSchema = schema.Data
}
result := make([]domain.Config, 0)
for _, config := range configs {
result = append(result, configToDto(config, jsonSchema))
}
return result, nil
}
func (c Config) CreateUpdateConfig(
ctx context.Context,
adminId int,
req domain.CreateUpdateConfigRequest,
) (*domain.CreateUpdateConfigResponse, error) {
if !req.Unsafe {
err := c.validateConfigUpdate(ctx, req.ModuleId, req.Data)
if err != nil {
return nil, errors.WithMessage(err, "validate config")
}
}
if req.Id == "" {
newConfig, err := c.insertNewConfig(ctx, adminId, req)
return &domain.CreateUpdateConfigResponse{
Config: newConfig, IsChanged: true}, err
}
variableExtractionResult, err := c.extractAndCheckVariables(ctx, req.Id, req.Data)
if err != nil {
return nil, errors.WithMessage(err, "extract variables")
}
oldConfig, err := c.configRepo.GetById(ctx, req.Id)
if err != nil {
return nil, errors.WithMessage(err, "get old config")
}
if oldConfig == nil {
return nil, entity.ErrConfigNotFound
}
isMatch, err := isEqualConfigs(oldConfig, req)
if err != nil {
return nil, errors.WithMessage(err, "compare data configs")
}
if isMatch {
c.logger.Info(ctx, "no changes in config; skip update")
return &domain.CreateUpdateConfigResponse{Config: configToDto(*oldConfig, nil), IsChanged: false}, nil
}
config := entity.Config{
Id: req.Id,
Name: req.Name,
Data: req.Data,
Version: req.Version,
AdminId: adminId,
}
updated, err := c.configRepo.UpdateByVersion(ctx, config)
if err != nil {
return nil, errors.WithMessage(err, "update config")
}
if !updated {
return nil, entity.ErrConfigConflictUpdate
}
err = c.configHistoryService.OnUpdateConfig(ctx, *oldConfig)
if err != nil {
return nil, errors.WithMessage(err, "change config history")
}
err = c.variableService.SaveVariableLinks(ctx, config.Id, variableExtractionResult.VariableLinks)
if err != nil {
return nil, errors.WithMessage(err, "save variable links")
}
if oldConfig.Active {
err = c.emitChangeActiveConfigEvent(ctx, oldConfig.ModuleId)
if err != nil {
return nil, errors.WithMessage(err, "emit change active config event")
}
}
newConfig := entity.Config{
Id: req.Id,
Name: req.Name,
ModuleId: req.ModuleId,
Data: req.Data,
Version: req.Version + 1,
Active: oldConfig.Active,
}
return &domain.CreateUpdateConfigResponse{
Config: configToDto(newConfig, nil), IsChanged: true}, nil
}
func (c Config) GetConfigById(ctx context.Context, configId string) (*domain.Config, error) {
config, err := c.configRepo.GetById(ctx, configId)
if err != nil {
return nil, errors.WithMessage(err, "get config by id")
}
if config == nil {
return nil, entity.ErrConfigNotFound
}
return new(configToDto(*config, nil)), nil
}
func (c Config) MarkConfigAsActive(ctx context.Context, configId string) error {
cfg, err := c.configRepo.GetById(ctx, configId)
if err != nil {
return errors.WithMessage(err, "get config by id")
}
if cfg == nil {
return entity.ErrConfigNotFound
}
currentActiveConfig, err := c.configRepo.GetActive(ctx, cfg.ModuleId)
if err != nil {
return errors.WithMessage(err, "get active config")
}
if currentActiveConfig != nil {
err := c.configRepo.SetActive(ctx, currentActiveConfig.Id, false)
if err != nil {
return errors.WithMessage(err, "deactivate config")
}
}
err = c.configRepo.SetActive(ctx, configId, true)
if err != nil {
return errors.WithMessage(err, "set active config")
}
err = c.emitChangeActiveConfigEvent(ctx, cfg.ModuleId)
if err != nil {
return errors.WithMessage(err, "emit change active config event")
}
return nil
}
func (c Config) DeleteConfig(ctx context.Context, configId string) error {
deleted, err := c.configRepo.DeleteNonActiveById(ctx, configId)
if err != nil {
return errors.WithMessage(err, "delete config")
}
if !deleted {
return entity.ErrConfigNotFoundOrActive
}
return nil
}
func (c Config) UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) error {
exist, err := c.configRepo.UpdateConfigName(ctx, req)
if err != nil {
return errors.WithMessage(err, "update config name")
}
if !exist {
return entity.ErrConfigNotFound
}
return nil
}
func (c Config) SyncConfig(ctx context.Context, moduleName string) error {
modules, err := c.moduleRepo.GetByNames(ctx, []string{moduleName})
if err != nil {
return errors.WithMessage(err, "get config by module name")
}
if len(modules) == 0 {
return entity.ErrModuleNotFound
}
moduleId := modules[0].Id
err = c.emitChangeActiveConfigEvent(ctx, moduleId)
if err != nil {
return errors.WithMessage(err, "emit change active config event")
}
return nil
}
func (c Config) insertNewConfig(ctx context.Context, adminId int, req domain.CreateUpdateConfigRequest) (domain.Config, error) {
config := entity.Config{
Id: uuid.NewString(),
Name: req.Name,
ModuleId: req.ModuleId,
Data: req.Data,
Version: 1,
Active: false,
AdminId: adminId,
}
// Check variables before insert so a config with missing variables is never persisted without links.
extractResult, err := c.extractAndCheckVariables(ctx, config.Id, config.Data)
if err != nil {
return domain.Config{}, err
}
err = c.configRepo.Insert(ctx, config)
if err != nil {
return domain.Config{}, errors.WithMessage(err, "insert new config")
}
err = c.variableService.SaveVariableLinks(ctx, config.Id, extractResult.VariableLinks)
if err != nil {
return domain.Config{}, errors.WithMessage(err, "save variable links")
}
result := configToDto(config, nil)
return result, nil
}
func (c Config) extractAndCheckVariables(ctx context.Context, configId string, input []byte) (*domain.VariableExtractionResult, error) {
variableExtractionResult, err := c.variableService.ExtractVariables(ctx, configId, input)
if err != nil {
return nil, errors.WithMessage(err, "extract variables")
}
if len(variableExtractionResult.AbsentVariables) > 0 {
details := make(map[string]string)
for _, variable := range variableExtractionResult.AbsentVariables {
details[variable] = "variable is not defined"
}
return nil, errors.WithMessage(domain.NewConfigValidationError(details), "config validation")
}
return variableExtractionResult, nil
}
func (c Config) validateConfigUpdate(ctx context.Context, moduleId string, configData []byte) error {
schema, err := c.schemaRepo.GetByModuleId(ctx, moduleId)
if err != nil {
return errors.WithMessage(err, "get schema by module id")
}
if schema == nil {
return entity.ErrSchemaNotFound
}
details, err := validateConfig(configData, schema.Data)
if err != nil {
return errors.WithMessage(err, "validate config")
}
if len(details) == 0 {
return nil
}
return errors.WithMessage(domain.NewConfigValidationError(details), "config validation")
}
func (c Config) emitChangeActiveConfigEvent(ctx context.Context, moduleId string) error {
eventPayload := entity.EventPayload{
ConfigUpdated: &entity.PayloadConfigUpdated{
ModuleId: moduleId,
},
}
err := c.eventRepo.Insert(ctx, entity.NewEvent(eventPayload))
if err != nil {
return errors.WithMessage(err, "insert new event")
}
return nil
}
func configToDto(config entity.Config, schema []byte) domain.Config {
valid := true
if schema != nil {
errors, _ := validateConfig(config.Data, schema)
valid = len(errors) == 0
}
return domain.Config{
Id: config.Id,
Name: config.Name,
ModuleId: config.ModuleId,
Valid: valid,
Data: config.Data,
Version: config.Version,
Active: bool(config.Active),
CreatedAt: time.Time(config.CreatedAt),
UpdatedAt: time.Time(config.UpdatedAt),
}
}
func validateConfig(config []byte, schema []byte) (map[string]string, error) {
schemaLoader := gojsonschema.NewBytesLoader(schema)
configLoader := gojsonschema.NewBytesLoader(config)
result, err := gojsonschema.Validate(schemaLoader, configLoader)
if err != nil {
return nil, errors.WithMessage(err, "validate config")
}
details := map[string]string{}
for _, resultError := range result.Errors() {
details[resultError.Field()] = resultError.Description()
}
return details, nil
}
func isEqualConfigs(oldConfig *entity.Config, reqConfig domain.CreateUpdateConfigRequest) (bool, error) {
if oldConfig.Name != reqConfig.Name {
return false, nil
}
oldDataMap := make(map[string]any)
err := json.Unmarshal(oldConfig.Data, &oldDataMap)
if err != nil {
return false, errors.WithMessage(err, "unmarshal actual config data")
}
reqDataMap := make(map[string]any)
err = json.Unmarshal(reqConfig.Data, &reqDataMap)
if err != nil {
return false, errors.WithMessage(err, "unmarshal request config data")
}
return cmp.Equal(oldDataMap, reqDataMap), nil
}
+148
View File
@@ -0,0 +1,148 @@
package api
import (
"context"
"fmt"
"time"
"github.com/google/uuid"
"github.com/txix-open/isp-kit/log"
"isp-config-service/domain"
"isp-config-service/entity"
"github.com/txix-open/isp-kit/errors"
)
type ConfigHistoryRepo interface {
Delete(ctx context.Context, id string) error
GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error)
Insert(ctx context.Context, history entity.ConfigHistory) error
DeleteOld(ctx context.Context, configId string, keepVersions int) (int, error)
}
type ConfigHistory struct {
configRepo ConfigRepo
moduleRepo ModuleRepo
repo ConfigHistoryRepo
keepVersions int
logger log.Logger
}
func NewConfigHistory(
configRepo ConfigRepo,
moduleRepo ModuleRepo,
repo ConfigHistoryRepo,
keepVersions int,
logger log.Logger,
) ConfigHistory {
return ConfigHistory{
repo: repo,
moduleRepo: moduleRepo,
configRepo: configRepo,
keepVersions: keepVersions,
logger: logger,
}
}
func (s ConfigHistory) GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error) {
versions, err := s.repo.GetByConfigId(ctx, configId)
if err != nil {
return nil, errors.WithMessage(err, "get config versions")
}
actualCfg, err := s.configRepo.GetById(ctx, configId)
if err != nil {
return nil, errors.WithMessage(err, "get actual config by id")
}
if actualCfg == nil {
return nil, entity.ErrConfigNotFound
}
result := make([]domain.ConfigVersion, 0, len(versions)+1)
result = append(result, domain.ConfigVersion{
Id: uuid.NewString(),
ConfigId: actualCfg.Id,
ConfigVersion: actualCfg.Version,
Data: actualCfg.Data,
CreatedAt: time.Time(actualCfg.UpdatedAt),
})
for _, version := range versions {
result = append(result, domain.ConfigVersion{
Id: version.Id,
ConfigId: version.ConfigId,
ConfigVersion: version.Version,
Data: version.Data,
CreatedAt: time.Time(version.CreatedAt),
})
}
return result, nil
}
func (s ConfigHistory) Delete(ctx context.Context, id string) error {
err := s.repo.Delete(ctx, id)
if err != nil {
return errors.WithMessage(err, "delete config version")
}
return nil
}
func (s ConfigHistory) Purge(ctx context.Context, moduleName string, keepVersions int) (map[string]int, error) {
modules, err := s.moduleRepo.GetByNames(ctx, []string{moduleName})
if err != nil {
return nil, errors.WithMessage(err, "get config by module name")
}
if len(modules) == 0 {
return nil, entity.ErrModuleNotFound
}
configs, err := s.configRepo.GetByModuleId(ctx, modules[0].Id)
if err != nil {
return nil, errors.WithMessage(err, "get configs by module id")
}
result := make(map[string]int)
for _, config := range configs {
deletedCount, err := s.repo.DeleteOld(ctx, config.Id, keepVersions)
if err != nil {
return nil, errors.WithMessage(err, "delete old config")
}
s.logger.Debug(ctx, fmt.Sprintf("delete '%d' old version of config '%s'", deletedCount, config.Id))
result[config.Id] = deletedCount
}
return result, nil
}
func (s ConfigHistory) OnUpdateConfig(ctx context.Context, oldConfig entity.Config) error {
history := entity.ConfigHistory{
Id: uuid.NewString(),
ConfigId: oldConfig.Id,
Data: oldConfig.Data,
Version: oldConfig.Version,
AdminId: oldConfig.AdminId,
CreatedAt: oldConfig.UpdatedAt,
}
err := s.repo.Insert(ctx, history)
if err != nil {
return errors.WithMessage(err, "save config history")
}
if s.keepVersions < 0 {
return nil
}
// nolint:gosec
go func() {
deletedCount, err := s.repo.DeleteOld(context.Background(), oldConfig.Id, s.keepVersions)
if err != nil {
s.logger.Error(ctx, errors.WithMessage(err, "delete old config versions"))
} else {
s.logger.Debug(ctx, fmt.Sprintf("delete '%d' old config versions", deletedCount))
}
}()
return nil
}
Loaded 100 of 169 files, more files were not shown because too many files have changed in this diff. Show more