Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7a141d25e | ||
|
|
6731fc6b93 | ||
|
|
d45f814d6a | ||
|
|
1ff499ace3 | ||
|
|
b481c2a45e | ||
|
|
dde6c49b92 | ||
|
|
9a66bd060a | ||
|
|
d669c65038 | ||
|
|
c9ee296835 | ||
|
|
53dff62759 | ||
|
|
439e6f5ebf | ||
|
|
a8a475435c | ||
|
|
b36cb1cd0e | ||
|
|
06ec2c6a87 | ||
|
|
45d7ea443f | ||
|
|
2bb06ffb8e | ||
|
|
45de1d1b12 | ||
|
|
6cd0b2c712 | ||
|
|
3d04dd2df7 | ||
|
|
6cfa1955ea | ||
|
|
9e24122e75 | ||
|
|
71997dc438 | ||
|
|
bd8a1b2de4 | ||
|
|
7b0108a358 | ||
|
|
a195c76799 | ||
|
|
780c2232fb | ||
|
|
ef0978e064 | ||
|
|
c464393e93 | ||
|
|
7f4e3ef028 | ||
|
|
5c8a554d4f | ||
|
|
5bdb4813b5 | ||
|
|
17ec4bdce9 | ||
|
|
428de36857 | ||
|
|
fc9c4f956f | ||
|
|
44961d8416 | ||
|
|
2a846c67e4 | ||
|
|
481f06bfec | ||
|
|
3b99380a62 | ||
|
|
ffa09db7b2 | ||
|
|
94af308030 | ||
|
|
36e320af28 | ||
|
|
c2d7aea679 | ||
|
|
aebd33e5cb | ||
|
|
45b28e46e6 | ||
|
|
48ccd130b2 | ||
|
|
7eb341856d | ||
|
|
38fe10f3a1 | ||
|
|
fa327ecf5c | ||
|
|
6c3e8a632e | ||
|
|
03fcb26473 | ||
|
|
7f4a1c8131 | ||
|
|
416f9307c3 | ||
|
|
1273869b07 | ||
|
|
1839a18bb4 | ||
|
|
34d7fabf61 | ||
|
|
c295bda53b | ||
|
|
f97795bd90 | ||
|
|
f7931b1d83 | ||
|
|
245cf8852d | ||
|
|
7b09eb3a07 | ||
|
|
e45900fbaa | ||
|
|
b0330e80f3 | ||
|
|
9a2cdd0662 | ||
|
|
9b577e96b1 | ||
|
|
7873c57c8e | ||
|
|
38fdb65ec2 | ||
|
|
9ebf03a15a | ||
|
|
8101f9a8c8 | ||
|
|
924d1cf6fe | ||
|
|
de3e456617 | ||
|
|
fc5a21d6bb | ||
|
|
4763d88628 | ||
|
|
a6d72ec1a4 | ||
|
|
99d4aaca45 | ||
|
|
2f614a5c75 | ||
|
|
960b87d86d | ||
|
|
35e15b7ae1 | ||
|
|
392e5f5cff | ||
|
|
451d277644 | ||
|
|
2caed6b3f0 | ||
|
|
a349df7b05 | ||
|
|
efed09bb92 | ||
|
|
a2c222dfd9 | ||
|
|
129ce7c2c6 | ||
|
|
cde261cf5d | ||
|
|
8ef12f8b11 | ||
|
|
99782ef3bb | ||
|
|
6a36603b5d | ||
|
|
5a3d4fffea | ||
|
|
7a585711f6 | ||
|
|
d024e038c2 | ||
|
|
7b329a8c73 | ||
|
|
e62089f019 | ||
|
|
c3ed4a0e27 | ||
|
|
846129b1af | ||
|
|
66edb03aa4 | ||
|
|
d56d6613bb | ||
|
|
5a67d0cc4f | ||
|
|
803b067278 | ||
|
|
78eeee0bc6 | ||
|
|
c6f2c3a813 | ||
|
|
441702a180 | ||
|
|
de85ffa726 | ||
|
|
1482636ad8 | ||
|
|
b62b0eef8b | ||
|
|
37f85f56fa | ||
|
|
4c131093b1 | ||
|
|
22bfe6f2a1 | ||
|
|
fd5ce55c4c | ||
|
|
e5494e2849 | ||
|
|
eb79974760 | ||
|
|
350d22ae75 | ||
|
|
3e7f235876 | ||
|
|
778e194d1d | ||
|
|
bfe9764707 | ||
|
|
5877176645 | ||
|
|
10e74db016 | ||
|
|
82f6d624ba | ||
|
|
22e76538c4 | ||
|
|
11a5477bcb | ||
|
|
aefc14ece9 | ||
|
|
0e6b5dec52 | ||
|
|
2a424699d7 | ||
|
|
3c19a8d532 | ||
|
|
28be68322c | ||
|
|
867fd98bce | ||
|
|
1d3bacd22c | ||
|
|
a483722e1d | ||
|
|
6ab012444f | ||
|
|
57f58e7fb7 | ||
|
|
a51aae9b69 | ||
|
|
4214bd3f20 | ||
|
|
a0b2a75c9d | ||
|
|
159db8114e | ||
|
|
a7b203bcd0 | ||
|
|
d0b55947c5 | ||
|
|
a3c65a1434 | ||
|
|
29c1a4deeb | ||
|
|
ee44e68af9 | ||
|
|
7a426b647b | ||
|
|
9d299beaf6 | ||
|
|
7a1d882248 | ||
|
|
ab95da7242 | ||
|
|
f63bf4a9f1 | ||
|
|
a9d4b96305 | ||
|
|
cedb376a91 | ||
|
|
93d09a779d | ||
|
|
41fa496052 | ||
|
|
398d537d8a | ||
|
|
c501354be1 | ||
|
|
7852772e9d | ||
|
|
efc4a4ee38 | ||
|
|
25c07ef016 | ||
|
|
b3511f018a | ||
|
|
46ba9541eb | ||
|
|
ecf2d06cfa | ||
|
|
d6a8f77610 | ||
|
|
be0dea3702 | ||
|
|
148327c74e | ||
|
|
eed94a4920 | ||
|
|
e47646c953 | ||
|
|
69567c4869 | ||
|
|
7a00dd1794 | ||
|
|
5fbfe1b039 | ||
|
|
8f9dc2048f | ||
|
|
ca70e4a038 | ||
|
|
16d2701e26 | ||
|
|
005510e0a5 | ||
|
|
5ba6913d5f | ||
|
|
c3400ab6cd | ||
|
|
83355f8bbc | ||
|
|
93f2a5ed50 | ||
|
|
120abaf6dd | ||
|
|
2db855d360 | ||
|
|
7aa2805f4c | ||
|
|
1342f0dcf2 | ||
|
|
4f4fb5e6c7 | ||
|
|
68c8681a9b | ||
|
|
cb8c66849a | ||
|
|
3f60267bdc | ||
|
|
43a1a206d5 | ||
|
|
d4badbb8db | ||
|
|
5346030323 | ||
|
|
c32c9d5eba | ||
|
|
000a5aacdf | ||
|
|
62815a7691 | ||
|
|
e52c0f760c | ||
|
|
bfe2a7f817 | ||
|
|
99c0e1b17d | ||
|
|
e1547dbb94 | ||
|
|
38c4295d0b | ||
|
|
3a9e163c9e | ||
|
|
0065c7c5a7 | ||
|
|
fb21d43425 | ||
|
|
13c5ed92f4 | ||
|
|
c3d626f074 | ||
|
|
a6fa3eee8a | ||
|
|
bf024474d1 | ||
|
|
2228e02770 | ||
|
|
d7d17e7f13 | ||
|
|
9bc9655c3d | ||
|
|
0320131d57 | ||
|
|
8275c01d21 | ||
|
|
125013ba0a | ||
|
|
3b34468842 | ||
|
|
cddd3383e8 | ||
|
|
c6148a1c1c | ||
|
|
b2e34c00a4 | ||
|
|
80a99c425b | ||
|
|
f90063cb03 | ||
|
|
c4abdaa54b | ||
|
|
8a2a65d8ed | ||
|
|
2e23e882bb | ||
|
|
4e96b7a930 | ||
|
|
5e72ec3864 | ||
|
|
05eb762273 | ||
|
|
e2419e2c4b | ||
|
|
72afc94782 | ||
|
|
02070b1db1 | ||
|
|
2fc6c7ba91 | ||
|
|
c706d7932d | ||
|
|
62714cdfe1 | ||
|
|
a2c49ac39f | ||
|
|
de55ea643c | ||
|
|
5fb60e14b8 | ||
|
|
02603cb018 | ||
|
|
ffbff595d1 | ||
|
|
989429824e | ||
|
|
a31e6080e2 | ||
|
|
90e05dfb4b | ||
|
|
2af27ddb68 | ||
|
|
d004faa9e0 | ||
|
|
45a4a23112 | ||
|
|
1bb50f8175 | ||
|
|
0cbfcab3f9 | ||
|
|
d4125963b2 | ||
|
|
2e33c2275c | ||
|
|
a5b21198e0 | ||
|
|
e765cda3f9 | ||
|
|
5a91184d6c | ||
|
|
e2094296f4 | ||
|
|
777e856d00 | ||
|
|
c3f419bbc5 | ||
|
|
52705f6982 | ||
|
|
a5134181be | ||
|
|
79c801d493 | ||
|
|
f9823d5303 | ||
|
|
8339591b27 | ||
|
|
17a6e3186d | ||
|
|
213bad9722 | ||
|
|
ef33bd9fd2 | ||
|
|
123de3d452 | ||
|
|
6591bff728 | ||
|
|
88c0779aa2 | ||
|
|
95adcb117c | ||
|
|
372636f43b | ||
|
|
54dae1ab2b | ||
|
|
f0f50a8507 | ||
|
|
c3d0d5be4c | ||
|
|
929132743c | ||
|
|
6643e8937c | ||
|
|
08b4ee461e | ||
|
|
ae501969bf | ||
|
|
c29ed6d41e | ||
|
|
1c28c895b5 | ||
|
|
d9c32437c9 | ||
|
|
0429bed9e3 | ||
|
|
8bdc36a302 | ||
|
|
a3576cc3f4 | ||
|
|
713db0aa4c | ||
|
|
95aae06a41 | ||
|
|
31a4a6f5b8 | ||
|
|
1c66729974 | ||
|
|
6387947b22 | ||
|
|
3a8469c5a9 | ||
|
|
44715591ef | ||
|
|
ceb9d71a1a | ||
|
|
15ad05277b | ||
|
|
14c5b0a678 | ||
|
|
c95964fa3c | ||
|
|
a46f2cee34 | ||
|
|
1764ce9a30 | ||
|
|
384fa0417a | ||
|
|
97ba1050a7 | ||
|
|
628c506e85 | ||
|
|
9226796463 | ||
|
|
83176ba878 | ||
|
|
94cb067214 | ||
|
|
b56b6e0e42 | ||
|
|
28aa3eae33 | ||
|
|
96dee8dee3 | ||
|
|
400410c449 | ||
|
|
ab08abb3f6 | ||
|
|
01e32537a8 | ||
|
|
652d1c8c4f | ||
|
|
64e7792778 | ||
|
|
bfb03c6d1e | ||
|
|
1fa20f9cda | ||
|
|
9d61ec49c3 | ||
|
|
9dc598feff | ||
|
|
49fde946ac | ||
|
|
c4ded39e7c | ||
|
|
c8518e9f35 | ||
|
|
97d3a38ed8 | ||
|
|
e840b53978 | ||
|
|
c43e52e9ad | ||
|
|
2a2bd99fcf | ||
|
|
c4f9fc4585 | ||
|
|
0222dfd865 | ||
|
|
11f91b67a8 | ||
|
|
6e2d485b90 | ||
|
|
e336a57e13 | ||
|
|
29e7c119bd | ||
|
|
882228558d | ||
|
|
51360e802f | ||
|
|
7a06660597 | ||
|
|
4553cd0261 | ||
|
|
2bbc426bef | ||
|
|
b22a22cac9 | ||
|
|
cc7b931e0a | ||
|
|
d4a44b0d72 | ||
|
|
284a9bb444 | ||
|
|
ef4dc0e972 | ||
|
|
def031958b | ||
|
|
00c1936683 | ||
|
|
cc3aab1e7b | ||
|
|
c14de6d198 | ||
|
|
f9f8186451 | ||
|
|
0259cf84ce | ||
|
|
04ceb5f4fa | ||
|
|
6efcbe7c70 | ||
|
|
e0ce92a9f3 | ||
|
|
28e08e108a | ||
|
|
4e68903251 | ||
|
|
73515e5179 | ||
|
|
f752770788 | ||
|
|
6eb6efe844 | ||
|
|
837b8755a0 | ||
|
|
e3b5e867b1 | ||
|
|
362efd9546 | ||
|
|
a958874731 | ||
|
|
0d5094cfb5 | ||
|
|
74b32e064e | ||
|
|
3ad5dfe030 | ||
|
|
95242965da | ||
|
|
8c15105087 | ||
|
|
db68505cca | ||
|
|
795aee86d1 | ||
|
|
33621ff523 | ||
|
|
415a694228 | ||
|
|
1fe8b7f78d | ||
|
|
c2fc3c54da | ||
|
|
652c2d95b8 | ||
|
|
da1b6caf67 | ||
|
|
deafdfb7ab | ||
|
|
f9feaeab0b | ||
|
|
330c160122 | ||
|
|
238c7b3a44 | ||
|
|
1317696cb7 | ||
|
|
23108f2224 | ||
|
|
6b14252577 | ||
|
|
8386cd7503 | ||
|
|
c6225eeb3a | ||
|
|
a12c2fd120 | ||
|
|
9e503ab31f | ||
|
|
c31abb84c9 | ||
|
|
b1a0bc252f | ||
|
|
599b1639e7 | ||
|
|
1199f9ae8e | ||
|
|
cb8ae318c4 | ||
|
|
fec8a759bc | ||
|
|
5d4b54c39c | ||
|
|
4ebab3a967 | ||
|
|
73315e6671 | ||
|
|
db03a888fb | ||
|
|
7d4a5c4c6c | ||
|
|
94397ea4c7 | ||
|
|
e05319432e | ||
|
|
f1bce695fb | ||
|
|
7aad2697f7 | ||
|
|
848a2d74d6 | ||
|
|
a2a470ad93 | ||
|
|
78150b2661 | ||
|
|
ed2e1a0936 | ||
|
|
445389b7d8 | ||
|
|
1bb8cbf3ab | ||
|
|
ca6fe7b86e | ||
|
|
0b351ea3a2 | ||
|
|
05c5db53bd | ||
|
|
7632e07f4e | ||
|
|
1ddbe43618 | ||
|
|
79f83e245c | ||
|
|
d678f28909 | ||
|
|
c3e95fa98c | ||
|
|
e32e55df15 | ||
|
|
48eaf48797 | ||
|
|
ead505d40c | ||
|
|
a39a53561e | ||
|
|
ebf715c368 | ||
|
|
87f2c360c5 | ||
|
|
b0584b4ead | ||
|
|
1575a4cc34 | ||
|
|
1bc12d7a33 | ||
|
|
89707ff412 | ||
|
|
33b9e220d3 | ||
|
|
d3e39f66a2 | ||
|
|
48a991e11b | ||
|
|
3ef79e51ca | ||
|
|
d945add7a0 | ||
|
|
2e0e25de42 | ||
|
|
334043947a | ||
|
|
e5e8f2b962 | ||
|
|
a16ecbc8a9 | ||
|
|
3c6e9c75a9 | ||
|
|
980bcb2eb5 | ||
|
|
3b73722bca | ||
|
|
15f7a970b1 | ||
|
|
e6083dbe81 | ||
|
|
54a77441fd | ||
|
|
353cf671da | ||
|
|
02c280009b | ||
|
|
379db84504 | ||
|
|
bd56df8ed8 |
No files matched your search
@@ -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
|
||||||
+3
-1
@@ -67,9 +67,11 @@ fabric.properties
|
|||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
/node_modules/
|
|
||||||
/vendor/
|
/vendor/
|
||||||
|
/node_modules/
|
||||||
package.json
|
package.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
|
||||||
conf/config_dev.yml
|
conf/config_dev.yml
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
include:
|
||||||
|
- project: '$CI_PROJECT_PATH'
|
||||||
|
file: '/ci-isp-go-service.yml'
|
||||||
+73
-53
@@ -1,58 +1,78 @@
|
|||||||
|
version: "2"
|
||||||
run:
|
run:
|
||||||
allow-parallel-runners: true
|
allow-parallel-runners: true
|
||||||
issues:
|
|
||||||
exclude-rules:
|
|
||||||
- path: controller #достаточное кол-во контекса на уровне контроллеров
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
- path: transaction #транзакции прозрачны
|
|
||||||
linters:
|
|
||||||
- wrapcheck
|
|
||||||
linters:
|
linters:
|
||||||
enable-all: true
|
default: all
|
||||||
disable:
|
disable:
|
||||||
- goimports #у нас собственные правила форматирования импортов
|
- contextcheck # не имеет смысла
|
||||||
- wsl #расставление пробелов очень индивидуально
|
- depguard # не всегда имеет смысл
|
||||||
- exhaustivestruct #не имеет смысла
|
- dupword # не имеет смысла
|
||||||
- varnamelen #очень индивидуально (db)
|
- exhaustruct # не имеет смысла
|
||||||
- exhaustruct #не имеет смысла
|
- exhaustruct_v5 # не имеет смысла
|
||||||
- golint #устарел
|
- goconst # не всегда имеет смысл
|
||||||
- contextcheck #не имеет смысла
|
- godot # не актуально для swagger
|
||||||
- gci #у нас собственные правила форматирования импортов
|
- godox # не позволяет оставлять todo
|
||||||
- gofumpt #у нас собственные правила форматирования импортов
|
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
|
||||||
- nolintlint #Goland все равно форматирует с отступом
|
- nlreturn # не всегда имеет смысл
|
||||||
- nlreturn #не всегда имеет смысл
|
- nolintlint # Goland все равно форматирует с отступом
|
||||||
- godot #не актуально для свагера
|
- perfsprint # мнимая производительность в угоду читаемости
|
||||||
- ifshort #приняли решение, что мы так не пишем if err := ...; err != nil {}
|
- tagalign # не всегда имеет смысл
|
||||||
- godox #не позволяет оставлять todo
|
- varnamelen # очень индивидуально (db)
|
||||||
- maligned #аллокацией памяти для структур конфликтует с удобством их чтения
|
- wsl # расставление пробелов очень индивидуально
|
||||||
- nosnakecase #не позволяет заводить пакеты используя snake_case
|
- wsl_v5 # расставление пробелов очень индивидуально
|
||||||
- depguard #не всегда имеет смысл
|
- godoclint # ругается на // nolint, не удобно
|
||||||
- dupword #не имеет смысла
|
- prealloc # слишком аггресивный, в большинстве случаев не требуется
|
||||||
- tagalign #не всегда имеет смысл
|
- gomoddirectives # в проекте осознанно захардкожены версии зависимостей
|
||||||
- musttag #у нас собственные правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внених для нас структур
|
settings:
|
||||||
- perfsprint #мнимая производительность в угоду читаемости
|
cyclop:
|
||||||
- gomoddirectives #требует rqlite
|
max-complexity: 15 # по умолчанию 10 мало
|
||||||
- tagliatelle
|
funlen:
|
||||||
- gomnd
|
lines: 80
|
||||||
linters-settings:
|
lll:
|
||||||
funlen:
|
line-length: 150
|
||||||
lines: 80
|
revive:
|
||||||
lll:
|
rules:
|
||||||
line-length: 150
|
- name: var-naming # отключаем Id -> ID
|
||||||
cyclop:
|
disabled: true
|
||||||
max-complexity: 15 #по умолчанию 10 мало
|
staticcheck:
|
||||||
revive:
|
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:
|
rules:
|
||||||
- name: var-naming #отключаем Id -> ID
|
- linters:
|
||||||
disabled: true
|
- wrapcheck
|
||||||
stylecheck:
|
path: controller # достаточное кол-во контекста на уровне контроллеров
|
||||||
checks: #отключаем Id -> ID
|
- linters:
|
||||||
- "-ST1000"
|
- wrapcheck
|
||||||
- "-ST1016"
|
path: transaction # транзакции прозрачны
|
||||||
- "-ST1020"
|
- linters:
|
||||||
- "-ST1021"
|
- unqueryvet
|
||||||
- "-ST1022"
|
- prealloc
|
||||||
testifylint:
|
path: ".*_test\\.go$"
|
||||||
disable:
|
paths:
|
||||||
- compares
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
+5
-4
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.23-alpine as builder
|
FROM golang:1.27-alpine AS builder
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
ARG version
|
ARG version
|
||||||
ENV version_env=$version
|
ENV version_env=$version
|
||||||
@@ -8,15 +8,15 @@ COPY . .
|
|||||||
RUN apk update && apk upgrade && apk add --no-cache gcc musl-dev
|
RUN apk update && apk upgrade && apk add --no-cache gcc musl-dev
|
||||||
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
||||||
WORKDIR cmd/migrate
|
WORKDIR cmd/migrate
|
||||||
RUN CGO_ENABLED=1 go build -o /migrate .
|
#RUN CGO_ENABLED=1 go build -o /migrate .
|
||||||
|
|
||||||
FROM alpine:3.20
|
FROM alpine:3.23
|
||||||
|
|
||||||
RUN apk add --no-cache tzdata
|
RUN apk add --no-cache tzdata
|
||||||
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
|
||||||
RUN echo "Europe/Moscow" > /etc/timezone
|
RUN echo "Europe/Moscow" > /etc/timezone
|
||||||
|
|
||||||
COPY --from=builder migrate /migrate/migrate
|
#COPY --from=builder migrate /migrate/migrate
|
||||||
COPY cmd/migrate/config.yml /migrate/config.yml
|
COPY cmd/migrate/config.yml /migrate/config.yml
|
||||||
RUN chmod 666 /migrate/config.yml
|
RUN chmod 666 /migrate/config.yml
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ RUN adduser \
|
|||||||
--no-create-home \
|
--no-create-home \
|
||||||
--uid "${UID}" \
|
--uid "${UID}" \
|
||||||
appuser
|
appuser
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -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
|
||||||
+45
-10
@@ -2,27 +2,34 @@ package assembly
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"isp-config-service/conf"
|
|
||||||
"isp-config-service/service/module/backend"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/txix-open/etp/v4"
|
"isp-config-service/conf"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"isp-config-service/service/module/backend"
|
||||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
"isp-config-service/service/variable"
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"github.com/txix-open/isp-kit/worker"
|
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"
|
||||||
"isp-config-service/controller/api"
|
"isp-config-service/controller/api"
|
||||||
"isp-config-service/repository"
|
"isp-config-service/repository"
|
||||||
"isp-config-service/routes"
|
"isp-config-service/routes"
|
||||||
apisvs "isp-config-service/service/api"
|
apisvs "isp-config-service/service/api"
|
||||||
"isp-config-service/service/event"
|
"isp-config-service/service/event"
|
||||||
|
"isp-config-service/service/metrics"
|
||||||
"isp-config-service/service/module"
|
"isp-config-service/service/module"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
"isp-config-service/service/subscription"
|
"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 (
|
const (
|
||||||
@@ -70,10 +77,12 @@ func NewLocator(
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
GrpcMux *grpc.Mux
|
GrpcMux *grpc.Mux
|
||||||
HttpMux http.Handler
|
HttpMux http.Handler
|
||||||
|
MetricsAdHandler http.Handler
|
||||||
EtpSrv *etp.Server
|
EtpSrv *etp.Server
|
||||||
HandleEventWorker *worker.Worker
|
HandleEventWorker *worker.Worker
|
||||||
CleanEventWorker *worker.Worker
|
CleanEventWorker *worker.Worker
|
||||||
CleanPhantomBackendWorker *worker.Worker
|
CleanPhantomBackendWorker *worker.Worker
|
||||||
|
CleanBackupsWorker *worker.Worker
|
||||||
OwnBackendsCleaner OwnBackendsCleaner
|
OwnBackendsCleaner OwnBackendsCleaner
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +94,10 @@ func (l Locator) Config() *Config {
|
|||||||
configRepo := repository.NewConfig(l.db)
|
configRepo := repository.NewConfig(l.db)
|
||||||
configSchemaRepo := repository.NewConfigSchema(l.db)
|
configSchemaRepo := repository.NewConfigSchema(l.db)
|
||||||
configHistoryRepo := repository.NewConfigHistory(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(
|
etpSrv := etp.NewServer(
|
||||||
etp.WithServerReadLimit(wsReadLimit),
|
etp.WithServerReadLimit(wsReadLimit),
|
||||||
@@ -99,6 +112,7 @@ func (l Locator) Config() *Config {
|
|||||||
configRepo,
|
configRepo,
|
||||||
etpSrv.Rooms(),
|
etpSrv.Rooms(),
|
||||||
emitter,
|
emitter,
|
||||||
|
variableService,
|
||||||
l.logger,
|
l.logger,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -119,11 +133,13 @@ func (l Locator) Config() *Config {
|
|||||||
configSchemaRepo,
|
configSchemaRepo,
|
||||||
subscriptionService,
|
subscriptionService,
|
||||||
emitter,
|
emitter,
|
||||||
|
variableService,
|
||||||
l.logger,
|
l.logger,
|
||||||
)
|
)
|
||||||
moduleController := controller.NewModule(moduleService, l.logger)
|
moduleController := controller.NewModule(moduleService, l.logger)
|
||||||
|
|
||||||
configHistoryApiService := apisvs.NewConfigHistory(configHistoryRepo, l.cfg.Local.KeepConfigVersions, l.logger)
|
configHistoryApiService := apisvs.NewConfigHistory(configRepo, moduleRepo, configHistoryRepo,
|
||||||
|
l.cfg.Local.KeepConfigVersions, l.logger)
|
||||||
configHistoryController := api.NewConfigHistory(configHistoryApiService)
|
configHistoryController := api.NewConfigHistory(configHistoryApiService)
|
||||||
|
|
||||||
moduleApiService := apisvs.NewModule(moduleRepo, backendRepo, configSchemaRepo)
|
moduleApiService := apisvs.NewModule(moduleRepo, backendRepo, configSchemaRepo)
|
||||||
@@ -135,10 +151,12 @@ func (l Locator) Config() *Config {
|
|||||||
configSchemaRepo,
|
configSchemaRepo,
|
||||||
eventRepo,
|
eventRepo,
|
||||||
configHistoryApiService,
|
configHistoryApiService,
|
||||||
|
variableService,
|
||||||
|
l.logger,
|
||||||
)
|
)
|
||||||
configApiController := api.NewConfig(configApiService)
|
configApiController := api.NewConfig(configApiService)
|
||||||
|
|
||||||
configSchemaApiService := apisvs.NewConfigSchema(configSchemaRepo)
|
configSchemaApiService := apisvs.NewConfigSchema(configSchemaRepo, moduleRepo)
|
||||||
configSchemaController := api.NewConfigSchema(configSchemaApiService)
|
configSchemaController := api.NewConfigSchema(configSchemaApiService)
|
||||||
|
|
||||||
controllers := routes.Controllers{
|
controllers := routes.Controllers{
|
||||||
@@ -147,6 +165,7 @@ func (l Locator) Config() *Config {
|
|||||||
ConfigApi: configApiController,
|
ConfigApi: configApiController,
|
||||||
ConfigHistoryApi: configHistoryController,
|
ConfigHistoryApi: configHistoryController,
|
||||||
ConfigSchemaApi: configSchemaController,
|
ConfigSchemaApi: configSchemaController,
|
||||||
|
VariableApi: variableController,
|
||||||
}
|
}
|
||||||
mapper := endpoint.DefaultWrapper(l.logger)
|
mapper := endpoint.DefaultWrapper(l.logger)
|
||||||
grpcMux := routes.GrpcHandler(mapper, controllers)
|
grpcMux := routes.GrpcHandler(mapper, controllers)
|
||||||
@@ -158,7 +177,14 @@ func (l Locator) Config() *Config {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
rqliteProxy := httputil.NewSingleHostReverseProxy(rqliteUrl)
|
rqliteProxy := httputil.NewSingleHostReverseProxy(rqliteUrl)
|
||||||
httpMux := routes.HttpHandler(etpSrv, l.cfg.Local, rqliteProxy)
|
|
||||||
|
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)
|
eventHandler := event.NewHandler(subscriptionService, l.logger)
|
||||||
handleEventJob := event.NewWorker(eventRepo, eventHandler, l.logger)
|
handleEventJob := event.NewWorker(eventRepo, eventHandler, l.logger)
|
||||||
@@ -167,13 +193,22 @@ func (l Locator) Config() *Config {
|
|||||||
cleanerJob := event.NewCleaner(eventRepo, l.leaderChecker, eventTtl, l.logger)
|
cleanerJob := event.NewCleaner(eventRepo, l.leaderChecker, eventTtl, l.logger)
|
||||||
cleanEventWorker := worker.New(cleanerJob, worker.WithInterval(cleanEventInterval))
|
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{
|
return &Config{
|
||||||
GrpcMux: grpcMux,
|
GrpcMux: grpcMux,
|
||||||
EtpSrv: etpSrv,
|
EtpSrv: etpSrv,
|
||||||
HttpMux: httpMux,
|
HttpMux: httpMux,
|
||||||
|
MetricsAdHandler: httpWrapper.Endpoint(metricsController.Autodiscovery),
|
||||||
HandleEventWorker: handleEventWorker,
|
HandleEventWorker: handleEventWorker,
|
||||||
CleanEventWorker: cleanEventWorker,
|
CleanEventWorker: cleanEventWorker,
|
||||||
CleanPhantomBackendWorker: cleanPhantomBackendWorker,
|
CleanPhantomBackendWorker: cleanPhantomBackendWorker,
|
||||||
|
CleanBackupsWorker: cleanBackupsWorker,
|
||||||
OwnBackendsCleaner: backendService,
|
OwnBackendsCleaner: backendService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,67 @@
|
|||||||
|
### 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
|
## v3.1.2
|
||||||
* возвращена поддержка rqlite.DiscoMode `dns` и `dns-srv`
|
* возвращена поддержка rqlite.DiscoMode `dns` и `dns-srv`
|
||||||
* добавлена поддержка работы в `kubernetes` c autodiscovery
|
* добавлена поддержка работы в `kubernetes` c autodiscovery
|
||||||
|
|||||||
+45
-43
@@ -1,76 +1,78 @@
|
|||||||
module isp-config-service/migrate
|
module isp-config-service/migrate
|
||||||
|
|
||||||
go 1.23
|
go 1.27
|
||||||
|
|
||||||
replace isp-config-service => ../..
|
replace isp-config-service => ../..
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/jmoiron/sqlx v1.4.0
|
github.com/jmoiron/sqlx v1.4.0
|
||||||
github.com/mattn/go-sqlite3 v1.14.22
|
github.com/mattn/go-sqlite3 v1.14.47
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pressly/goose/v3 v3.30.1
|
||||||
github.com/pressly/goose/v3 v3.22.1
|
github.com/txix-open/isp-kit v1.76.0
|
||||||
github.com/txix-open/isp-kit v1.39.2
|
|
||||||
isp-config-service v0.0.0-00010101000000-000000000000
|
isp-config-service v0.0.0-00010101000000-000000000000
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/squirrel v1.5.4 // indirect
|
github.com/Masterminds/squirrel v1.5.4 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/coder/websocket v1.8.12 // indirect
|
github.com/coder/websocket v1.8.15 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.4 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.2 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 // indirect
|
||||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/pgx/v5 v5.7.1 // indirect
|
github.com/jackc/pgx/v5 v5.13.0 // indirect
|
||||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
github.com/jackc/puddle/v2 v2.2.4 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.11 // indirect
|
github.com/klauspost/compress v1.20.4 // indirect
|
||||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.5.0 // indirect
|
||||||
github.com/mfridman/interpolate v0.0.2 // indirect
|
github.com/mfridman/interpolate v0.2.0 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.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/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/prometheus/client_golang v1.20.5 // indirect
|
github.com/pandatix/go-abnf v0.5.5 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_golang v1.25.0 // indirect
|
||||||
github.com/prometheus/common v0.60.1 // indirect
|
github.com/prometheus/client_model v0.6.3 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/common v0.74.0 // indirect
|
||||||
github.com/sethvargo/go-retry v0.3.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/gjson v1.18.0 // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.2.0 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
github.com/txix-open/bellows v1.2.0 // indirect
|
github.com/txix-open/bellows v1.2.0 // indirect
|
||||||
github.com/txix-open/etp/v4 v4.0.1 // indirect
|
github.com/txix-open/etp/v4 v4.1.3 // indirect
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 // indirect
|
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.31.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
|
go.opentelemetry.io/otel v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
|
go.opentelemetry.io/otel/log v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 // indirect
|
go.opentelemetry.io/otel/metric v1.47.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 // 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/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.28.0 // indirect
|
||||||
golang.org/x/crypto v0.28.0 // indirect
|
golang.org/x/crypto v0.59.0 // indirect
|
||||||
golang.org/x/net v0.30.0 // indirect
|
golang.org/x/net v0.63.0 // indirect
|
||||||
golang.org/x/sync v0.8.0 // indirect
|
golang.org/x/sync v0.25.0 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/sys v0.50.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/text v0.44.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f // indirect
|
||||||
google.golang.org/grpc v1.67.1 // indirect
|
google.golang.org/grpc v1.85.0 // indirect
|
||||||
google.golang.org/protobuf v1.35.1 // indirect
|
google.golang.org/protobuf v1.36.12 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
+128
-122
@@ -1,72 +1,69 @@
|
|||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
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 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
|
||||||
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
|
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 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
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 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
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 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
|
||||||
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
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.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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
|
github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
|
github.com/getsentry/sentry-go v0.50.0/go.mod h1:+xsDuN+SoRN/xfs1hdq78wnrE3omIZf+FCuh9FOW1C8=
|
||||||
github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA=
|
|
||||||
github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0=
|
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
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 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
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 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
||||||
github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8=
|
|
||||||
github.com/go-resty/resty/v2 v2.15.3/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
|
|
||||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
|
||||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/go-sql-driver/mysql v1.10.1 h1:arlSnNLq6a5yxGxV7qg9lF4j0C+KwD6NbQyKr9QL6ME=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
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/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 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0/go.mod h1:FHXQZnW5pA0txiMr3jApv9uNJzZ+7mYZd+u+PPenCFU=
|
||||||
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
|
||||||
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
|
||||||
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
|
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 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
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 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
|
github.com/jackc/pgx/v5 v5.13.0 h1:Hl08k64maU0nrRyVUEbwCnK6/gT0EhMrtAqBHz9/gA4=
|
||||||
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
|
github.com/jackc/pgx/v5 v5.13.0/go.mod h1:u2Fi6no03HCSBYE+ZVdLxbwdu3xyi2vU+K/YNJioSds=
|
||||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
github.com/jackc/puddle/v2 v2.2.4 h1:N6Mz6EGB9DL0bz3OEfxJ7eoOpjRHnnjpOh+G8kbLoG8=
|
||||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
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 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||||
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
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 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
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 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
|
||||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
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 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
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 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
@@ -77,16 +74,17 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq
|
|||||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
|
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 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
|
||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
||||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
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 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
|
||||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
github.com/mattn/go-sqlite3 v1.14.47 h1:jOBI62gS7nKeZv+as1oGEy0+1qISgXwH/QBlR6KbfIo=
|
||||||
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
|
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 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
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-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -96,29 +94,27 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
|||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
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 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
|
||||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
github.com/ncruces/go-strftime v1.1.0/go.mod h1:yVaq7iwCN09vHRrKBrrflXT0M9tTMG2KmZ9Fj7xeG/g=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pandatix/go-abnf v0.5.5 h1:EXex5KkRQx4Dm6GnpAcQnIMBs9KiK0uf8p/wq+4t9PM=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
github.com/pressly/goose/v3 v3.30.1 h1:KO28meBdbAUIdMbTP7bl9dp1FYZGXcYWb2O7miT09lE=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pressly/goose/v3 v3.30.1/go.mod h1:CHGwuG2acDerUaXwz2i5T18VSauXpYDiL4WxzDvcOIM=
|
||||||
github.com/pressly/goose/v3 v3.22.1 h1:2zICEfr1O3yTP9BRZMGPj7qFxQ+ik6yeo+z1LMuioLc=
|
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
|
||||||
github.com/pressly/goose/v3 v3.22.1/go.mod h1:xtMpbstWyCpyH+0cxLTMCENWBG+0CSxvTsXhW95d5eo=
|
github.com/prometheus/client_golang v1.25.0/go.mod h1:j2X/4/kaQHLPnmyEU8zjmkndo1T317VpCIQEml8LTKk=
|
||||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
|
||||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
github.com/prometheus/client_model v0.6.3/go.mod h1:gpN5P9S7Rr6Yr92PiQ+Ixvhf6JZEkF1dnxsYL2aPBEM=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
github.com/prometheus/common v0.74.0/go.mod h1:i/02C+FCst5B1etKgWesNrD49n+onplJCqUCtUKkOeA=
|
||||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
|
||||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
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/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
github.com/sethvargo/go-retry v0.5.0 h1:JYfFKmVJ8ER06GReN1efzc5cm52BrVsFVzmcHiKJwfY=
|
||||||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
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.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.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.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@@ -129,65 +125,79 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.7.1/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.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.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
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 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
|
||||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
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.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
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 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
||||||
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||||
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
|
||||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||||
github.com/txix-open/isp-kit v1.39.2 h1:2L2LFwi+sNop9NeLDQ4scIy8LuohzXh4EBejHApAeDM=
|
github.com/txix-open/isp-kit v1.76.0 h1:kqhX2DuoTfeW7BIshedG26TRIfOgX0QOInm606ssGVg=
|
||||||
github.com/txix-open/isp-kit v1.39.2/go.mod h1:xB6mkoOewZBI1ND8kjU5TR6kvLu3VQI3Rdkh6g6FE4I=
|
github.com/txix-open/isp-kit v1.76.0/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To=
|
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-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
github.com/txix-open/validator/v10 v10.0.0-20261027072444-85f3391fc5c3/go.mod h1:Yf41v210LFyYAj+tGmDh7PHdGsTaZjdBzHG0ptUvihw=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 h1:4BZHA+B1wXEQoGNHxW8mURaLhcdGwvRnmhGbm+odRbc=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0/go.mod h1:3qi2EEwMgB4xnKgPLqsDP3j9qxnHDZeHsnAxfjQqTko=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
|
||||||
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
|
||||||
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk=
|
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME=
|
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 h1:lUsI2TYsQw2r1IASwoROaCnjdj2cvC2+Jbxvk6nHnWU=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0/go.mod h1:2HpZxxQurfGxJlJDblybejHB6RX6pmExPNe517hREw4=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
|
||||||
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
|
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
|
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
|
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
|
||||||
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
|
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
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 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
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 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q=
|
||||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
go.yaml.in/yaml/v2 v2.4.5 h1:a5nxWvYi94DRl6QSLlTbLpVmutgx2qg8EVjnJtuFpwI=
|
||||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
go.yaml.in/yaml/v2 v2.4.5/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ=
|
||||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
go.yaml.in/yaml/v3 v3.0.6 h1:zcDfvjXEqTQmpjniUBLc91xYJMB2c4QOFxEF/LCEckM=
|
||||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
go.yaml.in/yaml/v3 v3.0.6/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
||||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
||||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
|
||||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw=
|
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc=
|
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI=
|
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
|
||||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
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 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 h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
@@ -196,15 +206,11 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
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 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
|
modernc.org/libc v1.80.2 h1:3+a4fJZvvzg920ZC0mOepnKPGn7cqCaVeDxm/UnrM1A=
|
||||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
|
modernc.org/libc v1.80.2/go.mod h1:pvo25Rs3OJEbDqhUV9jdEGevxeLJrJeDmNid/AcQV1g=
|
||||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||||
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||||
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||||
modernc.org/sqlite v1.33.0 h1:WWkA/T2G17okiLGgKAj4/RMIvgyMT19yQ038160IeYk=
|
modernc.org/sqlite v1.62.0 h1:gMaCjSM1qpl+iOjiWhR1LYP3zqrYDI+5GYLGt6veP2g=
|
||||||
modernc.org/sqlite v1.33.0/go.mod h1:9uQ9hF/pCZoYZK73D/ud5Z7cIRIILSZI8NdIemVMTX8=
|
modernc.org/sqlite v1.62.0/go.mod h1:Jzjh1mt4s0HuQ0KvtB1LIuHiGRmU2D5pgj8dUhW7/SE=
|
||||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
|
||||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
|
||||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
|
||||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
|
||||||
+17
-6
@@ -1,7 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pressly/goose/v3"
|
"github.com/pressly/goose/v3"
|
||||||
"github.com/txix-open/isp-kit/config"
|
"github.com/txix-open/isp-kit/config"
|
||||||
"github.com/txix-open/isp-kit/dbx"
|
"github.com/txix-open/isp-kit/dbx"
|
||||||
@@ -10,14 +15,12 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"github.com/txix-open/isp-kit/validator"
|
"github.com/txix-open/isp-kit/validator"
|
||||||
"isp-config-service/service/rqlite/goose_store"
|
"isp-config-service/service/rqlite/goose_store"
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/app"
|
"github.com/txix-open/isp-kit/app"
|
||||||
"github.com/txix-open/isp-kit/db"
|
"github.com/txix-open/isp-kit/db"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
"isp-config-service/migrate/migration"
|
"isp-config-service/migrate/migration"
|
||||||
@@ -34,6 +37,14 @@ type Cfg struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type dbClient struct {
|
||||||
|
*db.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d dbClient) ExecTransaction(ctx context.Context, requests [][]any) ([]sql.Result, error) {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app, err := app.New(app.WithConfigOptions(
|
app, err := app.New(app.WithConfigOptions(
|
||||||
config.WithValidator(validator.Default),
|
config.WithValidator(validator.Default),
|
||||||
@@ -58,7 +69,7 @@ func main() {
|
|||||||
defer pgDb.Close()
|
defer pgDb.Close()
|
||||||
|
|
||||||
fileName := fmt.Sprintf("db_%d.sqlite", time.Now().Unix())
|
fileName := fmt.Sprintf("db_%d.sqlite", time.Now().Unix())
|
||||||
dbClient := &db.Client{}
|
dbClient := dbClient{&db.Client{}}
|
||||||
dbClient.DB, err = sqlx.Open("sqlite3", fileName)
|
dbClient.DB, err = sqlx.Open("sqlite3", fileName)
|
||||||
dbClient.DB.MapperFunc(db.ToSnakeCase)
|
dbClient.DB.MapperFunc(db.ToSnakeCase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -156,7 +167,7 @@ func main() {
|
|||||||
AdminId: 0,
|
AdminId: 0,
|
||||||
CreatedAt: xtypes.Time(history.CreatedAt),
|
CreatedAt: xtypes.Time(history.CreatedAt),
|
||||||
}
|
}
|
||||||
err := configHistoryRepo.Insert(ctx, result)
|
err := configHistoryRepo.InsertV2(ctx, result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(errors.WithMessagef(err, "err inserting config_history: %s", history.Id))
|
panic(errors.WithMessagef(err, "err inserting config_history: %s", history.Id))
|
||||||
}
|
}
|
||||||
@@ -183,7 +194,7 @@ func main() {
|
|||||||
Header("Content-Type", "application/octet-stream").
|
Header("Content-Type", "application/octet-stream").
|
||||||
RequestBody(sqliteFile).
|
RequestBody(sqliteFile).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
Timeout(60 * time.Second).
|
Timeout(120 * time.Second).
|
||||||
DoWithoutResponse(ctx)
|
DoWithoutResponse(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(errors.WithMessage(err, "load sqlite file"))
|
panic(errors.WithMessage(err, "load sqlite file"))
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/pressly/goose/v3"
|
"github.com/pressly/goose/v3"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -35,4 +35,17 @@ rqlite:
|
|||||||
JoinAddrs: "127.0.0.1:9008"
|
JoinAddrs: "127.0.0.1:9008"
|
||||||
FKConstraints: true
|
FKConstraints: true
|
||||||
AutoVacInterval: 12h
|
AutoVacInterval: 12h
|
||||||
|
AutoOptimizeInterval: 23h
|
||||||
JoinAs: default
|
JoinAs: default
|
||||||
|
|
||||||
|
backup:
|
||||||
|
Enable: true
|
||||||
|
Amount: 5
|
||||||
|
Interval: "24h"
|
||||||
|
ClearInterval: "168h"
|
||||||
|
Sub:
|
||||||
|
Dir: "/app/data/backups/rqlite"
|
||||||
|
Name: "backup.sqlite.gz"
|
||||||
|
|
||||||
|
metricsAutodiscovery:
|
||||||
|
enable: true
|
||||||
+5
-2
@@ -1,7 +1,9 @@
|
|||||||
package conf
|
package conf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/rqlite/rqlite/v8/auth"
|
"isp-config-service/service/rqlite"
|
||||||
|
|
||||||
|
"github.com/rqlite/rqlite/v10/auth"
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,9 +11,10 @@ type Local struct {
|
|||||||
ConfigServiceAddress bootstrap.ConfigServiceAddr
|
ConfigServiceAddress bootstrap.ConfigServiceAddr
|
||||||
MaintenanceMode bool
|
MaintenanceMode bool
|
||||||
Credentials []auth.Credential
|
Credentials []auth.Credential
|
||||||
KeepConfigVersions int `validate:"required"`
|
KeepConfigVersions int
|
||||||
InternalClientCredential string `validate:"required"`
|
InternalClientCredential string `validate:"required"`
|
||||||
Rqlite Rqlite
|
Rqlite Rqlite
|
||||||
|
Backup rqlite.Backup
|
||||||
}
|
}
|
||||||
|
|
||||||
type Rqlite struct {
|
type Rqlite struct {
|
||||||
|
|||||||
+66
-10
@@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
@@ -16,10 +16,12 @@ import (
|
|||||||
type ConfigService interface {
|
type ConfigService interface {
|
||||||
GetActiveConfigByModuleName(ctx context.Context, moduleName string) (*domain.Config, error)
|
GetActiveConfigByModuleName(ctx context.Context, moduleName string) (*domain.Config, error)
|
||||||
GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error)
|
GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error)
|
||||||
CreateUpdateConfig(ctx context.Context, adminId int, req domain.CreateUpdateConfigRequest) (*domain.Config, error)
|
CreateUpdateConfig(ctx context.Context, adminId int, req domain.CreateUpdateConfigRequest) (*domain.CreateUpdateConfigResponse, error)
|
||||||
GetConfigById(ctx context.Context, configId string) (*domain.Config, error)
|
GetConfigById(ctx context.Context, configId string) (*domain.Config, error)
|
||||||
MarkConfigAsActive(ctx context.Context, configId string) error
|
MarkConfigAsActive(ctx context.Context, configId string) error
|
||||||
DeleteConfig(ctx context.Context, id 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 {
|
type Config struct {
|
||||||
@@ -94,7 +96,7 @@ func (c Config) GetConfigsByModuleId(ctx context.Context, req domain.GetByModule
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.CreateUpdateConfigRequest true "объект для сохранения"
|
// @Param body body domain.CreateUpdateConfigRequest true "объект для сохранения"
|
||||||
// @Success 200 {object} domain.Config
|
// @Success 200 {object} domain.CreateUpdateConfigResponse
|
||||||
// @Failure 400 {object} apierrors.Error "`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode: 2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже обновил конфигурацию<br/>`errorCode: 2005` - схема конфигурации не найдена<br/>"
|
// @Failure 400 {object} apierrors.Error "`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode: 2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже обновил конфигурацию<br/>`errorCode: 2005` - схема конфигурации не найдена<br/>"
|
||||||
// @Failure 500 {object} apierrors.Error
|
// @Failure 500 {object} apierrors.Error
|
||||||
// @Router /config/create_update_config [POST]
|
// @Router /config/create_update_config [POST]
|
||||||
@@ -102,14 +104,14 @@ func (c Config) CreateUpdateConfig(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
authData grpc.AuthData,
|
authData grpc.AuthData,
|
||||||
req domain.CreateUpdateConfigRequest,
|
req domain.CreateUpdateConfigRequest,
|
||||||
) (*domain.Config, error) {
|
) (*domain.CreateUpdateConfigResponse, error) {
|
||||||
adminIdValue, _ := grpc.StringFromMd("x-admin-id", metadata.MD(authData))
|
adminIdValue, _ := grpc.StringFromMd("x-admin-id", metadata.MD(authData))
|
||||||
var adminId int
|
var adminId int
|
||||||
if adminIdValue != "" {
|
if adminIdValue != "" {
|
||||||
adminId, _ = strconv.Atoi(adminIdValue)
|
adminId, _ = strconv.Atoi(adminIdValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := c.service.CreateUpdateConfig(ctx, adminId, req)
|
resp, err := c.service.CreateUpdateConfig(ctx, adminId, req)
|
||||||
|
|
||||||
var validationError domain.ConfigValidationError
|
var validationError domain.ConfigValidationError
|
||||||
switch {
|
switch {
|
||||||
@@ -144,7 +146,7 @@ func (c Config) CreateUpdateConfig(
|
|||||||
case err != nil:
|
case err != nil:
|
||||||
return nil, apierrors.NewInternalServiceError(err)
|
return nil, apierrors.NewInternalServiceError(err)
|
||||||
default:
|
default:
|
||||||
return config, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,12 +155,12 @@ func (c Config) CreateUpdateConfig(
|
|||||||
// @Tags Конфигурация
|
// @Tags Конфигурация
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.ConfigIdRequest true "id конфигурации"
|
// @Param body body domain.IdRequest true "id конфигурации"
|
||||||
// @Success 200 {object} domain.Config
|
// @Success 200 {object} domain.Config
|
||||||
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
|
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
|
||||||
// @Failure 500 {object} apierrors.Error
|
// @Failure 500 {object} apierrors.Error
|
||||||
// @Router /config/get_config_by_id [POST]
|
// @Router /config/get_config_by_id [POST]
|
||||||
func (c Config) GetConfigById(ctx context.Context, req domain.ConfigIdRequest) (*domain.Config, error) {
|
func (c Config) GetConfigById(ctx context.Context, req domain.IdRequest) (*domain.Config, error) {
|
||||||
config, err := c.service.GetConfigById(ctx, req.Id)
|
config, err := c.service.GetConfigById(ctx, req.Id)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, entity.ErrConfigNotFound):
|
case errors.Is(err, entity.ErrConfigNotFound):
|
||||||
@@ -180,12 +182,12 @@ func (c Config) GetConfigById(ctx context.Context, req domain.ConfigIdRequest) (
|
|||||||
// @Tags Конфигурация
|
// @Tags Конфигурация
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.ConfigIdRequest true "id конфигурации для изменения"
|
// @Param body body domain.IdRequest true "id конфигурации для изменения"
|
||||||
// @Success 200
|
// @Success 200
|
||||||
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
|
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
|
||||||
// @Failure 500 {object} apierrors.Error
|
// @Failure 500 {object} apierrors.Error
|
||||||
// @Router /config/mark_config_as_active [POST]
|
// @Router /config/mark_config_as_active [POST]
|
||||||
func (c Config) MarkConfigAsActive(ctx context.Context, identity domain.ConfigIdRequest) error {
|
func (c Config) MarkConfigAsActive(ctx context.Context, identity domain.IdRequest) error {
|
||||||
err := c.service.MarkConfigAsActive(ctx, identity.Id)
|
err := c.service.MarkConfigAsActive(ctx, identity.Id)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, entity.ErrConfigNotFound):
|
case errors.Is(err, entity.ErrConfigNotFound):
|
||||||
@@ -234,3 +236,57 @@ func (c Config) DeleteConfigs(ctx context.Context, identities []string) (*domain
|
|||||||
}, nil
|
}, 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,13 +3,17 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
|
||||||
"isp-config-service/domain"
|
"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 {
|
type ConfigHistoryService interface {
|
||||||
GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error)
|
GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error)
|
||||||
Delete(ctx context.Context, id string) error
|
Delete(ctx context.Context, id string) error
|
||||||
|
Purge(ctx context.Context, moduleName string, keepVersions int) (map[string]int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigHistory struct {
|
type ConfigHistory struct {
|
||||||
@@ -28,17 +32,25 @@ func NewConfigHistory(service ConfigHistoryService) ConfigHistory {
|
|||||||
// @Tags Конфигурация
|
// @Tags Конфигурация
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.ConfigIdRequest true "id конфигурации"
|
// @Param body body domain.IdRequest true "id конфигурации"
|
||||||
// @Success 200 {array} domain.ConfigVersion
|
// @Success 200 {array} domain.ConfigVersion
|
||||||
// @Failure 400 {object} apierrors.Error "если не указан массив идентификаторов"
|
// @Failure 400 {object} apierrors.Error "если не указан массив идентификаторов"
|
||||||
// @Failure 500 {object} apierrors.Error
|
// @Failure 500 {object} apierrors.Error
|
||||||
// @Router /config/get_all_version [POST]
|
// @Router /config/get_all_version [POST]
|
||||||
func (c ConfigHistory) GetAllVersion(ctx context.Context, req domain.ConfigIdRequest) ([]domain.ConfigVersion, error) {
|
func (c ConfigHistory) GetAllVersion(ctx context.Context, req domain.IdRequest) ([]domain.ConfigVersion, error) {
|
||||||
versions, err := c.service.GetAllVersions(ctx, req.Id)
|
versions, err := c.service.GetAllVersions(ctx, req.Id)
|
||||||
if err != nil {
|
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)
|
return nil, apierrors.NewInternalServiceError(err)
|
||||||
|
default:
|
||||||
|
return versions, nil
|
||||||
}
|
}
|
||||||
return versions, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteConfigVersion
|
// DeleteConfigVersion
|
||||||
@@ -47,12 +59,12 @@ func (c ConfigHistory) GetAllVersion(ctx context.Context, req domain.ConfigIdReq
|
|||||||
// @Tags Конфигурация
|
// @Tags Конфигурация
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body domain.ConfigIdRequest true "id версии конфигурации"
|
// @Param body body domain.IdRequest true "id версии конфигурации"
|
||||||
// @Success 200 {object} domain.DeleteResponse
|
// @Success 200 {object} domain.DeleteResponse
|
||||||
// @Failure 400 {object} apierrors.Error "не указан массив идентификаторов"
|
// @Failure 400 {object} apierrors.Error "не указан массив идентификаторов"
|
||||||
// @Failure 500 {object} apierrors.Error
|
// @Failure 500 {object} apierrors.Error
|
||||||
// @Router /config/delete_version [POST]
|
// @Router /config/delete_version [POST]
|
||||||
func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, req domain.ConfigIdRequest) (*domain.DeleteResponse, error) {
|
func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, req domain.IdRequest) (*domain.DeleteResponse, error) {
|
||||||
err := c.service.Delete(ctx, req.Id)
|
err := c.service.Delete(ctx, req.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, apierrors.NewInternalServiceError(err)
|
return nil, apierrors.NewInternalServiceError(err)
|
||||||
@@ -61,3 +73,30 @@ func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, req domain.Confi
|
|||||||
Deleted: 1,
|
Deleted: 1,
|
||||||
}, nil
|
}, 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,14 +3,16 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/apierrors"
|
|
||||||
"isp-config-service/domain"
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/apierrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigSchemaService interface {
|
type ConfigSchemaService interface {
|
||||||
SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error)
|
SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error)
|
||||||
|
UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigSchema struct {
|
type ConfigSchema struct {
|
||||||
@@ -49,3 +51,30 @@ func (c ConfigSchema) SchemaByModuleId(ctx context.Context, request domain.GetBy
|
|||||||
return schema, nil
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ type ModuleService interface {
|
|||||||
Status(ctx context.Context) ([]domain.ModuleInfo, error)
|
Status(ctx context.Context) ([]domain.ModuleInfo, error)
|
||||||
Delete(ctx context.Context, id string) error
|
Delete(ctx context.Context, id string) error
|
||||||
Connections(ctx context.Context) ([]domain.Connection, error)
|
Connections(ctx context.Context) ([]domain.Connection, error)
|
||||||
|
RequiredModules(ctx context.Context) ([]domain.ModuleRelation, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Module struct {
|
type Module struct {
|
||||||
@@ -65,6 +66,23 @@ func (c Module) DeleteModule(ctx context.Context, identities []string) (*domain.
|
|||||||
}, nil
|
}, 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
|
// Connections
|
||||||
// @Summary Метод получения маршрутов
|
// @Summary Метод получения маршрутов
|
||||||
// @Description Возвращает все доступные роуты
|
// @Description Возвращает все доступные роуты
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -2,11 +2,11 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/txix-open/etp/v4"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/etp/v4"
|
||||||
"github.com/txix-open/etp/v4/msg"
|
"github.com/txix-open/etp/v4/msg"
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"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/json"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/helpers"
|
"isp-config-service/helpers"
|
||||||
|
|||||||
+527
-13
@@ -28,13 +28,6 @@ definitions:
|
|||||||
version:
|
version:
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
domain.ConfigIdRequest:
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
type: object
|
|
||||||
domain.ConfigSchema:
|
domain.ConfigSchema:
|
||||||
properties:
|
properties:
|
||||||
createdAt:
|
createdAt:
|
||||||
@@ -75,10 +68,14 @@ definitions:
|
|||||||
type: string
|
type: string
|
||||||
id:
|
id:
|
||||||
type: string
|
type: string
|
||||||
|
isModuleLeader:
|
||||||
|
type: boolean
|
||||||
libVersion:
|
libVersion:
|
||||||
type: string
|
type: string
|
||||||
moduleName:
|
moduleName:
|
||||||
type: string
|
type: string
|
||||||
|
transport:
|
||||||
|
type: string
|
||||||
version:
|
version:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
@@ -100,6 +97,47 @@ definitions:
|
|||||||
- moduleId
|
- moduleId
|
||||||
- name
|
- name
|
||||||
type: object
|
type: object
|
||||||
|
domain.CreateUpdateConfigResponse:
|
||||||
|
properties:
|
||||||
|
active:
|
||||||
|
type: boolean
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
data:
|
||||||
|
type: object
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
isChanged:
|
||||||
|
type: boolean
|
||||||
|
moduleId:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
valid:
|
||||||
|
type: boolean
|
||||||
|
version:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
domain.CreateVariableRequest:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
enum:
|
||||||
|
- SECRET
|
||||||
|
- TEXT
|
||||||
|
type: string
|
||||||
|
value:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- type
|
||||||
|
- value
|
||||||
|
type: object
|
||||||
domain.DeleteResponse:
|
domain.DeleteResponse:
|
||||||
properties:
|
properties:
|
||||||
deleted:
|
deleted:
|
||||||
@@ -107,6 +145,8 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
domain.EndpointDescriptor:
|
domain.EndpointDescriptor:
|
||||||
properties:
|
properties:
|
||||||
|
httpMethod:
|
||||||
|
type: string
|
||||||
inner:
|
inner:
|
||||||
type: boolean
|
type: boolean
|
||||||
path:
|
path:
|
||||||
@@ -126,6 +166,22 @@ definitions:
|
|||||||
required:
|
required:
|
||||||
- moduleName
|
- moduleName
|
||||||
type: object
|
type: object
|
||||||
|
domain.IdRequest:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
type: object
|
||||||
|
domain.LinkedConfig:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
moduleId:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
domain.ModuleInfo:
|
domain.ModuleInfo:
|
||||||
properties:
|
properties:
|
||||||
active:
|
active:
|
||||||
@@ -147,10 +203,142 @@ definitions:
|
|||||||
$ref: '#/definitions/domain.Connection'
|
$ref: '#/definitions/domain.Connection'
|
||||||
type: array
|
type: array
|
||||||
type: object
|
type: object
|
||||||
|
domain.ModuleRelation:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
requiredModules:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.RequiredModuleType'
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
domain.PrometheusTargets:
|
||||||
|
properties:
|
||||||
|
labels:
|
||||||
|
additionalProperties:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
targets:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
type: object
|
||||||
|
domain.PurgeConfigVersionsRequest:
|
||||||
|
properties:
|
||||||
|
keepVersions:
|
||||||
|
type: integer
|
||||||
|
moduleName:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- keepVersions
|
||||||
|
- moduleName
|
||||||
|
type: object
|
||||||
|
domain.RequiredModuleType:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
domain.SyncConfigRequest:
|
||||||
|
properties:
|
||||||
|
moduleName:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- moduleName
|
||||||
|
type: object
|
||||||
|
domain.UpdateConfigNameRequest:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
newConfigName:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- newConfigName
|
||||||
|
type: object
|
||||||
|
domain.UpdateSchemaRequest:
|
||||||
|
properties:
|
||||||
|
moduleName:
|
||||||
|
type: string
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- moduleName
|
||||||
|
- schema
|
||||||
|
type: object
|
||||||
|
domain.UpdateVariableRequest:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
value:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- value
|
||||||
|
type: object
|
||||||
|
domain.UpsertVariableRequest:
|
||||||
|
properties:
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
enum:
|
||||||
|
- SECRET
|
||||||
|
- TEXT
|
||||||
|
type: string
|
||||||
|
value:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- type
|
||||||
|
- value
|
||||||
|
type: object
|
||||||
|
domain.Variable:
|
||||||
|
properties:
|
||||||
|
containsInConfigs:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.LinkedConfig'
|
||||||
|
type: array
|
||||||
|
createdAt:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
updatedAt:
|
||||||
|
type: string
|
||||||
|
value:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
domain.VariableByNameRequest:
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
type: object
|
||||||
github_com_txix-open_isp-kit_grpc_apierrors.Error:
|
github_com_txix-open_isp-kit_grpc_apierrors.Error:
|
||||||
properties:
|
properties:
|
||||||
details:
|
details:
|
||||||
additionalProperties: true
|
additionalProperties: {}
|
||||||
|
type: object
|
||||||
|
errorCode:
|
||||||
|
type: integer
|
||||||
|
errorMessage:
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
github_com_txix-open_isp-kit_http_apierrors.Error:
|
||||||
|
properties:
|
||||||
|
details:
|
||||||
|
additionalProperties: {}
|
||||||
type: object
|
type: object
|
||||||
errorCode:
|
errorCode:
|
||||||
type: integer
|
type: integer
|
||||||
@@ -186,7 +374,7 @@ paths:
|
|||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.Config'
|
$ref: '#/definitions/domain.CreateUpdateConfigResponse'
|
||||||
"400":
|
"400":
|
||||||
description: '`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode:
|
description: '`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode:
|
||||||
2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже
|
2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже
|
||||||
@@ -243,7 +431,7 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
$ref: '#/definitions/domain.IdRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -304,7 +492,7 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
$ref: '#/definitions/domain.IdRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -335,7 +523,7 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
$ref: '#/definitions/domain.IdRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -398,7 +586,7 @@ paths:
|
|||||||
name: body
|
name: body
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
$ref: '#/definitions/domain.IdRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
@@ -415,6 +603,120 @@ paths:
|
|||||||
summary: Метод активации конфигурации для модуля
|
summary: Метод активации конфигурации для модуля
|
||||||
tags:
|
tags:
|
||||||
- Конфигурация
|
- Конфигурация
|
||||||
|
/config/purge_versions:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Возвращает количество удаленных версий каждой конфигурации
|
||||||
|
parameters:
|
||||||
|
- description: Название модуля, количество оставленных версий конфигурации
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.PurgeConfigVersionsRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2001` - модуль не найден'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод удаления старых версий всех конфигураций модуля, оставляет keepVersions
|
||||||
|
последних версий каждой конфигурации
|
||||||
|
tags:
|
||||||
|
- Конфигурация
|
||||||
|
/config/sync_config:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Метод синхронизации актуальной конфигурации пришедешего модуля
|
||||||
|
parameters:
|
||||||
|
- description: название модуля
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.SyncConfigRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.Config'
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2001` - модуль не найден<br/>`errorCode: 2002`
|
||||||
|
- конфиг не найден'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод синхронизации актуальной конфигурации пришедешего модуля
|
||||||
|
tags:
|
||||||
|
- Конфигурация
|
||||||
|
/config/update_config_name:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Изменеяет название конфигурации без повышения версии и без рассылки
|
||||||
|
события
|
||||||
|
parameters:
|
||||||
|
- description: id конфигурации и новое название
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.UpdateConfigNameRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2002` - конфиг не найден<br/>'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод переименования объекта конфигурации
|
||||||
|
tags:
|
||||||
|
- Конфигурация
|
||||||
|
/internal/metrics/autodiscovery:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.PrometheusTargets'
|
||||||
|
type: array
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_http_apierrors.Error'
|
||||||
|
summary: Метод получения конфигурации для HTTP-based service discovery механизма
|
||||||
|
Prometheus
|
||||||
|
tags:
|
||||||
|
- Метрики
|
||||||
/module/delete_module:
|
/module/delete_module:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -465,6 +767,27 @@ paths:
|
|||||||
summary: Метод полчения полной информации о состоянии модулей
|
summary: Метод полчения полной информации о состоянии модулей
|
||||||
tags:
|
tags:
|
||||||
- Модули
|
- Модули
|
||||||
|
/module/get_required_modules:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Возвращает список модулей с их зависимостями
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.ModuleRelation'
|
||||||
|
type: array
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод для получения зависимостей модулей
|
||||||
|
tags:
|
||||||
|
- Модули
|
||||||
/routing/get_routes:
|
/routing/get_routes:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@@ -516,4 +839,195 @@ paths:
|
|||||||
summary: Метод получения схемы конфигурации модуля
|
summary: Метод получения схемы конфигурации модуля
|
||||||
tags:
|
tags:
|
||||||
- Схема
|
- Схема
|
||||||
|
/schema/update_by_module_name:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Меняет схему конфигурации модуля на переданную
|
||||||
|
parameters:
|
||||||
|
- description: название модуля и схема конфига
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.UpdateSchemaRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema: {}
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2001` - модуль не найден'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод обновления схемы конфигурации модуля
|
||||||
|
tags:
|
||||||
|
- Схема
|
||||||
|
/variable/all:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.Variable'
|
||||||
|
type: array
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод получения списка всех переменных
|
||||||
|
tags:
|
||||||
|
- Переменные
|
||||||
|
/variable/create:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Создает новую переменную с указанным наименованием и значением
|
||||||
|
parameters:
|
||||||
|
- description: тело запроса
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.CreateVariableRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2007` - переменная с таким именем уже существует<br/>'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод создания новой переменной
|
||||||
|
tags:
|
||||||
|
- Переменные
|
||||||
|
/variable/delete:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Переменная связанная с конфигурациями, не может быть удалена
|
||||||
|
parameters:
|
||||||
|
- description: тело запроса
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.VariableByNameRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2006` - переменная по имени не найдена<br/>`errorCode:
|
||||||
|
2008` - переменная используется в конфигурациях<br/>'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод удаления переменной
|
||||||
|
tags:
|
||||||
|
- Переменные
|
||||||
|
/variable/get_by_name:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- description: тело запроса
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.VariableByNameRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.Variable'
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2006` - переменная по имени не найдена<br/>'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод получения переменной по точному совпадению имени
|
||||||
|
tags:
|
||||||
|
- Переменные
|
||||||
|
/variable/update:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Выполняет обновление переменной по ее названию
|
||||||
|
parameters:
|
||||||
|
- description: тело запроса
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/domain.UpdateVariableRequest'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"400":
|
||||||
|
description: '`errorCode: 2006` - переменная по имени не найдена<br/>'
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод обновления переменной
|
||||||
|
tags:
|
||||||
|
- Переменные
|
||||||
|
/variable/upsert:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: |-
|
||||||
|
Выполняет безусловное добавление/обновление указанных в теле запроса переменных
|
||||||
|
Операция выполняется не в транзакции
|
||||||
|
parameters:
|
||||||
|
- description: тело запроса
|
||||||
|
in: body
|
||||||
|
name: body
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/domain.UpsertVariableRequest'
|
||||||
|
type: array
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
"500":
|
||||||
|
description: Internal Server Error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
|
||||||
|
summary: Метод добавления/обновления переменных
|
||||||
|
tags:
|
||||||
|
- Переменные
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
@@ -12,6 +12,9 @@ const (
|
|||||||
ErrorCodeInvalidConfig = 2003
|
ErrorCodeInvalidConfig = 2003
|
||||||
ErrorCodeConfigVersionConflict = 2004
|
ErrorCodeConfigVersionConflict = 2004
|
||||||
ErrorCodeSchemaNotFound = 2005
|
ErrorCodeSchemaNotFound = 2005
|
||||||
|
ErrorCodeVariableNotFound = 2006
|
||||||
|
ErrorCodeVariableAlreadyExists = 2007
|
||||||
|
ErrorCodeVariableUsedInConfigs = 2008
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigValidationError struct {
|
type ConfigValidationError struct {
|
||||||
|
|||||||
+27
-1
@@ -4,10 +4,15 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigIdRequest struct {
|
type IdRequest struct {
|
||||||
Id string `validate:"required"`
|
Id string `validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PurgeConfigVersionsRequest struct {
|
||||||
|
ModuleName string `validate:"required"`
|
||||||
|
KeepVersions int `validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
type GetByModuleIdRequest struct {
|
type GetByModuleIdRequest struct {
|
||||||
ModuleId string `validate:"required"`
|
ModuleId string `validate:"required"`
|
||||||
}
|
}
|
||||||
@@ -16,6 +21,11 @@ type GetByModuleNameRequest struct {
|
|||||||
ModuleName string `validate:"required"`
|
ModuleName string `validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UpdateSchemaRequest struct {
|
||||||
|
ModuleName string `validate:"required"`
|
||||||
|
Schema json.RawMessage `validate:"required" swaggertype:"object"`
|
||||||
|
}
|
||||||
|
|
||||||
type CreateUpdateConfigRequest struct {
|
type CreateUpdateConfigRequest struct {
|
||||||
Id string
|
Id string
|
||||||
Name string `validate:"required"`
|
Name string `validate:"required"`
|
||||||
@@ -24,3 +34,19 @@ type CreateUpdateConfigRequest struct {
|
|||||||
Data json.RawMessage `swaggertype:"object"`
|
Data json.RawMessage `swaggertype:"object"`
|
||||||
Unsafe bool
|
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
|
||||||
+29
-9
@@ -10,6 +10,12 @@ type DeleteResponse struct {
|
|||||||
Deleted int
|
Deleted int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateUpdateConfigResponse struct {
|
||||||
|
Config
|
||||||
|
|
||||||
|
IsChanged bool
|
||||||
|
}
|
||||||
|
|
||||||
type ModuleInfo struct {
|
type ModuleInfo struct {
|
||||||
Id string
|
Id string
|
||||||
Name string
|
Name string
|
||||||
@@ -22,13 +28,15 @@ type ModuleInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
Id string
|
Id string
|
||||||
ModuleName string
|
ModuleName string
|
||||||
LibVersion string
|
LibVersion string
|
||||||
Version string
|
Version string
|
||||||
Address Address
|
Address Address
|
||||||
Endpoints []EndpointDescriptor
|
IsModuleLeader bool
|
||||||
EstablishedAt time.Time
|
Transport string
|
||||||
|
Endpoints []EndpointDescriptor
|
||||||
|
EstablishedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type Address struct {
|
type Address struct {
|
||||||
@@ -37,8 +45,9 @@ type Address struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type EndpointDescriptor struct {
|
type EndpointDescriptor struct {
|
||||||
Path string
|
HttpMethod string
|
||||||
Inner bool
|
Path string
|
||||||
|
Inner bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -69,3 +78,14 @@ type ConfigSchema struct {
|
|||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModuleRelation struct {
|
||||||
|
Id string
|
||||||
|
Name string
|
||||||
|
RequiredModules []RequiredModuleType
|
||||||
|
}
|
||||||
|
|
||||||
|
type RequiredModuleType struct {
|
||||||
|
Id string
|
||||||
|
Name string
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
+19
-10
@@ -5,15 +5,24 @@ import (
|
|||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// nolint: tagliatelle
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
WsConnectionId string `json:"ws_connection_id"`
|
WsConnectionId string `json:"ws_connection_id"`
|
||||||
ModuleId string `json:"module_id"`
|
ModuleId string `json:"module_id"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
LibVersion string `json:"lib_version"`
|
LibVersion string `json:"lib_version"`
|
||||||
ModuleName string `json:"module_name"`
|
ModuleName string `json:"module_name"`
|
||||||
ConfigServiceNodeId string `json:"config_service_node_id"`
|
Transport string `json:"transport"`
|
||||||
Endpoints xtypes.Json[[]cluster.EndpointDescriptor] `json:"endpoints"`
|
ModuleLeaderMode string `json:"module_leader_mode"`
|
||||||
RequiredModules xtypes.Json[[]cluster.ModuleDependency] `json:"required_modules"`
|
ConfigServiceNodeId string `json:"config_service_node_id"`
|
||||||
CreatedAt xtypes.Time `json:"created_at"`
|
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"`
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// nolint: tagliatelle
|
||||||
package entity
|
package entity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -16,6 +17,14 @@ type Config struct {
|
|||||||
UpdatedAt xtypes.Time `json:"updated_at"`
|
UpdatedAt xtypes.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
type ConfigHistory struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
ConfigId string `json:"config_id"`
|
ConfigId string `json:"config_id"`
|
||||||
|
|||||||
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
package entity
|
package entity
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -10,4 +10,7 @@ var (
|
|||||||
ErrSchemaNotFound = errors.New("config schema not found")
|
ErrSchemaNotFound = errors.New("config schema not found")
|
||||||
ErrConfigNotFoundOrActive = errors.New("config not found or markers as active")
|
ErrConfigNotFoundOrActive = errors.New("config not found or markers as active")
|
||||||
ErrConfigConflictUpdate = errors.New("config conflict update")
|
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")
|
||||||
)
|
)
|
||||||
@@ -32,6 +32,7 @@ func (e Event) Key() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
type EventPayload struct {
|
type EventPayload struct {
|
||||||
ConfigUpdated *PayloadConfigUpdated `json:",omitempty"`
|
ConfigUpdated *PayloadConfigUpdated `json:",omitempty"`
|
||||||
ModuleReady *PayloadModuleReady `json:",omitempty"`
|
ModuleReady *PayloadModuleReady `json:",omitempty"`
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
type Module struct {
|
type Module struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
|||||||
@@ -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"`
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package xtypes
|
|||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Time time.Time
|
type Time time.Time
|
||||||
|
|||||||
@@ -1,101 +1,124 @@
|
|||||||
module isp-config-service
|
module isp-config-service
|
||||||
|
|
||||||
go 1.23
|
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 (
|
require (
|
||||||
github.com/Masterminds/squirrel v1.5.4
|
github.com/Masterminds/squirrel v1.5.4
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pressly/goose/v3 v3.30.1
|
||||||
github.com/pressly/goose/v3 v3.22.1
|
github.com/prometheus/client_golang v1.25.0
|
||||||
github.com/prometheus/client_golang v1.20.5
|
github.com/rqlite/gorqlite v0.0.0-20250609141355-ac86a4a1c9a8
|
||||||
github.com/rqlite/gorqlite v0.0.0-20241013203532-4385768ae85d
|
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099
|
||||||
github.com/rqlite/rqlite-disco-clients v0.0.0-20231230135307-118e35426347
|
github.com/rqlite/rqlite/v10 v10.2.7
|
||||||
github.com/rqlite/rqlite/v8 v8.32.5
|
github.com/stretchr/testify v1.12.1
|
||||||
github.com/stretchr/testify v1.9.0
|
|
||||||
github.com/tidwall/gjson v1.18.0
|
github.com/tidwall/gjson v1.18.0
|
||||||
github.com/txix-open/etp/v4 v4.0.1
|
github.com/txix-open/etp/v4 v4.1.3
|
||||||
github.com/txix-open/isp-kit v1.39.2
|
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
|
github.com/xeipuuv/gojsonschema v1.2.0
|
||||||
golang.org/x/sync v0.8.0
|
golang.org/x/sync v0.25.0
|
||||||
google.golang.org/grpc v1.67.1
|
google.golang.org/grpc v1.85.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/armon/go-metrics v0.5.3 // indirect
|
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/bahlo/generic-list-go v0.2.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/buger/jsonparser v1.1.1 // indirect
|
github.com/buger/jsonparser v1.6.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/coder/websocket v1.8.12 // indirect
|
github.com/coder/websocket v1.8.15 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
github.com/fatih/color v1.19.0 // indirect
|
||||||
github.com/fatih/color v1.18.0 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
github.com/getsentry/sentry-go v0.50.0 // indirect
|
||||||
github.com/getsentry/sentry-go v0.29.1 // indirect
|
github.com/go-faker/faker/v4 v4.12.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.4 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.2 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // 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-hclog v1.6.3 // indirect
|
||||||
github.com/hashicorp/go-immutable-radix v1.3.1 // 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 v1.1.5 // indirect
|
||||||
github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
|
github.com/hashicorp/go-msgpack/v2 v2.1.5 // indirect
|
||||||
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
github.com/hashicorp/go-uuid v1.0.3 // indirect
|
||||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||||
github.com/hashicorp/raft v1.7.1 // indirect
|
github.com/hashicorp/raft v1.7.3 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/compress v1.17.11 // indirect
|
github.com/klauspost/compress v1.20.4 // indirect
|
||||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
|
||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.5.0 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.9.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.15 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||||
github.com/mfridman/interpolate v0.0.2 // 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/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
github.com/pandatix/go-abnf v0.5.5 // indirect
|
||||||
github.com/prometheus/client_model v0.6.1 // indirect
|
github.com/prometheus/client_model v0.6.3 // indirect
|
||||||
github.com/prometheus/common v0.60.1 // indirect
|
github.com/prometheus/common v0.74.0 // indirect
|
||||||
github.com/prometheus/procfs v0.15.1 // indirect
|
github.com/prometheus/procfs v0.23.0 // indirect
|
||||||
github.com/rqlite/go-sqlite3 v1.36.0 // indirect
|
|
||||||
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 // indirect
|
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 // indirect
|
||||||
github.com/rqlite/sql v0.0.0-20241029220113-152a320b02f7 // indirect
|
github.com/rqlite/sql v0.0.0-20260224021119-1b2524a41372 // indirect
|
||||||
github.com/sethvargo/go-retry v0.3.0 // indirect
|
github.com/sethvargo/go-retry v0.5.0 // indirect
|
||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.2.0 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
github.com/txix-open/bellows v1.2.0 // indirect
|
github.com/txix-open/bellows v1.2.0 // indirect
|
||||||
github.com/txix-open/jsonschema v1.2.0 // indirect
|
github.com/txix-open/jsonschema v1.3.0 // indirect
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 // 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/wk8/go-ordered-map/v2 v2.1.8 // indirect
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||||
go.etcd.io/bbolt v1.3.11 // indirect
|
go.etcd.io/bbolt v1.5.0 // indirect
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect
|
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.31.0 // indirect
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect
|
go.opentelemetry.io/otel v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 // indirect
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 // indirect
|
go.opentelemetry.io/otel/log v1.47.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 // indirect
|
go.opentelemetry.io/otel/metric v1.47.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 // 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/multierr v1.11.0 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.28.0 // indirect
|
||||||
golang.org/x/crypto v0.28.0 // indirect
|
go.yaml.in/yaml/v3 v3.0.6 // indirect
|
||||||
golang.org/x/net v0.30.0 // indirect
|
golang.org/x/crypto v0.59.0 // indirect
|
||||||
golang.org/x/sys v0.26.0 // indirect
|
golang.org/x/net v0.63.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/sys v0.50.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 // indirect
|
golang.org/x/text v0.44.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f // indirect
|
||||||
google.golang.org/protobuf v1.35.1 // 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/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace (
|
|
||||||
github.com/armon/go-metrics => github.com/hashicorp/go-metrics v0.5.1
|
|
||||||
golang.org/x/text => golang.org/x/text v0.3.8
|
|
||||||
)
|
|
||||||
@@ -7,6 +7,44 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
|
|||||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
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 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
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 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
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 v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||||
@@ -14,51 +52,49 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
|
|||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
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/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/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
github.com/buger/jsonparser v1.6.1 h1:I0phFv0PlbLHnM7TZAVjZ2MJ2/eWRTDyuO7GLR98IEs=
|
||||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
github.com/buger/jsonparser v1.6.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
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.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 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
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/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/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
|
||||||
github.com/coder/websocket v1.8.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=
|
||||||
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
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.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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
|
||||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
|
||||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
|
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
|
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||||
github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA=
|
github.com/getsentry/sentry-go v0.50.0 h1:gkO59rn/i0RCAXUUTflC5QVbTQGPXbaFabs2olVzc9g=
|
||||||
github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0=
|
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 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
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.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/kit v0.9.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.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
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 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
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 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
||||||
github.com/go-resty/resty/v2 v2.15.3 h1:bqff+hcqAflpiF591hhJzNdkRsFhlB96CYfBwSFvql8=
|
|
||||||
github.com/go-resty/resty/v2 v2.15.3/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
|
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
|
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/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||||
@@ -66,15 +102,17 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
|
|||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
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.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
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.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.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
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/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 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.34.0 h1:vzlTzzi4tHLa/JQdIE5LeXw6SEX5EVVhq/VPqKHnKOk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
|
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-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.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||||
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
||||||
@@ -84,11 +122,13 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ
|
|||||||
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
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 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
|
||||||
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
|
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-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||||
github.com/hashicorp/go-msgpack v1.1.5 h1:9byZdVjKTe5mce63pRVNP1L7UAmdHOTEMGehn6KvJWs=
|
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 v1.1.5/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4=
|
||||||
github.com/hashicorp/go-msgpack/v2 v2.1.2 h1:4Ee8FTp834e+ewB71RDrQ0VKpyFdrKOjvYtnQ/ltVj0=
|
github.com/hashicorp/go-msgpack/v2 v2.1.5 h1:Ue879bPnutj/hXfmUk6s/jtIK90XxgiUIcXRl656T44=
|
||||||
github.com/hashicorp/go-msgpack/v2 v2.1.2/go.mod h1:upybraOAblm4S7rx0+jeNy+CWWhzywQsSRV5033mMu4=
|
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-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
|
||||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
|
||||||
@@ -96,13 +136,10 @@ github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
|
|||||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
|
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/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
|
||||||
github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM=
|
github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM=
|
||||||
github.com/hashicorp/raft v1.7.1 h1:ytxsNx4baHsRZrhUcbt3+79zc4ly8qm7pi0393pSchY=
|
github.com/hashicorp/raft v1.7.3 h1:DxpEqZJysHN0wK+fviai5mFcSYsCkNpFUl1xpAW8Rbo=
|
||||||
github.com/hashicorp/raft v1.7.1/go.mod h1:hUeiEwQQR/Nk2iKDD0dkEhklSsu3jcAcqvPzPoZSAEM=
|
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/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea/go.mod h1:qRd6nFJYYS6Iqnc/8HcUmko2/2Gw8qTFEmxDLii6W5I=
|
||||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
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.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 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
@@ -110,8 +147,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
|
|||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
github.com/klauspost/compress v1.20.4 h1:dD0v/bvxtjCBqQu6sx1TNWkalEY5lNTIe+HY9w8TeNI=
|
||||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
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.1/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/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
@@ -127,22 +164,21 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq
|
|||||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
|
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 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
|
||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
||||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
||||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
github.com/mailru/easyjson v0.9.2 h1:dX8U45hQsZpxd80nLvDGihsQ/OxlvTkVUXH2r/8cb2M=
|
||||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
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.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.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
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.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.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
github.com/mfridman/interpolate v0.2.0 h1:HM9ID8p6CUxoMJX+fECOtGQ2Mu7TW/GIMPyu48nnvUg=
|
||||||
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
|
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 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
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-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
@@ -155,8 +191,10 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
|
|||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
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/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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
github.com/ncruces/go-strftime v1.1.0 h1:vtPmPWMkb539RGV9WpWT9EwJGvrOCKvMNI4obWL47Hk=
|
||||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
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 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
|
||||||
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||||
@@ -166,49 +204,47 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
|||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
github.com/pressly/goose/v3 v3.30.1 h1:KO28meBdbAUIdMbTP7bl9dp1FYZGXcYWb2O7miT09lE=
|
||||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pressly/goose/v3 v3.30.1/go.mod h1:CHGwuG2acDerUaXwz2i5T18VSauXpYDiL4WxzDvcOIM=
|
||||||
github.com/pressly/goose/v3 v3.22.1 h1:2zICEfr1O3yTP9BRZMGPj7qFxQ+ik6yeo+z1LMuioLc=
|
|
||||||
github.com/pressly/goose/v3 v3.22.1/go.mod h1:xtMpbstWyCpyH+0cxLTMCENWBG+0CSxvTsXhW95d5eo=
|
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
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.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
|
||||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
github.com/prometheus/client_golang v1.25.0 h1:cDtW1TcFsMi1RJc8khwCKB4VhzwV04aKqbYtNOXuiK0=
|
||||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
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-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-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
github.com/prometheus/client_model v0.6.3 h1:O0jaTVAYNxTHYInEPFJt5I3+sN8zqBtVMPTB1qyxiEo=
|
||||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
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.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||||
github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc=
|
github.com/prometheus/common v0.74.0 h1:6iYW8MsYvmEnXFD9zLGgF0qmReaRhs3OMONu1c/nrLI=
|
||||||
github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw=
|
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-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
github.com/prometheus/procfs v0.0.2/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/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4=
|
||||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
github.com/rabbitmq/amqp091-go v1.17.0 h1:6KmTqrnJq93cGIE3Q3UnXgsqw6NtLu8MNfFoIbfBAIQ=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
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 h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||||
github.com/rqlite/go-sqlite3 v1.36.0 h1:dNW9Hn4v3HVVlO+q6QmQC5glZYIWFOzOWUjrKOxK3cE=
|
github.com/rqlite/go-sqlite3 v1.48.0 h1:3z/QU1WEFrywWvhjhLvZ+SBkaoIQZtkNcHgpCaxE1eg=
|
||||||
github.com/rqlite/go-sqlite3 v1.36.0/go.mod h1:R9H7CatgYBt3c+fSV/5yo2vLh4ZjCB0aMHdkv69fP4A=
|
github.com/rqlite/go-sqlite3 v1.48.0/go.mod h1:XIq9SQymduohsJwPy++jWepF9QJ5gT/S3SkUivYSVZ0=
|
||||||
github.com/rqlite/gorqlite v0.0.0-20241013203532-4385768ae85d h1:c88ius/WcN19inn14R+X2EQCFjjAu92txgdxNNnGxDI=
|
github.com/rqlite/gorqlite v0.0.0-20250609141355-ac86a4a1c9a8 h1:BoxiqWvhprOB2isgM59s8wkgKwAoyQH66Twfmof41oE=
|
||||||
github.com/rqlite/gorqlite v0.0.0-20241013203532-4385768ae85d/go.mod h1:xF/KoXmrRyahPfo5L7Szb5cAAUl53dMWBh9cMruGEZg=
|
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 h1:NZ62M+kT0JqhyFUMc8I4SMmfmD4NGJxhb2ePJQXjryc=
|
||||||
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48/go.mod h1:CRnsxgy5G8fAf5J+AM0yrsSdxXHKkIYOaq2sm+Q4DYc=
|
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-20231230135307-118e35426347 h1:01eOG4AXjYsrsLRITgBFHaDPXys1NfeY2idx25ZJFF8=
|
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099 h1:5cqkVLdl6sGJSY3kiF2dqaA3bD+8OS5FUdZqO0BxXLU=
|
||||||
github.com/rqlite/rqlite-disco-clients v0.0.0-20231230135307-118e35426347/go.mod h1:pym85nj6JnCI7rM9RxTZ4cubkTQyyg7uLwVydso9B80=
|
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099/go.mod h1:6SVI8KegsW9Fyu2UQ+uvw0JI5CAILRYRyiQ/OFSJPrs=
|
||||||
github.com/rqlite/rqlite/v8 v8.32.5 h1:wEzDX2HrGWMvFkg2fcCmi+rb1wQ1m5yEefUQfOMvMSY=
|
github.com/rqlite/rqlite/v10 v10.2.7 h1:fUsbbgoELw+MrKfQ9EkVrm8tA0rdVUe/bYYdtOOsnx4=
|
||||||
github.com/rqlite/rqlite/v8 v8.32.5/go.mod h1:a1irqNWEZ+pWuWpgekbScCXp85QtNTJLarN3bVPjn9M=
|
github.com/rqlite/rqlite/v10 v10.2.7/go.mod h1:iTG1rLhR0zBBWTHiN33b9o/HXVwaC71xrcdoFaUJecE=
|
||||||
github.com/rqlite/sql v0.0.0-20241029220113-152a320b02f7 h1:Mnz6yd4FWtiD6bbH9WHFFHfrOM2OYTUTmwrsckRc4W8=
|
github.com/rqlite/sql v0.0.0-20260224021119-1b2524a41372 h1:2V0y6mzmPj7vQKad76nTL7sZ/lFLj5VKvNjpa6IRxYE=
|
||||||
github.com/rqlite/sql v0.0.0-20241029220113-152a320b02f7/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg=
|
github.com/rqlite/sql v0.0.0-20260224021119-1b2524a41372/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg=
|
||||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
github.com/sethvargo/go-retry v0.5.0 h1:JYfFKmVJ8ER06GReN1efzc5cm52BrVsFVzmcHiKJwfY=
|
||||||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
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.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
@@ -223,28 +259,32 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
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.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.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
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 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
|
||||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
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.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
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/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||||
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
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/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||||
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
github.com/txix-open/etp/v4 v4.1.3 h1:u9ZyU2yKGgoQ1/DSaElhazWm8xASdqGEdWjoJ2xQlfo=
|
||||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
github.com/txix-open/etp/v4 v4.1.3/go.mod h1:9GK+Aje8BmLFq8Hk4j6Qb976LdU9WECCWAuLK1vAKgM=
|
||||||
github.com/txix-open/grmq v1.6.0 h1:V4QRb0sI2CMfdMaMsFGvGvUIDGad5vr3khNU7A3LlP8=
|
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60 h1:7SZ72lNU69g8eiT5rcRh1ubATZPs/J05NEIN7E47TYM=
|
||||||
github.com/txix-open/grmq v1.6.0/go.mod h1:s+NNNv42+32yLpjvl2tpqtyBbMB9e7kKFee3lfa/dyo=
|
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60/go.mod h1:jzpq0uwcdGq0OSNXZ6vv6UJkCOU/fLPgeoz+KkGDYgo=
|
||||||
github.com/txix-open/isp-kit v1.39.2 h1:2L2LFwi+sNop9NeLDQ4scIy8LuohzXh4EBejHApAeDM=
|
github.com/txix-open/grmq v1.12.0 h1:lSPYvwLfTL0+b0xDQmuuN6RaKS3NCEJNK9ccWpOWa8Y=
|
||||||
github.com/txix-open/isp-kit v1.39.2/go.mod h1:xB6mkoOewZBI1ND8kjU5TR6kvLu3VQI3Rdkh6g6FE4I=
|
github.com/txix-open/grmq v1.12.0/go.mod h1:6m9CCTQao/HAFalu5rFOZGJ5KLEP6WzzIwj80Ml3KGE=
|
||||||
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s=
|
github.com/txix-open/isp-kit v1.76.0 h1:kqhX2DuoTfeW7BIshedG26TRIfOgX0QOInm606ssGVg=
|
||||||
github.com/txix-open/jsonschema v1.2.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
github.com/txix-open/isp-kit v1.76.0/go.mod h1:hR9iAlh3x9gEg5GfALrrkN/2SbGkgZQCmwO2GZWjC1M=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To=
|
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
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 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
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-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||||
@@ -254,55 +294,58 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
|
|||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
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 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
|
||||||
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||||
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
|
go.etcd.io/bbolt v1.5.0 h1:S7GAl7Fxv12yohbwFfIbQCGDWbQbtDGPET4P/bD4lxU=
|
||||||
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
|
go.etcd.io/bbolt v1.5.0/go.mod h1:mkltfYE5aUHQxUct9N9V+Kp7aSjFqjgrhcXIS70Lrdk=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 h1:4BZHA+B1wXEQoGNHxW8mURaLhcdGwvRnmhGbm+odRbc=
|
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0/go.mod h1:3qi2EEwMgB4xnKgPLqsDP3j9qxnHDZeHsnAxfjQqTko=
|
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 h1:UP6IpuHFkUgOQL9FFQFrZ+5LiwhhYRbi7VZSIx6Nj5s=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0 h1:jva1c3z2ZFEQ5sTvnLG2tBALNehO+QvdXKQii6eKRoo=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0/go.mod h1:qxuZLtbq5QDtdeSHsS7bcf6EH6uO6jUAgk764zd3rhM=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.72.0/go.mod h1:3pjFS5EnOVfjvYO6/NMdtJFHFQR+8uiGtrZ965nZP4w=
|
||||||
go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 h1:LxwW/9ctSCv+QkE/cLR7M91ZIkXNMqJtEMi1vCw9U8s=
|
||||||
go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE=
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0/go.mod h1:tOsftB4SslBwwErVEPaenU2RpThXWPIU8DoJHEC4dyw=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 h1:K0XaT3DwHAcV4nKLzcQvwAgSyisUghWoY20I7huthMk=
|
go.opentelemetry.io/otel v1.47.0 h1:j7ALJ/zgkS7Z6aeJW09p8VC9804bC+PpeTfCD4XPnOM=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0/go.mod h1:B5Ki776z/MBnVha1Nzwp5arlzBbE3+1jk+pGmaP5HME=
|
go.opentelemetry.io/otel v1.47.0/go.mod h1:8wS9O2qfXrYrzp6hIF/HOYJJf/wIhFPhR2xLuP+iXQU=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0 h1:lUsI2TYsQw2r1IASwoROaCnjdj2cvC2+Jbxvk6nHnWU=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0 h1:julhjPeUH/q/7hinbSdDdqt5h7Zw9YWmRlWRhI0jd54=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.31.0/go.mod h1:2HpZxxQurfGxJlJDblybejHB6RX6pmExPNe517hREw4=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.47.0/go.mod h1:Ao2mz688LH/tFf0yMAenidq6k2YNSx6SIY2q6jDACck=
|
||||||
go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0 h1:aXZXsZ012wOgVkqaiQv+Z/d8V0xKjmg70F6m4CE94lc=
|
||||||
go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY=
|
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0/go.mod h1:ziu1gUIJhAaxM3EV1e3Ralk5AAyL1UOYz3lJJ4VSI38=
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
|
go.opentelemetry.io/otel/log v1.47.0 h1:cOTS1CcLbSQeZKanGJ+0JpF/+t4PELi3O3bbl2lqCcI=
|
||||||
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
|
go.opentelemetry.io/otel/log v1.47.0/go.mod h1:9byitSQ5pLC6PpqwGXjqdMKya6ZTswHRZh2vvXT33nw=
|
||||||
go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys=
|
go.opentelemetry.io/otel/metric v1.47.0 h1:4PptaldXx3Eat1XjMZ68pPJEs5wrhlemctZE9a3UdWY=
|
||||||
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
|
go.opentelemetry.io/otel/metric v1.47.0/go.mod h1:ADGSXxRrXM6bjbvLo535EstVFlPpPYZm4LBKixjDHwU=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
go.opentelemetry.io/otel/sdk v1.47.0 h1:zWXEr4j2lFefG87TU6Yg8a7ngfohIKFZHKp0Hf5hC6I=
|
||||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
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 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
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 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
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-20180904163835-0709b304e793/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-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
||||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
||||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
|
||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/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-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
|
||||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
|
||||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
|
||||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
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-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-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/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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-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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
@@ -311,34 +354,26 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/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-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
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-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.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
|
||||||
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
|
|
||||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
|
||||||
golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
golang.org/x/tools v0.0.0-20190424220101-1e8e1cfdf96b/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38 h1:2oV8dfuIkM1Ti7DwXc0BJfnwr9csz4TDXI9EmiI+Rbw=
|
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20241021214115-324edc3d5d38/go.mod h1:vuAjtvlwkDKF6L1GQ0SokiRLCGFfeBUXWr/aFFkHACc=
|
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38 h1:zciRKQ4kBpFgpfC5QQCVtnnNAcLIqweL7plyZRQHVpI=
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f h1:7CbYDSDM5xqpq8v2tNm+Q057COf1lvA0gorVk+304tY=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241021214115-324edc3d5d38/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
google.golang.org/genproto/googleapis/api v0.0.0-20261118221215-c8830f628b3f/go.mod h1:CPxXEEQ1S9iJmInAF/8MNc8tKWnya8I8Kni9Zh2hV0M=
|
||||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f h1:aDW6Vb2T1K0xbAgW+ED8iz39WlgjjX/OKiNh6tXv/+g=
|
||||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20261118221215-c8830f628b3f/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc=
|
||||||
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
|
google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw=
|
||||||
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
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/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 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -353,15 +388,11 @@ 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.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 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
|
modernc.org/libc v1.80.2 h1:3+a4fJZvvzg920ZC0mOepnKPGn7cqCaVeDxm/UnrM1A=
|
||||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
|
modernc.org/libc v1.80.2/go.mod h1:pvo25Rs3OJEbDqhUV9jdEGevxeLJrJeDmNid/AcQV1g=
|
||||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||||
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
modernc.org/memory v1.12.1 h1:nFMiWrpStgZczNl6XI9GnIk/rWhYIyHGUaR04pGbp9g=
|
||||||
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
modernc.org/memory v1.12.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
|
||||||
modernc.org/sqlite v1.33.0 h1:WWkA/T2G17okiLGgKAj4/RMIvgyMT19yQ038160IeYk=
|
modernc.org/sqlite v1.62.0 h1:gMaCjSM1qpl+iOjiWhR1LYP3zqrYDI+5GYLGt6veP2g=
|
||||||
modernc.org/sqlite v1.33.0/go.mod h1:9uQ9hF/pCZoYZK73D/ud5Z7cIRIILSZI8NdIemVMTX8=
|
modernc.org/sqlite v1.62.0/go.mod h1:Jzjh1mt4s0HuQ0KvtB1LIuHiGRmU2D5pgj8dUhW7/SE=
|
||||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
|
||||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
|
||||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
|
||||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
|
||||||
+3
-2
@@ -1,12 +1,13 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
"net"
|
||||||
|
|
||||||
"github.com/txix-open/etp/v4"
|
"github.com/txix-open/etp/v4"
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"net"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ModuleName(conn *etp.Conn) string {
|
func ModuleName(conn *etp.Conn) string {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
|
||||||
"github.com/txix-open/isp-kit/shutdown"
|
|
||||||
"isp-config-service/conf"
|
"isp-config-service/conf"
|
||||||
"isp-config-service/routes"
|
"isp-config-service/routes"
|
||||||
"isp-config-service/service/startup"
|
"isp-config-service/service/startup"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/shutdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -24,7 +26,12 @@ var (
|
|||||||
//go:generate swag init --parseDependency
|
//go:generate swag init --parseDependency
|
||||||
//go:generate rm -f docs/swagger.json docs/docs.go
|
//go:generate rm -f docs/swagger.json docs/docs.go
|
||||||
func main() {
|
func main() {
|
||||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors())
|
boot := bootstrap.New(
|
||||||
|
version,
|
||||||
|
conf.Remote{},
|
||||||
|
cluster.Endpoints(routes.EndpointDescriptors()),
|
||||||
|
cluster.GrpcTransport,
|
||||||
|
)
|
||||||
app := boot.App
|
app := boot.App
|
||||||
logger := app.Logger()
|
logger := app.Logger()
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package middlewares
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/txix-open/etp/v4"
|
"github.com/txix-open/etp/v4"
|
||||||
|
|
||||||
"github.com/txix-open/etp/v4/msg"
|
"github.com/txix-open/etp/v4/msg"
|
||||||
@@ -26,7 +28,7 @@ func EtpLogger(logger log.Logger) EtpMiddleware {
|
|||||||
|
|
||||||
//nolint:ireturn
|
//nolint:ireturn
|
||||||
func EtpChain(root etp.Handler, middlewares ...EtpMiddleware) etp.Handler {
|
func EtpChain(root etp.Handler, middlewares ...EtpMiddleware) etp.Handler {
|
||||||
for i := len(middlewares) - 1; i >= 0; i-- {
|
for i := range slices.Backward(middlewares) {
|
||||||
root = middlewares[i](root)
|
root = middlewares[i](root)
|
||||||
}
|
}
|
||||||
return root
|
return root
|
||||||
|
|||||||
@@ -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;
|
||||||
+73
-10
@@ -4,11 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
@@ -21,17 +22,27 @@ func NewBackend(db db.DB) Backend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Backend) Insert(ctx context.Context, backend entity.Backend) error {
|
func (r Backend) Upsert(ctx context.Context, backend entity.Backend) error {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.Insert")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.Upsert")
|
||||||
|
|
||||||
query, args, err := squirrel.Insert(Table("backend")).
|
query, args, err := squirrel.Insert(Table("backend")).
|
||||||
Columns("ws_connection_id", "module_id", "address",
|
Columns("ws_connection_id", "module_id", "address",
|
||||||
"version", "lib_version", "module_name", "config_service_node_id",
|
"version", "lib_version", "module_name", "transport",
|
||||||
"endpoints", "required_modules").
|
"module_leader_mode", "config_service_node_id", "endpoints",
|
||||||
|
"required_modules", "metrics_autodiscovery").
|
||||||
Values(backend.WsConnectionId, backend.ModuleId, backend.Address,
|
Values(backend.WsConnectionId, backend.ModuleId, backend.Address,
|
||||||
backend.Version, backend.LibVersion, backend.ModuleName, backend.ConfigServiceNodeId,
|
backend.Version, backend.LibVersion, backend.ModuleName, backend.Transport,
|
||||||
backend.Endpoints, backend.RequiredModules,
|
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()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "build query")
|
return errors.WithMessage(err, "build query")
|
||||||
@@ -91,6 +102,7 @@ func (r Backend) DeleteByConfigServiceNodeId(ctx context.Context, configServiceN
|
|||||||
func (r Backend) GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error) {
|
func (r Backend) GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByConfigServiceNodeId")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByConfigServiceNodeId")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("backend")).
|
From(Table("backend")).
|
||||||
Where(squirrel.Eq{
|
Where(squirrel.Eq{
|
||||||
@@ -114,8 +126,17 @@ func (r Backend) All(ctx context.Context) ([]entity.Backend, error) {
|
|||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.All")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.All")
|
||||||
|
|
||||||
result := make([]entity.Backend, 0)
|
result := make([]entity.Backend, 0)
|
||||||
query := fmt.Sprintf("SELECT * FROM %s order by created_at desc", Table("backend"))
|
|
||||||
err := r.db.Select(ctx, &result, query)
|
// 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 {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||||
}
|
}
|
||||||
@@ -125,6 +146,7 @@ func (r Backend) All(ctx context.Context) ([]entity.Backend, error) {
|
|||||||
func (r Backend) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Backend, error) {
|
func (r Backend) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Backend, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByModuleId")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByModuleId")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("backend")).
|
From(Table("backend")).
|
||||||
Where(squirrel.Eq{
|
Where(squirrel.Eq{
|
||||||
@@ -143,3 +165,44 @@ func (r Backend) GetByModuleId(ctx context.Context, moduleId string) ([]entity.B
|
|||||||
|
|
||||||
return result, nil
|
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
|
||||||
|
}
|
||||||
+59
-1
@@ -2,9 +2,11 @@ package repository
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
@@ -44,6 +46,7 @@ func (r Config) Insert(ctx context.Context, cfg entity.Config) error {
|
|||||||
func (r Config) GetActive(ctx context.Context, moduleId string) (*entity.Config, error) {
|
func (r Config) GetActive(ctx context.Context, moduleId string) (*entity.Config, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetActive")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetActive")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("config")).
|
From(Table("config")).
|
||||||
Where(squirrel.Eq{
|
Where(squirrel.Eq{
|
||||||
@@ -62,6 +65,7 @@ func (r Config) GetActive(ctx context.Context, moduleId string) (*entity.Config,
|
|||||||
func (r Config) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error) {
|
func (r Config) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetByModuleId")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetByModuleId")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("config")).
|
From(Table("config")).
|
||||||
Where(squirrel.Eq{
|
Where(squirrel.Eq{
|
||||||
@@ -84,6 +88,7 @@ func (r Config) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Co
|
|||||||
func (r Config) GetById(ctx context.Context, id string) (*entity.Config, error) {
|
func (r Config) GetById(ctx context.Context, id string) (*entity.Config, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetById")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetById")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("config")).
|
From(Table("config")).
|
||||||
Where(squirrel.Eq{
|
Where(squirrel.Eq{
|
||||||
@@ -170,3 +175,56 @@ func (r Config) SetActive(ctx context.Context, configId string, active xtypes.Bo
|
|||||||
|
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
@@ -24,12 +24,23 @@ func NewConfigHistory(db db.DB) ConfigHistory {
|
|||||||
func (r ConfigHistory) GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error) {
|
func (r ConfigHistory) GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.GetByConfigId")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.GetByConfigId")
|
||||||
|
|
||||||
query := fmt.Sprintf(`select * from %s where config_id = ? order by version desc`, Table("config_history"))
|
// 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)
|
result := make([]entity.ConfigHistory, 0)
|
||||||
err := r.db.Select(ctx, &result, query, configId)
|
err = r.db.Select(ctx, &result, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +55,8 @@ func (r ConfigHistory) Delete(ctx context.Context, id string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r ConfigHistory) Insert(ctx context.Context, history entity.ConfigHistory) error {
|
func (r ConfigHistory) InsertV2(ctx context.Context, history entity.ConfigHistory) error {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Insert")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.InsertV2")
|
||||||
|
|
||||||
query, args, err := squirrel.Insert(Table("config_history")).
|
query, args, err := squirrel.Insert(Table("config_history")).
|
||||||
Columns("id", "config_id", "data", "version", "admin_id").
|
Columns("id", "config_id", "data", "version", "admin_id").
|
||||||
@@ -63,6 +74,25 @@ func (r ConfigHistory) Insert(ctx context.Context, history entity.ConfigHistory)
|
|||||||
return nil
|
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) {
|
func (r ConfigHistory) DeleteOld(ctx context.Context, configId string, keepVersions int) (int, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.DeleteOld")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.DeleteOld")
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,9 @@ package repository
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
@@ -46,18 +45,28 @@ func (r ConfigSchema) Upsert(ctx context.Context, schema entity.ConfigSchema) er
|
|||||||
func (r ConfigSchema) All(ctx context.Context) ([]entity.ConfigSchema, error) {
|
func (r ConfigSchema) All(ctx context.Context) ([]entity.ConfigSchema, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.All")
|
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)
|
result := make([]entity.ConfigSchema, 0)
|
||||||
query := fmt.Sprintf("select * from %s order by created_at", Table("config_schema"))
|
err = r.db.Select(ctx, &result, query, args...)
|
||||||
err := r.db.Select(ctx, &result, query)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r ConfigSchema) GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error) {
|
func (r ConfigSchema) GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.GetByModuleId")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigSchema.GetByModuleId")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("config_schema")).
|
From(Table("config_schema")).
|
||||||
Where(squirrel.Eq{"module_id": moduleId}).
|
Where(squirrel.Eq{"module_id": moduleId}).
|
||||||
@@ -69,8 +78,26 @@ func (r ConfigSchema) GetByModuleId(ctx context.Context, moduleId string) (*enti
|
|||||||
return selectRow[entity.ConfigSchema](ctx, r.db, query, args...)
|
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
|
//nolint:nilnil
|
||||||
func selectRow[T any](ctx context.Context, db db.DB, query string, args ...interface{}) (*T, error) {
|
func selectRow[T any](ctx context.Context, db db.DB, query string, args ...any) (*T, error) {
|
||||||
var result T
|
var result T
|
||||||
err := db.SelectRow(ctx, &result, query, args...)
|
err := db.SelectRow(ctx, &result, query, args...)
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
|
|||||||
+17
-3
@@ -4,7 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
@@ -35,12 +36,25 @@ func (r Event) Insert(ctx context.Context, event entity.Event) error {
|
|||||||
func (r Event) Get(ctx context.Context, lastEventId int, limit int) ([]entity.Event, error) {
|
func (r Event) Get(ctx context.Context, lastEventId int, limit int) ([]entity.Event, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Event.Get")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Event.Get")
|
||||||
|
|
||||||
query := fmt.Sprintf("select * from %s where id > ? order by id limit ?", Table("event"))
|
// 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)
|
result := make([]entity.Event, 0)
|
||||||
err := r.db.Select(ctx, &result, query, lastEventId, limit)
|
err = r.db.Select(ctx, &result, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+25
-5
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
@@ -66,6 +66,7 @@ func (r Module) SetDisconnectedAtNow(
|
|||||||
func (r Module) GetByNames(ctx context.Context, names []string) ([]entity.Module, error) {
|
func (r Module) GetByNames(ctx context.Context, names []string) ([]entity.Module, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.GetByNames")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.GetByNames")
|
||||||
|
|
||||||
|
// nolint:unqueryvet
|
||||||
query, args, err := squirrel.Select("*").
|
query, args, err := squirrel.Select("*").
|
||||||
From(Table("module")).
|
From(Table("module")).
|
||||||
Where(squirrel.Eq{
|
Where(squirrel.Eq{
|
||||||
@@ -88,19 +89,38 @@ func (r Module) GetByNames(ctx context.Context, names []string) ([]entity.Module
|
|||||||
func (r Module) GetById(ctx context.Context, id string) (*entity.Module, error) {
|
func (r Module) GetById(ctx context.Context, id string) (*entity.Module, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.GetById")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.GetById")
|
||||||
|
|
||||||
query := fmt.Sprintf("select * from %s where id = ?", Table("module"))
|
// nolint:unqueryvet
|
||||||
return selectRow[entity.Module](ctx, r.db, query, id)
|
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) {
|
func (r Module) All(ctx context.Context) ([]entity.Module, error) {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Module.All")
|
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)
|
result := make([]entity.Module, 0)
|
||||||
query := fmt.Sprintf("select * from %s order by name", Table("module"))
|
err = r.db.Select(ctx, &result, query, args...)
|
||||||
err := r.db.Select(ctx, &result, query)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessagef(err, "select: %s", query)
|
return nil, errors.WithMessagef(err, "select: %s", query)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
+163
-58
@@ -1,17 +1,20 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/etp/v4"
|
|
||||||
"isp-config-service/conf"
|
|
||||||
"net/http"
|
"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/cluster"
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
"github.com/txix-open/isp-kit/grpc/endpoint"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/controller"
|
|
||||||
"isp-config-service/controller/api"
|
|
||||||
mws "isp-config-service/middlewares"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Controllers struct {
|
type Controllers struct {
|
||||||
@@ -20,15 +23,27 @@ type Controllers struct {
|
|||||||
ConfigApi api.Config
|
ConfigApi api.Config
|
||||||
ConfigHistoryApi api.ConfigHistory
|
ConfigHistoryApi api.ConfigHistory
|
||||||
ConfigSchemaApi api.ConfigSchema
|
ConfigSchemaApi api.ConfigSchema
|
||||||
|
VariableApi api.Variable
|
||||||
}
|
}
|
||||||
|
|
||||||
func EndpointDescriptors() []cluster.EndpointDescriptor {
|
func EndpointDescriptors() []cluster.EndpointDescriptor {
|
||||||
return endpointDescriptors(Controllers{})
|
c := Controllers{}
|
||||||
|
return concatEndpoints(
|
||||||
|
modulesDescriptors(c),
|
||||||
|
configsDescriptors(c),
|
||||||
|
variablesDescriptors(c),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GrpcHandler(wrapper endpoint.Wrapper, c Controllers) *grpc.Mux {
|
func GrpcHandler(wrapper endpoint.Wrapper, c Controllers) *grpc.Mux {
|
||||||
muxer := grpc.NewMux()
|
muxer := grpc.NewMux()
|
||||||
for _, descriptor := range endpointDescriptors(c) {
|
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))
|
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
|
||||||
}
|
}
|
||||||
return muxer
|
return muxer
|
||||||
@@ -52,64 +67,154 @@ func BindEtp(etpSrv *etp.Server, c Controllers, logger log.Logger) {
|
|||||||
etpSrv.On(cluster.ModuleReady, onModuleReady)
|
etpSrv.On(cluster.ModuleReady, onModuleReady)
|
||||||
}
|
}
|
||||||
|
|
||||||
func HttpHandler(etpSrv *etp.Server, conf conf.Local, rqliteProxy http.Handler) http.Handler {
|
func HttpHandler(etpSrv *etp.Server, conf conf.Local, rqliteProxy, rqliteBackupProxy http.Handler) http.Handler {
|
||||||
httpMux := http.NewServeMux()
|
httpMux := http.NewServeMux()
|
||||||
if conf.MaintenanceMode {
|
if conf.MaintenanceMode {
|
||||||
httpMux.Handle("/", rqliteProxy)
|
httpMux.Handle("/", rqliteProxy)
|
||||||
} else {
|
} else {
|
||||||
httpMux.Handle("/isp-etp/", etpSrv)
|
httpMux.Handle("/isp-etp/", etpSrv)
|
||||||
|
httpMux.Handle("/backup", rqliteBackupProxy)
|
||||||
}
|
}
|
||||||
return httpMux
|
return httpMux
|
||||||
}
|
}
|
||||||
|
|
||||||
func endpointDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
func modulesDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
||||||
return []cluster.EndpointDescriptor{{
|
return []cluster.EndpointDescriptor{
|
||||||
Path: "config/module/get_modules_info",
|
{
|
||||||
Inner: true,
|
Path: "config/module/get_modules_info",
|
||||||
Handler: c.ModuleApi.Status,
|
Inner: true,
|
||||||
}, {
|
Extra: cluster.RequireAdminPermission("module_view"),
|
||||||
Path: "config/module/delete_module",
|
Handler: c.ModuleApi.Status,
|
||||||
Inner: true,
|
}, {
|
||||||
Handler: c.ModuleApi.DeleteModule,
|
Path: "config/module/delete_module",
|
||||||
}, {
|
Inner: true,
|
||||||
Path: "config/routing/get_routes",
|
Extra: cluster.RequireAdminPermission("module_delete"),
|
||||||
Inner: true,
|
Handler: c.ModuleApi.DeleteModule,
|
||||||
Handler: c.ModuleApi.Connections,
|
}, {
|
||||||
}, {
|
Path: "config/routing/get_routes",
|
||||||
Path: "config/config/get_active_config_by_module_name",
|
Inner: true,
|
||||||
Inner: true,
|
Extra: cluster.RequireAdminPermission("module_view"),
|
||||||
Handler: c.ConfigApi.GetActiveConfigByModuleName,
|
Handler: c.ModuleApi.Connections,
|
||||||
}, {
|
}, {
|
||||||
Path: "config/config/get_configs_by_module_id",
|
Path: "config/module/get_required_modules",
|
||||||
Inner: true,
|
Inner: true,
|
||||||
Handler: c.ConfigApi.GetConfigsByModuleId,
|
Extra: cluster.RequireAdminPermission("module_view"),
|
||||||
}, {
|
Handler: c.ModuleApi.RequiredModules,
|
||||||
Path: "config/config/create_update_config",
|
},
|
||||||
Inner: true,
|
}
|
||||||
Handler: c.ConfigApi.CreateUpdateConfig,
|
}
|
||||||
}, {
|
|
||||||
Path: "config/config/get_config_by_id",
|
func configsDescriptors(c Controllers) []cluster.EndpointDescriptor {
|
||||||
Inner: true,
|
return []cluster.EndpointDescriptor{
|
||||||
Handler: c.ConfigApi.GetConfigById,
|
{
|
||||||
}, {
|
Path: "config/config/get_active_config_by_module_name",
|
||||||
Path: "config/config/mark_config_as_active",
|
Inner: true,
|
||||||
Inner: true,
|
Extra: cluster.RequireAdminPermission("module_view"),
|
||||||
Handler: c.ConfigApi.MarkConfigAsActive,
|
Handler: c.ConfigApi.GetActiveConfigByModuleName,
|
||||||
}, {
|
}, {
|
||||||
Path: "config/config/delete_config",
|
Path: "config/config/get_configs_by_module_id",
|
||||||
Inner: true,
|
Inner: true,
|
||||||
Handler: c.ConfigApi.DeleteConfigs,
|
Extra: cluster.RequireAdminPermission("module_view"),
|
||||||
}, {
|
Handler: c.ConfigApi.GetConfigsByModuleId,
|
||||||
Path: "config/config/get_all_version",
|
}, {
|
||||||
Inner: true,
|
Path: "config/config/create_update_config",
|
||||||
Handler: c.ConfigHistoryApi.GetAllVersion,
|
Inner: true,
|
||||||
}, {
|
Extra: cluster.RequireAdminPermission("module_configuration_edit"),
|
||||||
Path: "config/config/delete_version",
|
Handler: c.ConfigApi.CreateUpdateConfig,
|
||||||
Inner: true,
|
}, {
|
||||||
Handler: c.ConfigHistoryApi.DeleteConfigVersion,
|
Path: "config/config/get_config_by_id",
|
||||||
}, {
|
Inner: true,
|
||||||
Path: "config/schema/get_by_module_id",
|
Extra: cluster.RequireAdminPermission("module_view"),
|
||||||
Inner: true,
|
Handler: c.ConfigApi.GetConfigById,
|
||||||
Handler: c.ConfigSchemaApi.SchemaByModuleId,
|
}, {
|
||||||
}}
|
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
|
||||||
}
|
}
|
||||||
+122
-14
@@ -5,7 +5,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"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"
|
"github.com/xeipuuv/gojsonschema"
|
||||||
"isp-config-service/domain"
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
@@ -20,6 +23,7 @@ type ConfigRepo interface {
|
|||||||
Insert(ctx context.Context, cfg entity.Config) error
|
Insert(ctx context.Context, cfg entity.Config) error
|
||||||
UpdateByVersion(ctx context.Context, cfg entity.Config) (bool, error)
|
UpdateByVersion(ctx context.Context, cfg entity.Config) (bool, error)
|
||||||
SetActive(ctx context.Context, configId string, active xtypes.Bool) error
|
SetActive(ctx context.Context, configId string, active xtypes.Bool) error
|
||||||
|
UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type EventRepo interface {
|
type EventRepo interface {
|
||||||
@@ -30,12 +34,19 @@ type ConfigHistoryService interface {
|
|||||||
OnUpdateConfig(ctx context.Context, oldConfig entity.Config) error
|
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 {
|
type Config struct {
|
||||||
configRepo ConfigRepo
|
configRepo ConfigRepo
|
||||||
moduleRepo ModuleRepo
|
moduleRepo ModuleRepo
|
||||||
schemaRepo SchemaRepo
|
schemaRepo SchemaRepo
|
||||||
eventRepo EventRepo
|
eventRepo EventRepo
|
||||||
configHistoryService ConfigHistoryService
|
configHistoryService ConfigHistoryService
|
||||||
|
variableService VariableService
|
||||||
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(
|
func NewConfig(
|
||||||
@@ -44,6 +55,8 @@ func NewConfig(
|
|||||||
schemaRepo SchemaRepo,
|
schemaRepo SchemaRepo,
|
||||||
eventRepo EventRepo,
|
eventRepo EventRepo,
|
||||||
configHistoryService ConfigHistoryService,
|
configHistoryService ConfigHistoryService,
|
||||||
|
variableService VariableService,
|
||||||
|
logger log.Logger,
|
||||||
) Config {
|
) Config {
|
||||||
return Config{
|
return Config{
|
||||||
configRepo: configRepo,
|
configRepo: configRepo,
|
||||||
@@ -51,6 +64,8 @@ func NewConfig(
|
|||||||
schemaRepo: schemaRepo,
|
schemaRepo: schemaRepo,
|
||||||
eventRepo: eventRepo,
|
eventRepo: eventRepo,
|
||||||
configHistoryService: configHistoryService,
|
configHistoryService: configHistoryService,
|
||||||
|
variableService: variableService,
|
||||||
|
logger: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +87,7 @@ func (c Config) GetActiveConfigByModuleName(ctx context.Context, moduleName stri
|
|||||||
return nil, entity.ErrConfigNotFound
|
return nil, entity.ErrConfigNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
result := configToDto(*config, nil)
|
return new(configToDto(*config, nil)), nil
|
||||||
return &result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error) {
|
func (c Config) GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error) {
|
||||||
@@ -106,7 +120,7 @@ func (c Config) CreateUpdateConfig(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
adminId int,
|
adminId int,
|
||||||
req domain.CreateUpdateConfigRequest,
|
req domain.CreateUpdateConfigRequest,
|
||||||
) (*domain.Config, error) {
|
) (*domain.CreateUpdateConfigResponse, error) {
|
||||||
if !req.Unsafe {
|
if !req.Unsafe {
|
||||||
err := c.validateConfigUpdate(ctx, req.ModuleId, req.Data)
|
err := c.validateConfigUpdate(ctx, req.ModuleId, req.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -115,7 +129,14 @@ func (c Config) CreateUpdateConfig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if req.Id == "" {
|
if req.Id == "" {
|
||||||
return c.insertNewConfig(ctx, adminId, req)
|
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)
|
oldConfig, err := c.configRepo.GetById(ctx, req.Id)
|
||||||
@@ -126,6 +147,15 @@ func (c Config) CreateUpdateConfig(
|
|||||||
return nil, entity.ErrConfigNotFound
|
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{
|
config := entity.Config{
|
||||||
Id: req.Id,
|
Id: req.Id,
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
@@ -145,6 +175,10 @@ func (c Config) CreateUpdateConfig(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "change config history")
|
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 {
|
if oldConfig.Active {
|
||||||
err = c.emitChangeActiveConfigEvent(ctx, oldConfig.ModuleId)
|
err = c.emitChangeActiveConfigEvent(ctx, oldConfig.ModuleId)
|
||||||
@@ -161,8 +195,8 @@ func (c Config) CreateUpdateConfig(
|
|||||||
Version: req.Version + 1,
|
Version: req.Version + 1,
|
||||||
Active: oldConfig.Active,
|
Active: oldConfig.Active,
|
||||||
}
|
}
|
||||||
result := configToDto(newConfig, nil)
|
return &domain.CreateUpdateConfigResponse{
|
||||||
return &result, nil
|
Config: configToDto(newConfig, nil), IsChanged: true}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) GetConfigById(ctx context.Context, configId string) (*domain.Config, error) {
|
func (c Config) GetConfigById(ctx context.Context, configId string) (*domain.Config, error) {
|
||||||
@@ -174,8 +208,7 @@ func (c Config) GetConfigById(ctx context.Context, configId string) (*domain.Con
|
|||||||
return nil, entity.ErrConfigNotFound
|
return nil, entity.ErrConfigNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
result := configToDto(*config, nil)
|
return new(configToDto(*config, nil)), nil
|
||||||
return &result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) MarkConfigAsActive(ctx context.Context, configId string) error {
|
func (c Config) MarkConfigAsActive(ctx context.Context, configId string) error {
|
||||||
@@ -222,7 +255,37 @@ func (c Config) DeleteConfig(ctx context.Context, configId string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) insertNewConfig(ctx context.Context, adminId int, req domain.CreateUpdateConfigRequest) (*domain.Config, error) {
|
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{
|
config := entity.Config{
|
||||||
Id: uuid.NewString(),
|
Id: uuid.NewString(),
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
@@ -232,12 +295,37 @@ func (c Config) insertNewConfig(ctx context.Context, adminId int, req domain.Cre
|
|||||||
Active: false,
|
Active: false,
|
||||||
AdminId: adminId,
|
AdminId: adminId,
|
||||||
}
|
}
|
||||||
err := c.configRepo.Insert(ctx, config)
|
// 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 {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "insert new config")
|
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)
|
result := configToDto(config, nil)
|
||||||
return &result, 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 {
|
func (c Config) validateConfigUpdate(ctx context.Context, moduleId string, configData []byte) error {
|
||||||
@@ -257,7 +345,7 @@ func (c Config) validateConfigUpdate(ctx context.Context, moduleId string, confi
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.NewConfigValidationError(details)
|
return errors.WithMessage(domain.NewConfigValidationError(details), "config validation")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Config) emitChangeActiveConfigEvent(ctx context.Context, moduleId string) error {
|
func (c Config) emitChangeActiveConfigEvent(ctx context.Context, moduleId string) error {
|
||||||
@@ -306,3 +394,23 @@ func validateConfig(config []byte, schema []byte) (map[string]string, error) {
|
|||||||
}
|
}
|
||||||
return details, nil
|
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
|
||||||
|
}
|
||||||
@@ -3,13 +3,15 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/google/uuid"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
|
||||||
"isp-config-service/domain"
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigHistoryRepo interface {
|
type ConfigHistoryRepo interface {
|
||||||
@@ -20,18 +22,24 @@ type ConfigHistoryRepo interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConfigHistory struct {
|
type ConfigHistory struct {
|
||||||
|
configRepo ConfigRepo
|
||||||
|
moduleRepo ModuleRepo
|
||||||
repo ConfigHistoryRepo
|
repo ConfigHistoryRepo
|
||||||
keepVersions int
|
keepVersions int
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigHistory(
|
func NewConfigHistory(
|
||||||
|
configRepo ConfigRepo,
|
||||||
|
moduleRepo ModuleRepo,
|
||||||
repo ConfigHistoryRepo,
|
repo ConfigHistoryRepo,
|
||||||
keepVersions int,
|
keepVersions int,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
) ConfigHistory {
|
) ConfigHistory {
|
||||||
return ConfigHistory{
|
return ConfigHistory{
|
||||||
repo: repo,
|
repo: repo,
|
||||||
|
moduleRepo: moduleRepo,
|
||||||
|
configRepo: configRepo,
|
||||||
keepVersions: keepVersions,
|
keepVersions: keepVersions,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
@@ -42,8 +50,23 @@ func (s ConfigHistory) GetAllVersions(ctx context.Context, configId string) ([]d
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "get config versions")
|
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),
|
||||||
|
})
|
||||||
|
|
||||||
result := make([]domain.ConfigVersion, 0, len(versions))
|
|
||||||
for _, version := range versions {
|
for _, version := range versions {
|
||||||
result = append(result, domain.ConfigVersion{
|
result = append(result, domain.ConfigVersion{
|
||||||
Id: version.Id,
|
Id: version.Id,
|
||||||
@@ -65,13 +88,42 @@ func (s ConfigHistory) Delete(ctx context.Context, id string) error {
|
|||||||
return nil
|
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 {
|
func (s ConfigHistory) OnUpdateConfig(ctx context.Context, oldConfig entity.Config) error {
|
||||||
history := entity.ConfigHistory{
|
history := entity.ConfigHistory{
|
||||||
Id: uuid.NewString(),
|
Id: uuid.NewString(),
|
||||||
ConfigId: oldConfig.Id,
|
ConfigId: oldConfig.Id,
|
||||||
Data: oldConfig.Data,
|
Data: oldConfig.Data,
|
||||||
Version: oldConfig.Version,
|
Version: oldConfig.Version,
|
||||||
AdminId: oldConfig.AdminId,
|
AdminId: oldConfig.AdminId,
|
||||||
|
CreatedAt: oldConfig.UpdatedAt,
|
||||||
}
|
}
|
||||||
err := s.repo.Insert(ctx, history)
|
err := s.repo.Insert(ctx, history)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -82,6 +134,7 @@ func (s ConfigHistory) OnUpdateConfig(ctx context.Context, oldConfig entity.Conf
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:gosec
|
||||||
go func() {
|
go func() {
|
||||||
deletedCount, err := s.repo.DeleteOld(context.Background(), oldConfig.Id, s.keepVersions)
|
deletedCount, err := s.repo.DeleteOld(context.Background(), oldConfig.Id, s.keepVersions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -4,18 +4,21 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-config-service/domain"
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigSchema struct {
|
type ConfigSchema struct {
|
||||||
schemaRepo SchemaRepo
|
schemaRepo SchemaRepo
|
||||||
|
moduleRepo ModuleRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfigSchema(schemaRepo SchemaRepo) ConfigSchema {
|
func NewConfigSchema(schemaRepo SchemaRepo, moduleRepo ModuleRepo) ConfigSchema {
|
||||||
return ConfigSchema{
|
return ConfigSchema{
|
||||||
schemaRepo: schemaRepo,
|
schemaRepo: schemaRepo,
|
||||||
|
moduleRepo: moduleRepo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,3 +42,20 @@ func (s ConfigSchema) SchemaByModuleId(ctx context.Context, moduleId string) (*d
|
|||||||
|
|
||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s ConfigSchema) UpdateSchemaByModuleName(ctx context.Context, request domain.UpdateSchemaRequest) error {
|
||||||
|
modules, err := s.moduleRepo.GetByNames(ctx, []string{request.ModuleName})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get modules by name")
|
||||||
|
}
|
||||||
|
if len(modules) == 0 {
|
||||||
|
return entity.ErrModuleNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.schemaRepo.UpdateByModuleId(ctx, modules[0].Id, request.Schema)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update schema by module id")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
+121
-12
@@ -6,12 +6,13 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"isp-config-service/domain"
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/helpers"
|
"isp-config-service/helpers"
|
||||||
|
"isp-config-service/service/module/leader"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModuleRepo interface {
|
type ModuleRepo interface {
|
||||||
@@ -27,6 +28,7 @@ type BackendsRepo interface {
|
|||||||
type SchemaRepo interface {
|
type SchemaRepo interface {
|
||||||
All(ctx context.Context) ([]entity.ConfigSchema, error)
|
All(ctx context.Context) ([]entity.ConfigSchema, error)
|
||||||
GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error)
|
GetByModuleId(ctx context.Context, moduleId string) (*entity.ConfigSchema, error)
|
||||||
|
UpdateByModuleId(ctx context.Context, moduleId string, data []byte) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Module struct {
|
type Module struct {
|
||||||
@@ -57,26 +59,37 @@ func (s Module) Status(ctx context.Context) ([]domain.ModuleInfo, error) {
|
|||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
var err error
|
var err error
|
||||||
modules, err = s.moduleRepo.All(ctx)
|
modules, err = s.moduleRepo.All(ctx)
|
||||||
return errors.WithMessage(err, "get all modules")
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get all modules")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
var err error
|
var err error
|
||||||
backends, err = s.backendsRepo.All(ctx)
|
backends, err = s.backendsRepo.All(ctx)
|
||||||
return errors.WithMessage(err, "get all backends")
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get all backends")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
group.Go(func() error {
|
group.Go(func() error {
|
||||||
var err error
|
var err error
|
||||||
schemas, err = s.schemaRepo.All(ctx)
|
schemas, err = s.schemaRepo.All(ctx)
|
||||||
return errors.WithMessage(err, "get all schemas")
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get all schemas")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
err := group.Wait()
|
err := group.Wait()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "wait")
|
return nil, errors.WithMessage(err, "wait")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elections := leader.DeriveByModule(backends)
|
||||||
|
|
||||||
connections := make(map[string][]domain.Connection, len(modules))
|
connections := make(map[string][]domain.Connection, len(modules))
|
||||||
for _, backend := range backends {
|
for _, backend := range backends {
|
||||||
conn, err := s.backendToDto(backend)
|
conn, err := s.backendToDto(backend, isModuleLeader(elections, backend))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "backend to dto")
|
return nil, errors.WithMessage(err, "backend to dto")
|
||||||
}
|
}
|
||||||
@@ -106,6 +119,52 @@ func (s Module) Status(ctx context.Context) ([]domain.ModuleInfo, error) {
|
|||||||
return moduleInfos, nil
|
return moduleInfos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s Module) RequiredModules(ctx context.Context) ([]domain.ModuleRelation, error) {
|
||||||
|
var (
|
||||||
|
modules []entity.Module
|
||||||
|
backends []entity.Backend
|
||||||
|
)
|
||||||
|
group, groupCtx := errgroup.WithContext(ctx)
|
||||||
|
group.Go(func() error {
|
||||||
|
var err error
|
||||||
|
modules, err = s.moduleRepo.All(groupCtx)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get all modules")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
group.Go(func() error {
|
||||||
|
var err error
|
||||||
|
backends, err = s.backendsRepo.All(groupCtx)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get all backends")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
err := group.Wait()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "wait")
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleIdsByName := make(map[string]string, len(modules))
|
||||||
|
for _, module := range modules {
|
||||||
|
moduleIdsByName[module.Name] = module.Id
|
||||||
|
}
|
||||||
|
|
||||||
|
requiredNamesByModuleId := requiredModuleNamesByModuleId(backends)
|
||||||
|
|
||||||
|
result := make([]domain.ModuleRelation, 0, len(modules))
|
||||||
|
for _, module := range modules {
|
||||||
|
result = append(result, domain.ModuleRelation{
|
||||||
|
Id: module.Id,
|
||||||
|
Name: module.Name,
|
||||||
|
RequiredModules: toRequiredModuleTypes(requiredNamesByModuleId[module.Id], moduleIdsByName),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s Module) Delete(ctx context.Context, id string) error {
|
func (s Module) Delete(ctx context.Context, id string) error {
|
||||||
err := s.moduleRepo.Delete(ctx, id)
|
err := s.moduleRepo.Delete(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -120,9 +179,11 @@ func (s Module) Connections(ctx context.Context) ([]domain.Connection, error) {
|
|||||||
return nil, errors.WithMessage(err, "get all backends")
|
return nil, errors.WithMessage(err, "get all backends")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elections := leader.DeriveByModule(backends)
|
||||||
|
|
||||||
connections := make([]domain.Connection, 0, len(backends))
|
connections := make([]domain.Connection, 0, len(backends))
|
||||||
for _, backend := range backends {
|
for _, backend := range backends {
|
||||||
conn, err := s.backendToDto(backend)
|
conn, err := s.backendToDto(backend, isModuleLeader(elections, backend))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "backend to dto")
|
return nil, errors.WithMessage(err, "backend to dto")
|
||||||
}
|
}
|
||||||
@@ -132,7 +193,7 @@ func (s Module) Connections(ctx context.Context) ([]domain.Connection, error) {
|
|||||||
return connections, nil
|
return connections, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Module) backendToDto(backend entity.Backend) (domain.Connection, error) {
|
func (s Module) backendToDto(backend entity.Backend, moduleLeader bool) (domain.Connection, error) {
|
||||||
addr, err := helpers.SplitAddress(backend)
|
addr, err := helpers.SplitAddress(backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return domain.Connection{}, errors.WithMessage(err, "split address")
|
return domain.Connection{}, errors.WithMessage(err, "split address")
|
||||||
@@ -141,12 +202,17 @@ func (s Module) backendToDto(backend entity.Backend) (domain.Connection, error)
|
|||||||
endpointsDescriptors := make([]domain.EndpointDescriptor, 0)
|
endpointsDescriptors := make([]domain.EndpointDescriptor, 0)
|
||||||
for _, desc := range backend.Endpoints.Value {
|
for _, desc := range backend.Endpoints.Value {
|
||||||
endpointsDescriptors = append(endpointsDescriptors, domain.EndpointDescriptor{
|
endpointsDescriptors = append(endpointsDescriptors, domain.EndpointDescriptor{
|
||||||
Path: desc.Path,
|
HttpMethod: desc.HttpMethod,
|
||||||
Inner: desc.Inner,
|
Path: desc.Path,
|
||||||
|
Inner: desc.Inner,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
slices.SortFunc(endpointsDescriptors, func(a, b domain.EndpointDescriptor) int {
|
slices.SortFunc(endpointsDescriptors, func(a, b domain.EndpointDescriptor) int {
|
||||||
return cmp.Compare(a.Path, b.Path)
|
c := cmp.Compare(a.Path, b.Path)
|
||||||
|
if c != 0 {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return cmp.Compare(a.HttpMethod, b.HttpMethod)
|
||||||
})
|
})
|
||||||
|
|
||||||
conn := domain.Connection{
|
conn := domain.Connection{
|
||||||
@@ -154,13 +220,56 @@ func (s Module) backendToDto(backend entity.Backend) (domain.Connection, error)
|
|||||||
ModuleName: backend.ModuleName,
|
ModuleName: backend.ModuleName,
|
||||||
LibVersion: backend.LibVersion,
|
LibVersion: backend.LibVersion,
|
||||||
Version: backend.Version,
|
Version: backend.Version,
|
||||||
|
Transport: backend.Transport,
|
||||||
Address: domain.Address{
|
Address: domain.Address{
|
||||||
Ip: addr.IP,
|
Ip: addr.IP,
|
||||||
Port: addr.Port,
|
Port: addr.Port,
|
||||||
},
|
},
|
||||||
Endpoints: endpointsDescriptors,
|
IsModuleLeader: moduleLeader,
|
||||||
EstablishedAt: time.Time(backend.CreatedAt),
|
Endpoints: endpointsDescriptors,
|
||||||
|
EstablishedAt: time.Time(backend.CreatedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isModuleLeader(elections map[string]leader.Result, backend entity.Backend) bool {
|
||||||
|
election := elections[backend.ModuleId]
|
||||||
|
|
||||||
|
return election.Found && election.Leader.WsConnectionId == backend.WsConnectionId
|
||||||
|
}
|
||||||
|
|
||||||
|
func requiredModuleNamesByModuleId(backends []entity.Backend) map[string]map[string]struct{} {
|
||||||
|
result := make(map[string]map[string]struct{})
|
||||||
|
for _, backend := range backends {
|
||||||
|
_, ok := result[backend.ModuleId]
|
||||||
|
if !ok {
|
||||||
|
result[backend.ModuleId] = make(map[string]struct{})
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, dep := range backend.RequiredModules.Value {
|
||||||
|
result[backend.ModuleId][dep.Name] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func toRequiredModuleTypes(requiredNames map[string]struct{}, moduleIdsByName map[string]string) []domain.RequiredModuleType {
|
||||||
|
requiredModules := make([]domain.RequiredModuleType, 0, len(requiredNames))
|
||||||
|
|
||||||
|
for requiredName := range requiredNames {
|
||||||
|
requiredModules = append(
|
||||||
|
requiredModules,
|
||||||
|
domain.RequiredModuleType{
|
||||||
|
Id: moduleIdsByName[requiredName],
|
||||||
|
Name: requiredName,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
slices.SortFunc(requiredModules, func(a, b domain.RequiredModuleType) int {
|
||||||
|
return cmp.Compare(a.Name, b.Name)
|
||||||
|
})
|
||||||
|
|
||||||
|
return requiredModules
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package event
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"isp-config-service/service/rqlite"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BackupCleaner struct {
|
||||||
|
leaderChecker LeaderChecker
|
||||||
|
cfg rqlite.Backup
|
||||||
|
logger log.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBackupCleaner(
|
||||||
|
leaderChecker LeaderChecker,
|
||||||
|
cfg rqlite.Backup,
|
||||||
|
logger log.Logger,
|
||||||
|
) BackupCleaner {
|
||||||
|
return BackupCleaner{
|
||||||
|
leaderChecker: leaderChecker,
|
||||||
|
cfg: cfg,
|
||||||
|
logger: logger,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c BackupCleaner) Do(ctx context.Context) {
|
||||||
|
ctx = log.ToContext(ctx, log.String("worker", "backupCleaner"))
|
||||||
|
if !c.leaderChecker.IsLeader() {
|
||||||
|
c.logger.Debug(ctx, "is not a leader, skip work")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
files, err := os.ReadDir(c.cfg.Sub.Dir)
|
||||||
|
if err != nil {
|
||||||
|
c.logger.Error(ctx, fmt.Sprintf("failed to read files from %s: %s", c.cfg.Sub.Dir, err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
backups := make([]os.DirEntry, 0)
|
||||||
|
for _, file := range files {
|
||||||
|
if !strings.Contains(file.Name(), "backup") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
backups = append(backups, file)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(backups) <= c.cfg.Amount {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteAmount := len(backups) - c.cfg.Amount
|
||||||
|
deleted := 0
|
||||||
|
|
||||||
|
for i := range deleteAmount {
|
||||||
|
err = os.Remove(c.cfg.Sub.Dir + "/" + backups[i].Name())
|
||||||
|
if err != nil {
|
||||||
|
c.logger.Error(ctx, fmt.Sprintf("failed to remove %s: %s", backups[i].Name(), err.Error()))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
deleted++
|
||||||
|
}
|
||||||
|
|
||||||
|
c.logger.Debug(ctx, fmt.Sprintf("delete %d old backups", deleted))
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ func NewCompactor() Compactor {
|
|||||||
func (c Compactor) Compact(events []entity.Event) []entity.Event {
|
func (c Compactor) Compact(events []entity.Event) []entity.Event {
|
||||||
uniqueEvents := make([]entity.Event, 0, len(events))
|
uniqueEvents := make([]entity.Event, 0, len(events))
|
||||||
uniqueEventKeys := make(map[string]bool, len(events))
|
uniqueEventKeys := make(map[string]bool, len(events))
|
||||||
for i := len(events) - 1; i >= 0; i-- {
|
for _, event := range slices.Backward(events) {
|
||||||
event := events[i]
|
|
||||||
key := event.Key()
|
key := event.Key()
|
||||||
if uniqueEventKeys[key] {
|
if uniqueEventKeys[key] {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package event_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"isp-config-service/entity"
|
||||||
|
"isp-config-service/service/event"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
const testModuleId = "test-module-id"
|
||||||
|
|
||||||
|
func TestCompactCollapsesModuleLifecycle(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
ready := entity.NewEvent(entity.EventPayload{
|
||||||
|
ModuleReady: &entity.PayloadModuleReady{ModuleId: testModuleId},
|
||||||
|
})
|
||||||
|
ready.Id = 1
|
||||||
|
|
||||||
|
disconnected := entity.NewEvent(entity.EventPayload{
|
||||||
|
ModuleDisconnected: &entity.PayloadModuleDisconnected{ModuleId: testModuleId},
|
||||||
|
})
|
||||||
|
disconnected.Id = 2
|
||||||
|
|
||||||
|
configUpdated := entity.NewEvent(entity.EventPayload{
|
||||||
|
ConfigUpdated: &entity.PayloadConfigUpdated{ModuleId: testModuleId},
|
||||||
|
})
|
||||||
|
configUpdated.Id = 3
|
||||||
|
|
||||||
|
require.Equal("module_lifecycle_"+testModuleId, ready.Key())
|
||||||
|
require.Equal("module_lifecycle_"+testModuleId, disconnected.Key())
|
||||||
|
require.Equal("config_updated_"+testModuleId, configUpdated.Key())
|
||||||
|
|
||||||
|
compacted := event.NewCompactor().Compact([]entity.Event{ready, disconnected, configUpdated})
|
||||||
|
|
||||||
|
require.Equal([]entity.Event{disconnected, configUpdated}, compacted,
|
||||||
|
"the newest lifecycle event wins, a config update is a key of its own")
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package event
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
)
|
)
|
||||||
@@ -33,7 +33,9 @@ func (h Handler) Handle(ctx context.Context, events []entity.Event) {
|
|||||||
routingChanged := false
|
routingChanged := false
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
payload := event.Payload.Value
|
payload := event.Payload.Value
|
||||||
routingChanged = routingChanged || payload.ModuleReady != nil || payload.ModuleDisconnected != nil
|
routingChanged = routingChanged ||
|
||||||
|
payload.ModuleReady != nil ||
|
||||||
|
payload.ModuleDisconnected != nil
|
||||||
err := h.handleEvent(ctx, event)
|
err := h.handleEvent(ctx, event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Error(ctx, errors.WithMessagef(err, "handle event: %s", event.Key()))
|
h.logger.Error(ctx, errors.WithMessagef(err, "handle event: %s", event.Key()))
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package event_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"isp-config-service/entity"
|
||||||
|
"isp-config-service/service/event"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type subscriptionSpy struct {
|
||||||
|
backendsChanged []string
|
||||||
|
routingCalls int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *subscriptionSpy) NotifyConfigChanged(ctx context.Context, moduleId string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *subscriptionSpy) NotifyBackendsChanged(ctx context.Context, moduleId string) error {
|
||||||
|
s.backendsChanged = append(s.backendsChanged, moduleId)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *subscriptionSpy) NotifyRoutingChanged(ctx context.Context) error {
|
||||||
|
s.routingCalls++
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type loggerSpy struct {
|
||||||
|
errors []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Error(ctx context.Context, message any, fields ...log.Field) {
|
||||||
|
l.errors = append(l.errors, fmt.Sprint(message))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Warn(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Info(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Debug(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func moduleReadyEvent(id int) entity.Event {
|
||||||
|
event := entity.NewEvent(entity.EventPayload{
|
||||||
|
ModuleReady: &entity.PayloadModuleReady{ModuleId: testModuleId},
|
||||||
|
})
|
||||||
|
event.Id = id
|
||||||
|
return event
|
||||||
|
}
|
||||||
|
|
||||||
|
func moduleDisconnectedEvent(id int) entity.Event {
|
||||||
|
event := entity.NewEvent(entity.EventPayload{
|
||||||
|
ModuleDisconnected: &entity.PayloadModuleDisconnected{ModuleId: testModuleId},
|
||||||
|
})
|
||||||
|
event.Id = id
|
||||||
|
return event
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHandleLifecycleBatchFansRoutingOnce(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
subscription := &subscriptionSpy{}
|
||||||
|
logger := &loggerSpy{}
|
||||||
|
handler := event.NewHandler(subscription, logger)
|
||||||
|
|
||||||
|
batch := event.NewCompactor().Compact([]entity.Event{
|
||||||
|
moduleReadyEvent(1),
|
||||||
|
moduleDisconnectedEvent(2),
|
||||||
|
})
|
||||||
|
handler.Handle(t.Context(), batch)
|
||||||
|
|
||||||
|
require.Equal([]string{testModuleId}, subscription.backendsChanged,
|
||||||
|
"ready and disconnected collapse into the newest lifecycle event")
|
||||||
|
require.Equal(1, subscription.routingCalls, "the routing map is broadcast once per batch")
|
||||||
|
require.Empty(logger.errors)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestHandleUnknownEventDoesNotAbortBatch(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
subscription := &subscriptionSpy{}
|
||||||
|
logger := &loggerSpy{}
|
||||||
|
handler := event.NewHandler(subscription, logger)
|
||||||
|
|
||||||
|
unknown := entity.NewEvent(entity.EventPayload{})
|
||||||
|
|
||||||
|
handler.Handle(t.Context(), []entity.Event{unknown, moduleReadyEvent(1)})
|
||||||
|
|
||||||
|
require.Len(logger.errors, 1)
|
||||||
|
require.Contains(logger.errors[0], "unknown event")
|
||||||
|
require.Equal([]string{testModuleId}, subscription.backendsChanged,
|
||||||
|
"an unknown payload kind must not stop the batch")
|
||||||
|
require.Equal(1, subscription.routingCalls)
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package event
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package metrics
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"isp-config-service/domain"
|
||||||
|
"isp-config-service/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type metricsAutodiscoveryRepo interface {
|
||||||
|
AllMetricsAutodiscovery(ctx context.Context) ([]entity.MetricsAdWrapper, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type service struct {
|
||||||
|
repo metricsAutodiscoveryRepo
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(repo metricsAutodiscoveryRepo) service {
|
||||||
|
return service{repo: repo}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s service) Autodiscovery(ctx context.Context) (domain.AutodiscoveryResponse, error) {
|
||||||
|
metricsAdList, err := s.repo.AllMetricsAutodiscovery(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "all metrics autodiscovery")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(domain.AutodiscoveryResponse, len(metricsAdList))
|
||||||
|
for i, v := range metricsAdList {
|
||||||
|
v := v.MetricsAutodiscovery
|
||||||
|
result[i] = domain.PrometheusTargets{
|
||||||
|
Targets: []string{v.Value.Address},
|
||||||
|
Labels: v.Value.Labels,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -3,16 +3,19 @@ package backend
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
"net/http"
|
||||||
"github.com/txix-open/etp/v4"
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
|
|
||||||
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Repo interface {
|
type Repo interface {
|
||||||
Insert(ctx context.Context, backend entity.Backend) error
|
Upsert(ctx context.Context, backend entity.Backend) error
|
||||||
DeleteByWsConnectionIds(ctx context.Context, wsConnIds []string) error
|
DeleteByWsConnectionIds(ctx context.Context, wsConnIds []string) error
|
||||||
GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error)
|
GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error)
|
||||||
DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error)
|
DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error)
|
||||||
@@ -52,19 +55,39 @@ func (s Backend) Connect(
|
|||||||
moduleId string,
|
moduleId string,
|
||||||
declaration cluster.BackendDeclaration,
|
declaration cluster.BackendDeclaration,
|
||||||
) (*entity.Backend, error) {
|
) (*entity.Backend, error) {
|
||||||
backend := entity.Backend{
|
var metricsAd *xtypes.Json[cluster.MetricsAutodiscovery]
|
||||||
WsConnectionId: connId,
|
if declaration.MetricsAutodiscovery != nil {
|
||||||
ModuleId: moduleId,
|
metricsAd = &xtypes.Json[cluster.MetricsAutodiscovery]{Value: *declaration.MetricsAutodiscovery}
|
||||||
Address: fmt.Sprintf("%s:%s", declaration.Address.IP, declaration.Address.Port),
|
|
||||||
Version: declaration.Version,
|
|
||||||
LibVersion: declaration.LibVersion,
|
|
||||||
ModuleName: declaration.ModuleName,
|
|
||||||
ConfigServiceNodeId: s.nodeId,
|
|
||||||
Endpoints: xtypes.Json[[]cluster.EndpointDescriptor]{Value: declaration.Endpoints},
|
|
||||||
RequiredModules: xtypes.Json[[]cluster.ModuleDependency]{Value: declaration.RequiredModules},
|
|
||||||
CreatedAt: xtypes.Time{},
|
|
||||||
}
|
}
|
||||||
err := s.backendRepo.Insert(ctx, backend)
|
|
||||||
|
if declaration.Transport == "" {
|
||||||
|
declaration.Transport = cluster.GrpcTransport
|
||||||
|
}
|
||||||
|
if declaration.Transport == cluster.GrpcTransport {
|
||||||
|
for i := range declaration.Endpoints {
|
||||||
|
if declaration.Endpoints[i].HttpMethod == "" {
|
||||||
|
declaration.Endpoints[i].HttpMethod = http.MethodPost
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
backend := entity.Backend{
|
||||||
|
WsConnectionId: connId,
|
||||||
|
ModuleId: moduleId,
|
||||||
|
Address: fmt.Sprintf("%s:%s", declaration.Address.IP, declaration.Address.Port),
|
||||||
|
Version: declaration.Version,
|
||||||
|
LibVersion: declaration.LibVersion,
|
||||||
|
ModuleName: declaration.ModuleName,
|
||||||
|
Transport: declaration.Transport,
|
||||||
|
ModuleLeaderMode: s.normalizeModuleLeaderMode(ctx, declaration.ModuleName, declaration.ModuleLeaderMode),
|
||||||
|
ConfigServiceNodeId: s.nodeId,
|
||||||
|
Endpoints: xtypes.Json[[]cluster.EndpointDescriptor]{Value: declaration.Endpoints},
|
||||||
|
RequiredModules: xtypes.Json[[]cluster.ModuleDependency]{Value: declaration.RequiredModules},
|
||||||
|
CreatedAt: xtypes.Time{},
|
||||||
|
MetricsAutodiscovery: metricsAd,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := s.backendRepo.Upsert(ctx, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "upsert backend in store")
|
return nil, errors.WithMessage(err, "upsert backend in store")
|
||||||
}
|
}
|
||||||
@@ -88,7 +111,7 @@ func (s Backend) Disconnect(ctx context.Context, backend entity.Backend) error {
|
|||||||
return errors.WithMessage(err, "delete backend in store")
|
return errors.WithMessage(err, "delete backend in store")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.insertDisconnectEvent(ctx, backend.ModuleId)
|
err = s.insertDisconnectEvent(ctx, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "insert disconnect event")
|
return errors.WithMessage(err, "insert disconnect event")
|
||||||
}
|
}
|
||||||
@@ -103,7 +126,7 @@ func (s Backend) ClearPhantomBackends(ctx context.Context) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toDelete := make([]string, 0)
|
toDelete := make([]string, 0)
|
||||||
modulesToDisconnect := make(map[string]bool)
|
phantoms := make(map[string]entity.Backend, len(backends))
|
||||||
for _, backend := range backends {
|
for _, backend := range backends {
|
||||||
_, ok := s.rooms.Get(backend.WsConnectionId)
|
_, ok := s.rooms.Get(backend.WsConnectionId)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -111,7 +134,7 @@ func (s Backend) ClearPhantomBackends(ctx context.Context) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toDelete = append(toDelete, backend.WsConnectionId)
|
toDelete = append(toDelete, backend.WsConnectionId)
|
||||||
modulesToDisconnect[backend.ModuleId] = true
|
phantoms[backend.ModuleId] = backend
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(toDelete) == 0 {
|
if len(toDelete) == 0 {
|
||||||
@@ -123,8 +146,8 @@ func (s Backend) ClearPhantomBackends(ctx context.Context) (int, error) {
|
|||||||
return 0, errors.WithMessage(err, "delete backends by ws connection ids")
|
return 0, errors.WithMessage(err, "delete backends by ws connection ids")
|
||||||
}
|
}
|
||||||
|
|
||||||
for moduleId := range modulesToDisconnect {
|
for _, phantom := range phantoms {
|
||||||
err := s.insertDisconnectEvent(ctx, moduleId)
|
err = s.insertDisconnectEvent(ctx, phantom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.WithMessage(err, "insert disconnect event")
|
return 0, errors.WithMessage(err, "insert disconnect event")
|
||||||
}
|
}
|
||||||
@@ -142,15 +165,36 @@ func (s Backend) DeleteOwnBackends(ctx context.Context) {
|
|||||||
s.logger.Info(ctx, fmt.Sprintf("delete %d own backends", deleted))
|
s.logger.Info(ctx, fmt.Sprintf("delete %d own backends", deleted))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Backend) insertDisconnectEvent(ctx context.Context, moduleId string) error {
|
func (s Backend) insertDisconnectEvent(ctx context.Context, backend entity.Backend) error {
|
||||||
event := entity.NewEvent(entity.EventPayload{
|
event := entity.NewEvent(entity.EventPayload{
|
||||||
ModuleDisconnected: &entity.PayloadModuleDisconnected{
|
ModuleDisconnected: &entity.PayloadModuleDisconnected{
|
||||||
ModuleId: moduleId,
|
ModuleId: backend.ModuleId,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
err := s.eventRepo.Insert(ctx, event)
|
err := s.eventRepo.Insert(ctx, event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "insert event in store")
|
return errors.WithMessage(err, "insert event in store")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s Backend) normalizeModuleLeaderMode(
|
||||||
|
ctx context.Context,
|
||||||
|
moduleName string,
|
||||||
|
moduleLeaderMode string,
|
||||||
|
) string {
|
||||||
|
switch moduleLeaderMode {
|
||||||
|
case cluster.ModuleLeaderModeNone, cluster.ModuleLeaderModeRequestElection:
|
||||||
|
return moduleLeaderMode
|
||||||
|
}
|
||||||
|
|
||||||
|
s.logger.Warn(
|
||||||
|
ctx,
|
||||||
|
"unsupported module leader mode, stored as none",
|
||||||
|
log.String("moduleName", moduleName),
|
||||||
|
log.String("moduleLeaderMode", moduleLeaderMode),
|
||||||
|
)
|
||||||
|
|
||||||
|
return cluster.ModuleLeaderModeNone
|
||||||
|
}
|
||||||
@@ -0,0 +1,284 @@
|
|||||||
|
package backend_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"isp-config-service/entity"
|
||||||
|
"isp-config-service/service/module/backend"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/etp/v4"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
testModuleName = "test-module"
|
||||||
|
testModuleId = "test-module-id"
|
||||||
|
testConnId = "test-conn-id"
|
||||||
|
testNodeId = "test-node-id"
|
||||||
|
|
||||||
|
leaderConnId = "conn-1"
|
||||||
|
followerConnId = "conn-2"
|
||||||
|
leaderAddress = "10.0.0.1:9000"
|
||||||
|
followerAddress = "10.0.0.2:9000"
|
||||||
|
)
|
||||||
|
|
||||||
|
type storedLog struct {
|
||||||
|
message any
|
||||||
|
fields map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
type loggerSpy struct {
|
||||||
|
warns []storedLog
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Warn(ctx context.Context, message any, fields ...log.Field) {
|
||||||
|
entry := storedLog{
|
||||||
|
message: message,
|
||||||
|
fields: make(map[string]string, len(fields)),
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
entry.fields[field.Key] = field.String
|
||||||
|
}
|
||||||
|
l.warns = append(l.warns, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Error(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Info(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Debug(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
type backendRepoSpy struct {
|
||||||
|
upserted []entity.Backend
|
||||||
|
deleted []string
|
||||||
|
calls []string
|
||||||
|
rows map[string]entity.Backend
|
||||||
|
}
|
||||||
|
|
||||||
|
func newBackendRepoSpy(backends ...entity.Backend) *backendRepoSpy {
|
||||||
|
rows := make(map[string]entity.Backend, len(backends))
|
||||||
|
for _, backend := range backends {
|
||||||
|
rows[backend.WsConnectionId] = backend
|
||||||
|
}
|
||||||
|
|
||||||
|
return &backendRepoSpy{rows: rows}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *backendRepoSpy) Upsert(ctx context.Context, backend entity.Backend) error {
|
||||||
|
r.calls = append(r.calls, "upsert")
|
||||||
|
r.upserted = append(r.upserted, backend)
|
||||||
|
if r.rows == nil {
|
||||||
|
r.rows = make(map[string]entity.Backend, 1)
|
||||||
|
}
|
||||||
|
r.rows[backend.WsConnectionId] = backend
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *backendRepoSpy) DeleteByWsConnectionIds(ctx context.Context, wsConnIds []string) error {
|
||||||
|
r.calls = append(r.calls, "delete")
|
||||||
|
r.deleted = append(r.deleted, wsConnIds...)
|
||||||
|
for _, wsConnId := range wsConnIds {
|
||||||
|
delete(r.rows, wsConnId)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *backendRepoSpy) GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error) {
|
||||||
|
r.calls = append(r.calls, "own_node")
|
||||||
|
|
||||||
|
ownNode := make([]entity.Backend, 0, len(r.rows))
|
||||||
|
for _, backend := range r.rows {
|
||||||
|
ownNode = append(ownNode, backend)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ownNode, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *backendRepoSpy) DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error) {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type eventRepoSpy struct {
|
||||||
|
inserted []entity.Event
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *eventRepoSpy) Insert(ctx context.Context, event entity.Event) error {
|
||||||
|
r.inserted = append(r.inserted, event)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConnectNormalizesModuleLeaderMode(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
expectedMode string
|
||||||
|
announcedMode string
|
||||||
|
name string
|
||||||
|
expectedWarn bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "request election is stored as is",
|
||||||
|
announcedMode: cluster.ModuleLeaderModeRequestElection,
|
||||||
|
expectedMode: cluster.ModuleLeaderModeRequestElection,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "empty mode is stored as empty",
|
||||||
|
announcedMode: cluster.ModuleLeaderModeNone,
|
||||||
|
expectedMode: cluster.ModuleLeaderModeNone,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "im leader is reserved",
|
||||||
|
announcedMode: cluster.ModuleLeaderModeImLeader,
|
||||||
|
expectedMode: cluster.ModuleLeaderModeNone,
|
||||||
|
expectedWarn: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "im follower is reserved",
|
||||||
|
announcedMode: cluster.ModuleLeaderModeImFollower,
|
||||||
|
expectedMode: cluster.ModuleLeaderModeNone,
|
||||||
|
expectedWarn: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "garbage is unknown",
|
||||||
|
announcedMode: "SOMETHING_ELSE",
|
||||||
|
expectedMode: cluster.ModuleLeaderModeNone,
|
||||||
|
expectedWarn: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
logger := &loggerSpy{}
|
||||||
|
backendRepo := &backendRepoSpy{}
|
||||||
|
service := backend.NewBackend(backendRepo, &eventRepoSpy{}, testNodeId, nil, logger)
|
||||||
|
|
||||||
|
declaration := cluster.BackendDeclaration{
|
||||||
|
ModuleName: testModuleName,
|
||||||
|
Version: "1.0.0",
|
||||||
|
LibVersion: "1.0.0",
|
||||||
|
Address: cluster.AddressConfiguration{IP: "10.0.0.1", Port: "9000"},
|
||||||
|
ModuleLeaderMode: tt.announcedMode,
|
||||||
|
}
|
||||||
|
connected, err := service.Connect(t.Context(), testConnId, testModuleId, declaration)
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Len(backendRepo.upserted, 1)
|
||||||
|
require.Equal(tt.expectedMode, backendRepo.upserted[0].ModuleLeaderMode)
|
||||||
|
require.Equal(tt.expectedMode, connected.ModuleLeaderMode)
|
||||||
|
|
||||||
|
if !tt.expectedWarn {
|
||||||
|
require.Empty(logger.warns)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
require.Len(logger.warns, 1)
|
||||||
|
require.Equal(testModuleName, logger.warns[0].fields["moduleName"])
|
||||||
|
require.Equal(tt.announcedMode, logger.warns[0].fields["moduleLeaderMode"])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestConnectInsertsOnlyLifecycleEvent(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
events := &eventRepoSpy{}
|
||||||
|
backendRepo := newBackendRepoSpy(electedInstance(leaderConnId, leaderAddress))
|
||||||
|
service := backend.NewBackend(backendRepo, events, testNodeId, nil, &loggerSpy{})
|
||||||
|
|
||||||
|
declaration := cluster.BackendDeclaration{
|
||||||
|
ModuleName: testModuleName,
|
||||||
|
Address: cluster.AddressConfiguration{IP: "10.0.0.2", Port: "9000"},
|
||||||
|
ModuleLeaderMode: cluster.ModuleLeaderModeRequestElection,
|
||||||
|
}
|
||||||
|
_, err := service.Connect(t.Context(), followerConnId, testModuleId, declaration)
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Equal([]string{"upsert"}, backendRepo.calls,
|
||||||
|
"the connect path elects nobody: the leader is derived where the address list is emitted")
|
||||||
|
require.Equal([]string{"module_lifecycle_" + testModuleId}, eventKeys(events),
|
||||||
|
"one lifecycle event per connect, no dedicated leader event")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDisconnectInsertsOnlyLifecycleEvent(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
events := &eventRepoSpy{}
|
||||||
|
backendRepo := newBackendRepoSpy(
|
||||||
|
electedInstance(leaderConnId, leaderAddress),
|
||||||
|
electedInstance(followerConnId, followerAddress),
|
||||||
|
)
|
||||||
|
service := backend.NewBackend(backendRepo, events, testNodeId, nil, &loggerSpy{})
|
||||||
|
|
||||||
|
err := service.Disconnect(t.Context(), entity.Backend{
|
||||||
|
WsConnectionId: leaderConnId,
|
||||||
|
ModuleId: testModuleId,
|
||||||
|
ModuleName: testModuleName,
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Equal([]string{"delete"}, backendRepo.calls,
|
||||||
|
"the disconnect path elects nobody")
|
||||||
|
require.Equal([]string{"module_lifecycle_" + testModuleId}, eventKeys(events),
|
||||||
|
"one lifecycle event per disconnect, no dedicated leader event")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestClearPhantomBackendsInsertsOneLifecycleEventPerModule(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
events := &eventRepoSpy{}
|
||||||
|
backendRepo := newBackendRepoSpy(
|
||||||
|
electedInstance(leaderConnId, leaderAddress),
|
||||||
|
electedInstance(followerConnId, followerAddress),
|
||||||
|
)
|
||||||
|
service := backend.NewBackend(backendRepo, events, testNodeId, &etp.Rooms{}, &loggerSpy{})
|
||||||
|
|
||||||
|
deleted, err := service.ClearPhantomBackends(t.Context())
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Equal(2, deleted)
|
||||||
|
require.Equal([]string{"own_node", "delete"}, backendRepo.calls,
|
||||||
|
"the cleanup deletes and announces, it elects nobody")
|
||||||
|
require.Equal([]string{"module_lifecycle_" + testModuleId}, eventKeys(events),
|
||||||
|
"the instances of one module are announced once")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeleteOwnBackendsInsertsNoEvents(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
events := &eventRepoSpy{}
|
||||||
|
service := backend.NewBackend(newBackendRepoSpy(), events, testNodeId, nil, &loggerSpy{})
|
||||||
|
|
||||||
|
service.DeleteOwnBackends(t.Context())
|
||||||
|
|
||||||
|
require.Empty(events.inserted, "graceful shutdown inserts no events at all")
|
||||||
|
}
|
||||||
|
|
||||||
|
func electedInstance(connId string, address string) entity.Backend {
|
||||||
|
return entity.Backend{
|
||||||
|
WsConnectionId: connId,
|
||||||
|
ModuleId: testModuleId,
|
||||||
|
ModuleName: testModuleName,
|
||||||
|
Address: address,
|
||||||
|
ModuleLeaderMode: cluster.ModuleLeaderModeRequestElection,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func eventKeys(events *eventRepoSpy) []string {
|
||||||
|
keys := make([]string, 0, len(events.inserted))
|
||||||
|
for _, event := range events.inserted {
|
||||||
|
keys = append(keys, event.Key())
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys
|
||||||
|
}
|
||||||
@@ -3,7 +3,8 @@ package backend
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ package module
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/txix-open/etp/v4"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/txix-open/etp/v4"
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/helpers"
|
"isp-config-service/helpers"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package leader
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"isp-config-service/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Result struct {
|
||||||
|
HasElection bool
|
||||||
|
Found bool
|
||||||
|
Leader entity.Backend
|
||||||
|
}
|
||||||
|
|
||||||
|
func Derive(backends []entity.Backend) Result {
|
||||||
|
result := Result{
|
||||||
|
HasElection: hasElection(backends),
|
||||||
|
}
|
||||||
|
if !result.HasElection {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
candidates := slices.Clone(backends)
|
||||||
|
slices.SortFunc(candidates, compare)
|
||||||
|
|
||||||
|
result.Found = true
|
||||||
|
result.Leader = candidates[0]
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeriveByModule(backends []entity.Backend) map[string]Result {
|
||||||
|
byModule := make(map[string][]entity.Backend, len(backends))
|
||||||
|
for _, backend := range backends {
|
||||||
|
byModule[backend.ModuleId] = append(byModule[backend.ModuleId], backend)
|
||||||
|
}
|
||||||
|
|
||||||
|
elections := make(map[string]Result, len(byModule))
|
||||||
|
for moduleId, moduleBackends := range byModule {
|
||||||
|
elections[moduleId] = Derive(moduleBackends)
|
||||||
|
}
|
||||||
|
|
||||||
|
return elections
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasElection(backends []entity.Backend) bool {
|
||||||
|
for _, backend := range backends {
|
||||||
|
if backend.ModuleLeaderMode == cluster.ModuleLeaderModeRequestElection {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func compare(a, b entity.Backend) int {
|
||||||
|
byCreatedAt := time.Time(a.CreatedAt).Compare(time.Time(b.CreatedAt))
|
||||||
|
if byCreatedAt != 0 {
|
||||||
|
return byCreatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Compare(a.WsConnectionId, b.WsConnectionId)
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
package leader_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"isp-config-service/entity"
|
||||||
|
"isp-config-service/entity/xtypes"
|
||||||
|
"isp-config-service/service/module/leader"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
electionMode = cluster.ModuleLeaderModeRequestElection
|
||||||
|
noElectionMode = cluster.ModuleLeaderModeNone
|
||||||
|
garbageMode = "SOMETHING_ELSE"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDerive(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
elected := leader.Derive(instances(
|
||||||
|
instance("conn-c", 100, noElectionMode),
|
||||||
|
instance("conn-a", 200, electionMode),
|
||||||
|
instance("conn-b", 100, noElectionMode),
|
||||||
|
))
|
||||||
|
|
||||||
|
require.True(elected.HasElection)
|
||||||
|
require.True(elected.Found)
|
||||||
|
require.Equal("conn-b", elected.Leader.WsConnectionId, "leader is the earliest instance, tie broken by ws_connection_id")
|
||||||
|
|
||||||
|
first := leader.Derive(instances(
|
||||||
|
instance("conn-c", 100, noElectionMode),
|
||||||
|
instance("conn-a", 200, electionMode),
|
||||||
|
instance("conn-b", 100, noElectionMode),
|
||||||
|
))
|
||||||
|
second := leader.Derive(instances(
|
||||||
|
instance("conn-a", 200, electionMode),
|
||||||
|
instance("conn-b", 100, noElectionMode),
|
||||||
|
instance("conn-c", 100, noElectionMode),
|
||||||
|
))
|
||||||
|
|
||||||
|
require.Equal(first, second, "the same set of instances must yield the same leader")
|
||||||
|
require.Equal(elected.Leader.WsConnectionId, first.Leader.WsConnectionId)
|
||||||
|
require.Equal(elected.Leader.WsConnectionId, second.Leader.WsConnectionId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDerive_InputOrder(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
base := instances(
|
||||||
|
instance("conn-d", 100, electionMode),
|
||||||
|
instance("conn-a", 300, electionMode),
|
||||||
|
instance("conn-c", 100, noElectionMode),
|
||||||
|
instance("conn-b", 200, noElectionMode),
|
||||||
|
)
|
||||||
|
|
||||||
|
expected := leader.Derive(base)
|
||||||
|
require.Equal("conn-c", expected.Leader.WsConnectionId)
|
||||||
|
|
||||||
|
for _, input := range permutations(base) {
|
||||||
|
original := slices.Clone(base)
|
||||||
|
|
||||||
|
got := leader.Derive(input)
|
||||||
|
|
||||||
|
require.Equal(expected, got, "input order must not change the result")
|
||||||
|
require.Equal(original, base, "Derive must not mutate the caller slice")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDerive_NoElection(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
got := leader.Derive(instances(
|
||||||
|
instance("conn-a", 100, noElectionMode),
|
||||||
|
instance("conn-b", 200, cluster.ModuleLeaderModeImLeader),
|
||||||
|
instance("conn-c", 50, garbageMode),
|
||||||
|
))
|
||||||
|
|
||||||
|
require.False(got.HasElection)
|
||||||
|
require.False(got.Found)
|
||||||
|
require.Equal(entity.Backend{}, got.Leader)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDerive_SingleInstance(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
got := leader.Derive(instances(instance("conn-a", 100, electionMode)))
|
||||||
|
|
||||||
|
require.True(got.HasElection)
|
||||||
|
require.True(got.Found)
|
||||||
|
require.Equal("conn-a", got.Leader.WsConnectionId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDerive_NoInstances(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
got := leader.Derive(nil)
|
||||||
|
|
||||||
|
require.False(got.HasElection)
|
||||||
|
require.False(got.Found)
|
||||||
|
require.Equal(entity.Backend{}, got.Leader)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDeriveByModule(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
first := instance("conn-a", 100, electionMode)
|
||||||
|
first.ModuleId = "module-1"
|
||||||
|
first.ModuleName = "module-one"
|
||||||
|
|
||||||
|
second := instance("conn-b", 200, noElectionMode)
|
||||||
|
second.ModuleId = "module-2"
|
||||||
|
second.ModuleName = "module-two"
|
||||||
|
|
||||||
|
elections := leader.DeriveByModule(instances(second, first))
|
||||||
|
|
||||||
|
require.Len(elections, 2, "every module gets its own election")
|
||||||
|
require.Equal("conn-a", elections["module-1"].Leader.WsConnectionId)
|
||||||
|
require.False(elections["module-2"].HasElection, "an instance of another module must not start an election")
|
||||||
|
}
|
||||||
|
|
||||||
|
func instance(wsConnectionId string, createdAt int64, mode string) entity.Backend {
|
||||||
|
return entity.Backend{
|
||||||
|
WsConnectionId: wsConnectionId,
|
||||||
|
ModuleId: "module-id",
|
||||||
|
ModuleName: "module",
|
||||||
|
Address: "10.2.9.1:9999",
|
||||||
|
ModuleLeaderMode: mode,
|
||||||
|
CreatedAt: xtypes.Time(time.Unix(createdAt, 0)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func instances(backends ...entity.Backend) []entity.Backend {
|
||||||
|
return backends
|
||||||
|
}
|
||||||
|
|
||||||
|
func permutations(backends []entity.Backend) [][]entity.Backend {
|
||||||
|
reversed := slices.Clone(backends)
|
||||||
|
slices.Reverse(reversed)
|
||||||
|
|
||||||
|
rotated := append(slices.Clone(backends[1:]), backends[0])
|
||||||
|
|
||||||
|
return [][]entity.Backend{backends, reversed, rotated}
|
||||||
|
}
|
||||||
@@ -4,12 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/etp/v4"
|
"github.com/txix-open/etp/v4"
|
||||||
"github.com/txix-open/etp/v4/store"
|
"github.com/txix-open/etp/v4/store"
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
"isp-config-service/domain"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/entity/xtypes"
|
"isp-config-service/entity/xtypes"
|
||||||
"isp-config-service/helpers"
|
"isp-config-service/helpers"
|
||||||
@@ -42,6 +45,12 @@ type ConfigRepo interface {
|
|||||||
GetActive(ctx context.Context, moduleId string) (*entity.Config, error)
|
GetActive(ctx context.Context, moduleId string) (*entity.Config, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VariableService interface {
|
||||||
|
RenderConfig(ctx context.Context, input []byte) ([]byte, error)
|
||||||
|
ExtractVariables(ctx context.Context, configId string, input []byte) (*domain.VariableExtractionResult, error)
|
||||||
|
SaveVariableLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error
|
||||||
|
}
|
||||||
|
|
||||||
type SubscriptionService interface {
|
type SubscriptionService interface {
|
||||||
SubscribeToConfigChanges(conn *etp.Conn, moduleId string)
|
SubscribeToConfigChanges(conn *etp.Conn, moduleId string)
|
||||||
SubscribeToBackendsChanges(ctx context.Context, conn *etp.Conn, requiredModuleNames []string) error
|
SubscribeToBackendsChanges(ctx context.Context, conn *etp.Conn, requiredModuleNames []string) error
|
||||||
@@ -55,6 +64,7 @@ type Service struct {
|
|||||||
configSchemaRepo ConfigSchemaRepo
|
configSchemaRepo ConfigSchemaRepo
|
||||||
subscriptionService SubscriptionService
|
subscriptionService SubscriptionService
|
||||||
emitter Emitter
|
emitter Emitter
|
||||||
|
variableService VariableService
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +75,7 @@ func NewService(
|
|||||||
configSchemaRepo ConfigSchemaRepo,
|
configSchemaRepo ConfigSchemaRepo,
|
||||||
subscriptionService SubscriptionService,
|
subscriptionService SubscriptionService,
|
||||||
emitter Emitter,
|
emitter Emitter,
|
||||||
|
variableService VariableService,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
) Service {
|
) Service {
|
||||||
return Service{
|
return Service{
|
||||||
@@ -74,6 +85,7 @@ func NewService(
|
|||||||
configSchemaRepo: configSchemaRepo,
|
configSchemaRepo: configSchemaRepo,
|
||||||
subscriptionService: subscriptionService,
|
subscriptionService: subscriptionService,
|
||||||
emitter: emitter,
|
emitter: emitter,
|
||||||
|
variableService: variableService,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,14 +221,32 @@ func (s Service) OnModuleConfigSchema(
|
|||||||
Version: 1,
|
Version: 1,
|
||||||
Active: xtypes.Bool(true),
|
Active: xtypes.Bool(true),
|
||||||
}
|
}
|
||||||
err := s.configRepo.Insert(ctx, initialConfig)
|
|
||||||
|
result, err := s.variableService.ExtractVariables(ctx, initialConfig.Id, initialConfig.Data)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "extract variables from initial config")
|
||||||
|
}
|
||||||
|
if len(result.AbsentVariables) > 0 {
|
||||||
|
return errors.Errorf("missing variables in initial config: [%s]", strings.Join(result.AbsentVariables, ","))
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.configRepo.Insert(ctx, initialConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "insert config in store")
|
return errors.WithMessage(err, "insert config in store")
|
||||||
}
|
}
|
||||||
|
err = s.variableService.SaveVariableLinks(ctx, initialConfig.Id, result.VariableLinks)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "save variable links in store")
|
||||||
|
}
|
||||||
|
|
||||||
config = &initialConfig
|
config = &initialConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
s.emitter.Emit(ctx, conn, cluster.ConfigSendConfigWhenConnected, config.Data)
|
configData, err := s.variableService.RenderConfig(ctx, config.Data)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "render config")
|
||||||
|
}
|
||||||
|
s.emitter.Emit(ctx, conn, cluster.ConfigSendConfigWhenConnected, configData)
|
||||||
|
|
||||||
s.subscriptionService.SubscribeToConfigChanges(conn, moduleId)
|
s.subscriptionService.SubscribeToConfigChanges(conn, moduleId)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,495 @@
|
|||||||
|
// nolint
|
||||||
|
package rqlite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config represents the configuration as set by command-line flags.
|
||||||
|
// All variables will be set, unless explicit noted.
|
||||||
|
type Config struct {
|
||||||
|
// DataPath is path to node data. Always set.
|
||||||
|
DataPath string
|
||||||
|
|
||||||
|
// ExtensionPaths is a comma-delimited list of path to SQLite extensions to be loaded.
|
||||||
|
// Each element may be a directory path, zipfile, or tar.gz file. May not be set.
|
||||||
|
ExtensionPaths StringSliceValue
|
||||||
|
|
||||||
|
// HTTPAddr is the bind network address for the HTTP Server.
|
||||||
|
// It never includes a trailing HTTP or HTTPS.
|
||||||
|
HTTPAddr string
|
||||||
|
|
||||||
|
// HTTPAdv is the advertised HTTP server network.
|
||||||
|
HTTPAdv string
|
||||||
|
|
||||||
|
// HTTPAllowOrigin is the value to set for Access-Control-Allow-Origin HTTP header.
|
||||||
|
HTTPAllowOrigin string
|
||||||
|
|
||||||
|
// AuthFile is the path to the authentication file. May not be set.
|
||||||
|
AuthFile string `filepath:"true"`
|
||||||
|
|
||||||
|
// AutoBackupFile is the path to the auto-backup file. May not be set.
|
||||||
|
AutoBackupFile string `filepath:"true"`
|
||||||
|
|
||||||
|
// AutoRestoreFile is the path to the auto-restore file. May not be set.
|
||||||
|
AutoRestoreFile string `filepath:"true"`
|
||||||
|
|
||||||
|
// HTTPx509CACert is the path to the CA certificate file for when this node verifies
|
||||||
|
// other certificates for any HTTP communications. May not be set.
|
||||||
|
HTTPx509CACert string `filepath:"true"`
|
||||||
|
|
||||||
|
// HTTPx509Cert is the path to the X509 cert for the HTTP server. May not be set.
|
||||||
|
HTTPx509Cert string `filepath:"true"`
|
||||||
|
|
||||||
|
// HTTPx509Key is the path to the private key for the HTTP server. May not be set.
|
||||||
|
HTTPx509Key string `filepath:"true"`
|
||||||
|
|
||||||
|
// HTTPVerifyClient indicates whether the HTTP server should verify client certificates.
|
||||||
|
HTTPVerifyClient bool
|
||||||
|
|
||||||
|
// NodeX509CACert is the path to the CA certificate file for when this node verifies
|
||||||
|
// other certificates for any inter-node communications. May not be set.
|
||||||
|
NodeX509CACert string `filepath:"true"`
|
||||||
|
|
||||||
|
// NodeX509Cert is the path to the X509 cert for the Raft server. May not be set.
|
||||||
|
NodeX509Cert string `filepath:"true"`
|
||||||
|
|
||||||
|
// NodeX509Key is the path to the X509 key for the Raft server. May not be set.
|
||||||
|
NodeX509Key string `filepath:"true"`
|
||||||
|
|
||||||
|
// NoNodeVerify disables checking other nodes' Node X509 certs for validity.
|
||||||
|
NoNodeVerify bool
|
||||||
|
|
||||||
|
// NodeVerifyClient enable mutual TLS for node-to-node communication.
|
||||||
|
NodeVerifyClient bool
|
||||||
|
|
||||||
|
// NodeVerifyServerName is the hostname to verify on the certificates returned by nodes.
|
||||||
|
// If NoNodeVerify is true this field is ignored.
|
||||||
|
NodeVerifyServerName string
|
||||||
|
|
||||||
|
// NodeVerifyCommonName is the CommonName to verify as on the certificates returned by a node.
|
||||||
|
NodeVerifyCommonName string
|
||||||
|
|
||||||
|
// NodeID is the Raft ID for the node.
|
||||||
|
NodeID string
|
||||||
|
|
||||||
|
// RaftAddr is the bind network address for the Raft server.
|
||||||
|
RaftAddr string
|
||||||
|
|
||||||
|
// RaftAdv is the advertised Raft server address.
|
||||||
|
RaftAdv string
|
||||||
|
|
||||||
|
// JoinAddrs is the list of Raft addresses to use for a join attempt.
|
||||||
|
JoinAddrs string
|
||||||
|
|
||||||
|
// JoinAttempts is the number of times a node should attempt to join using a
|
||||||
|
// given address.
|
||||||
|
JoinAttempts int
|
||||||
|
|
||||||
|
// JoinInterval is the time between retrying failed join operations.
|
||||||
|
JoinInterval time.Duration
|
||||||
|
|
||||||
|
// JoinAs sets the user join attempts should be performed as. May not be set.
|
||||||
|
JoinAs string
|
||||||
|
|
||||||
|
// BootstrapExpect is the minimum number of nodes required for a bootstrap.
|
||||||
|
BootstrapExpect int
|
||||||
|
|
||||||
|
// BootstrapExpectTimeout is the maximum time a bootstrap operation can take.
|
||||||
|
BootstrapExpectTimeout time.Duration
|
||||||
|
|
||||||
|
// DiscoMode sets the discovery mode. May not be set.
|
||||||
|
DiscoMode string
|
||||||
|
|
||||||
|
// DiscoKey sets the discovery prefix key.
|
||||||
|
DiscoKey string
|
||||||
|
|
||||||
|
// DiscoConfig sets the path to any discovery configuration file. May not be set.
|
||||||
|
DiscoConfig string
|
||||||
|
|
||||||
|
// OnDiskPath sets the path to the SQLite file. May not be set.
|
||||||
|
OnDiskPath string
|
||||||
|
|
||||||
|
// FKConstraints enables SQLite foreign key constraints.
|
||||||
|
FKConstraints bool
|
||||||
|
|
||||||
|
// AutoVacInterval sets the automatic VACUUM interval. Use 0s to disable.
|
||||||
|
AutoVacInterval time.Duration
|
||||||
|
|
||||||
|
// AutoOptimizeInterval sets the automatic optimization interval. Use 0s to disable.
|
||||||
|
AutoOptimizeInterval time.Duration
|
||||||
|
|
||||||
|
// RaftLogLevel sets the minimum logging level for the Raft subsystem.
|
||||||
|
RaftLogLevel string
|
||||||
|
|
||||||
|
// RaftNonVoter controls whether this node is a voting, read-only node.
|
||||||
|
RaftNonVoter bool
|
||||||
|
|
||||||
|
// RaftSnapThreshold is the number of outstanding log entries that trigger snapshot.
|
||||||
|
RaftSnapThreshold uint64
|
||||||
|
|
||||||
|
// RaftSnapThreshold is the size of a SQLite WAL file which will trigger a snapshot.
|
||||||
|
RaftSnapThresholdWALSize uint64
|
||||||
|
|
||||||
|
// RaftSnapInterval sets the threshold check interval.
|
||||||
|
RaftSnapInterval time.Duration
|
||||||
|
|
||||||
|
// RaftLeaderLeaseTimeout sets the leader lease timeout.
|
||||||
|
RaftLeaderLeaseTimeout time.Duration
|
||||||
|
|
||||||
|
// RaftHeartbeatTimeout specifies the time in follower state without contact
|
||||||
|
// from a Leader before the node attempts an election.
|
||||||
|
RaftHeartbeatTimeout time.Duration
|
||||||
|
|
||||||
|
// RaftElectionTimeout specifies the time in candidate state without contact
|
||||||
|
// from a Leader before the node attempts an election.
|
||||||
|
RaftElectionTimeout time.Duration
|
||||||
|
|
||||||
|
// RaftApplyTimeout sets the Log-apply timeout.
|
||||||
|
RaftApplyTimeout time.Duration
|
||||||
|
|
||||||
|
// RaftShutdownOnRemove sets whether Raft should be shutdown if the node is removed
|
||||||
|
RaftShutdownOnRemove bool
|
||||||
|
|
||||||
|
// RaftClusterRemoveOnShutdown sets whether the node should remove itself from the cluster on shutdown
|
||||||
|
RaftClusterRemoveOnShutdown bool
|
||||||
|
|
||||||
|
// RaftStepdownOnShutdown sets whether Leadership should be relinquished on shutdown
|
||||||
|
RaftStepdownOnShutdown bool
|
||||||
|
|
||||||
|
// RaftReapNodeTimeout sets the duration after which a non-reachable voting node is
|
||||||
|
// reaped i.e. removed from the cluster.
|
||||||
|
RaftReapNodeTimeout time.Duration
|
||||||
|
|
||||||
|
// RaftReapReadOnlyNodeTimeout sets the duration after which a non-reachable non-voting node is
|
||||||
|
// reaped i.e. removed from the cluster.
|
||||||
|
RaftReapReadOnlyNodeTimeout time.Duration
|
||||||
|
|
||||||
|
// ClusterConnectTimeout sets the timeout when initially connecting to another node in
|
||||||
|
// the cluster, for non-Raft communications.
|
||||||
|
ClusterConnectTimeout time.Duration
|
||||||
|
|
||||||
|
// WriteQueueCap is the default capacity of Execute queues
|
||||||
|
WriteQueueCap int
|
||||||
|
|
||||||
|
// WriteQueueBatchSz is the default batch size for Execute queues
|
||||||
|
WriteQueueBatchSz int
|
||||||
|
|
||||||
|
// WriteQueueTimeout is the default time after which any data will be sent on
|
||||||
|
// Execute queues, if a batch size has not been reached.
|
||||||
|
WriteQueueTimeout time.Duration
|
||||||
|
|
||||||
|
// WriteQueueTx controls whether writes from the queue are done within a transaction.
|
||||||
|
WriteQueueTx bool
|
||||||
|
|
||||||
|
// CPUProfile enables CPU profiling.
|
||||||
|
CPUProfile string
|
||||||
|
|
||||||
|
// MemProfile enables memory profiling.
|
||||||
|
MemProfile string
|
||||||
|
|
||||||
|
// TraceProfile enables trace profiling.
|
||||||
|
TraceProfile string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Backup struct {
|
||||||
|
Enable bool
|
||||||
|
Amount int
|
||||||
|
Version int
|
||||||
|
Type string
|
||||||
|
Interval string
|
||||||
|
ClearInterval time.Duration
|
||||||
|
Timestamp bool
|
||||||
|
Vacuum bool
|
||||||
|
Sub Sub
|
||||||
|
}
|
||||||
|
|
||||||
|
type Sub struct {
|
||||||
|
Dir string
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Backup) SetParams() {
|
||||||
|
b.Version = 1
|
||||||
|
b.Type = "file"
|
||||||
|
b.Timestamp = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate checks the configuration for internal consistency, and activates
|
||||||
|
// important rqlite policies. It must be called at least once on a Config
|
||||||
|
// object before the Config object is used. It is OK to call more than
|
||||||
|
// once.
|
||||||
|
func (c *Config) Validate() error {
|
||||||
|
dataPath, err := filepath.Abs(c.DataPath)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Errorf("failed to determine absolute data path: %s", err.Error())
|
||||||
|
}
|
||||||
|
c.DataPath = dataPath
|
||||||
|
|
||||||
|
err = c.CheckFilePaths()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.CheckDirPaths()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.ExtensionPaths) > 0 {
|
||||||
|
for _, p := range c.ExtensionPaths {
|
||||||
|
if !fileExists(p) {
|
||||||
|
return errors.Errorf("extension path does not exist: %s", p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bothUnsetSet(c.HTTPx509Cert, c.HTTPx509Key) {
|
||||||
|
return errors.Errorf("either both -%s and -%s must be set, or neither", HTTPx509CertFlag, HTTPx509KeyFlag)
|
||||||
|
}
|
||||||
|
if !bothUnsetSet(c.NodeX509Cert, c.NodeX509Key) {
|
||||||
|
return errors.Errorf("either both -%s and -%s must be set, or neither", NodeX509CertFlag, NodeX509KeyFlag)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.RaftAddr == c.HTTPAddr {
|
||||||
|
return errors.New("HTTP and Raft addresses must differ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enforce policies regarding addresses
|
||||||
|
if c.RaftAdv == "" {
|
||||||
|
c.RaftAdv = c.RaftAddr
|
||||||
|
}
|
||||||
|
if c.HTTPAdv == "" {
|
||||||
|
c.HTTPAdv = c.HTTPAddr
|
||||||
|
}
|
||||||
|
|
||||||
|
// Node ID policy
|
||||||
|
if c.NodeID == "" {
|
||||||
|
c.NodeID = c.RaftAdv
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform some address validity checks.
|
||||||
|
if strings.HasPrefix(strings.ToLower(c.HTTPAddr), "http") ||
|
||||||
|
strings.HasPrefix(strings.ToLower(c.HTTPAdv), "http") {
|
||||||
|
return errors.New("HTTP options should not include protocol (http:// or https://)")
|
||||||
|
}
|
||||||
|
if _, _, err := net.SplitHostPort(c.HTTPAddr); err != nil {
|
||||||
|
return errors.New("HTTP bind address not valid")
|
||||||
|
}
|
||||||
|
|
||||||
|
hadv, _, err := net.SplitHostPort(c.HTTPAdv)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("HTTP advertised HTTP address not valid")
|
||||||
|
}
|
||||||
|
if addr := net.ParseIP(hadv); addr != nil && addr.IsUnspecified() {
|
||||||
|
return errors.Errorf("advertised HTTP address is not routable (%s), specify it via -%s or -%s",
|
||||||
|
hadv, HTTPAddrFlag, HTTPAdvAddrFlag)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, rp, err := net.SplitHostPort(c.RaftAddr); err != nil {
|
||||||
|
return errors.New("raft bind address not valid")
|
||||||
|
} else if _, err := strconv.Atoi(rp); err != nil {
|
||||||
|
return errors.New("raft bind port not valid")
|
||||||
|
}
|
||||||
|
|
||||||
|
radv, rp, err := net.SplitHostPort(c.RaftAdv)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("raft advertised address not valid")
|
||||||
|
}
|
||||||
|
if addr := net.ParseIP(radv); addr != nil && addr.IsUnspecified() {
|
||||||
|
return errors.Errorf("advertised Raft address is not routable (%s), specify it via -%s or -%s",
|
||||||
|
radv, RaftAddrFlag, RaftAdvAddrFlag)
|
||||||
|
}
|
||||||
|
if _, err := strconv.Atoi(rp); err != nil {
|
||||||
|
return errors.New("raft advertised port is not valid")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.RaftAdv == c.HTTPAdv {
|
||||||
|
return errors.New("advertised HTTP and Raft addresses must differ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enforce bootstrapping policies
|
||||||
|
if c.BootstrapExpect > 0 && c.RaftNonVoter {
|
||||||
|
return errors.New("bootstrapping only applicable to voting nodes")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Join parameters OK?
|
||||||
|
if c.JoinAddrs != "" {
|
||||||
|
addrs := strings.Split(c.JoinAddrs, ",")
|
||||||
|
for i := range addrs {
|
||||||
|
if _, _, err := net.SplitHostPort(addrs[i]); err != nil {
|
||||||
|
return errors.Errorf("%s is an invalid join address", addrs[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.BootstrapExpect == 0 {
|
||||||
|
if addrs[i] == c.RaftAdv || addrs[i] == c.RaftAddr {
|
||||||
|
return errors.New("node cannot join with itself unless bootstrapping")
|
||||||
|
}
|
||||||
|
if c.AutoRestoreFile != "" {
|
||||||
|
return errors.New("auto-restoring cannot be used when joining a cluster")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.DiscoMode != "" {
|
||||||
|
return errors.New("disco mode cannot be used when also explicitly joining a cluster")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid disco mode?
|
||||||
|
switch c.DiscoMode {
|
||||||
|
case "":
|
||||||
|
case DiscoModeEtcdKV, DiscoModeConsulKV:
|
||||||
|
if c.BootstrapExpect > 0 {
|
||||||
|
return errors.Errorf("bootstrapping not applicable when using %s", c.DiscoMode)
|
||||||
|
}
|
||||||
|
case DiscoModeDNS, DiscoModeDNSSRV:
|
||||||
|
if c.BootstrapExpect == 0 && !c.RaftNonVoter {
|
||||||
|
return errors.Errorf("bootstrap-expect value required when using %s with a voting node", c.DiscoMode)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return errors.Errorf("disco mode must be one of %s, %s, %s, or %s",
|
||||||
|
DiscoModeConsulKV, DiscoModeEtcdKV, DiscoModeDNS, DiscoModeDNSSRV)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// JoinAddresses returns the join addresses set at the command line. Returns nil
|
||||||
|
// if no join addresses were set.
|
||||||
|
func (c *Config) JoinAddresses() []string {
|
||||||
|
if c.JoinAddrs == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return strings.Split(c.JoinAddrs, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
// HTTPURL returns the fully-formed, advertised HTTP API address for this config, including
|
||||||
|
// protocol, host and port.
|
||||||
|
func (c *Config) HTTPURL() string {
|
||||||
|
apiProto := "http"
|
||||||
|
if c.HTTPx509Cert != "" {
|
||||||
|
apiProto = "https"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s://%s", apiProto, c.HTTPAdv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RaftPort returns the port on which the Raft system is listening. Validate must
|
||||||
|
// have been called before calling this method.
|
||||||
|
func (c *Config) RaftPort() int {
|
||||||
|
_, port, err := net.SplitHostPort(c.RaftAddr)
|
||||||
|
if err != nil {
|
||||||
|
panic("RaftAddr not valid")
|
||||||
|
}
|
||||||
|
p, err := strconv.Atoi(port)
|
||||||
|
if err != nil {
|
||||||
|
panic("RaftAddr port not valid")
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
// DiscoConfigReader returns a ReadCloser providing access to the Disco config.
|
||||||
|
// The caller must call close on the ReadCloser when finished with it. If no
|
||||||
|
// config was supplied, it returns nil.
|
||||||
|
func (c *Config) DiscoConfigReader() io.ReadCloser {
|
||||||
|
var rc io.ReadCloser
|
||||||
|
if c.DiscoConfig == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open config file. If opening fails, assume string is the literal config.
|
||||||
|
cfgFile, err := os.Open(c.DiscoConfig)
|
||||||
|
if err != nil {
|
||||||
|
rc = io.NopCloser(bytes.NewReader([]byte(c.DiscoConfig)))
|
||||||
|
} else {
|
||||||
|
rc = cfgFile
|
||||||
|
}
|
||||||
|
return rc
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckFilePaths checks that all file paths in the config exist.
|
||||||
|
// Empty filepaths are ignored.
|
||||||
|
func (c *Config) CheckFilePaths() error {
|
||||||
|
v := reflect.ValueOf(c).Elem()
|
||||||
|
|
||||||
|
// Iterate through the fields of the struct
|
||||||
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
field := v.Type().Field(i)
|
||||||
|
fieldValue := v.Field(i)
|
||||||
|
|
||||||
|
if fieldValue.Kind() != reflect.String {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if tagValue, ok := field.Tag.Lookup("filepath"); ok && tagValue == "true" {
|
||||||
|
filePath := fieldValue.String()
|
||||||
|
if filePath == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !fileExists(filePath) {
|
||||||
|
return errors.Errorf("%s does not exist", filePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CheckDirPaths checks that all directory paths in the config exist and are directories.
|
||||||
|
// Empty directory paths are ignored.
|
||||||
|
func (c *Config) CheckDirPaths() error {
|
||||||
|
v := reflect.ValueOf(c).Elem()
|
||||||
|
|
||||||
|
// Iterate through the fields of the struct
|
||||||
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
field := v.Type().Field(i)
|
||||||
|
fieldValue := v.Field(i)
|
||||||
|
|
||||||
|
if fieldValue.Kind() != reflect.String {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if tagValue, ok := field.Tag.Lookup("dirpath"); ok && tagValue == "true" {
|
||||||
|
dirPath := fieldValue.String()
|
||||||
|
if dirPath == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !fileExists(dirPath) {
|
||||||
|
return errors.Errorf("%s does not exist", dirPath)
|
||||||
|
}
|
||||||
|
if !isDir(dirPath) {
|
||||||
|
return errors.Errorf("%s is not a directory", dirPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// bothUnsetSet returns true if both a and b are unset, or both are set.
|
||||||
|
func bothUnsetSet(a, b string) bool {
|
||||||
|
return (a == "" && b == "") || (a != "" && b != "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func fileExists(path string) bool {
|
||||||
|
_, err := os.Stat(path)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isDir(path string) bool {
|
||||||
|
fi, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return fi.IsDir()
|
||||||
|
}
|
||||||
@@ -2,8 +2,9 @@ package rqlite
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/rqlite/rqlite/v8/auth"
|
"github.com/rqlite/rqlite/v10/auth"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+77
-26
@@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
"github.com/txix-open/isp-kit/http/httpcli"
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
)
|
)
|
||||||
@@ -32,7 +32,7 @@ func (d Adapter) Select(ctx context.Context, ptr any, query string, args ...any)
|
|||||||
result := &Result{
|
result := &Result{
|
||||||
Rows: ptr,
|
Rows: ptr,
|
||||||
}
|
}
|
||||||
resp := Response{
|
resp := &Response{
|
||||||
Results: []*Result{result},
|
Results: []*Result{result},
|
||||||
}
|
}
|
||||||
params := map[string]any{
|
params := map[string]any{
|
||||||
@@ -42,22 +42,24 @@ func (d Adapter) Select(ctx context.Context, ptr any, query string, args ...any)
|
|||||||
consistencyFromContext(ctx).appendParams(params)
|
consistencyFromContext(ctx).appendParams(params)
|
||||||
err := d.cli.Post("/db/query").
|
err := d.cli.Post("/db/query").
|
||||||
QueryParams(params).
|
QueryParams(params).
|
||||||
JsonRequestBody(requests(request(query, args...))).
|
JsonRequestBody(Requests(Request(query, args...))).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(resp).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
DoWithoutResponse(ctx)
|
DoWithoutResponse(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "call rqlite")
|
return errors.WithMessage(err, "call rqlite")
|
||||||
}
|
}
|
||||||
if result.Error != "" {
|
err = catchError(resp, result)
|
||||||
return errors.Errorf("sqlite: %s", result.Error)
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Adapter) SelectRow(ctx context.Context, ptr any, query string, args ...any) error {
|
func (d Adapter) SelectRow(ctx context.Context, ptr any, query string, args ...any) error {
|
||||||
result := &Result{}
|
result := &Result{}
|
||||||
resp := Response{
|
resp := &Response{
|
||||||
Results: []*Result{result},
|
Results: []*Result{result},
|
||||||
}
|
}
|
||||||
params := map[string]any{
|
params := map[string]any{
|
||||||
@@ -67,8 +69,8 @@ func (d Adapter) SelectRow(ctx context.Context, ptr any, query string, args ...a
|
|||||||
consistencyFromContext(ctx).appendParams(params)
|
consistencyFromContext(ctx).appendParams(params)
|
||||||
httpResp, err := d.cli.Post("/db/request").
|
httpResp, err := d.cli.Post("/db/request").
|
||||||
QueryParams(params).
|
QueryParams(params).
|
||||||
JsonRequestBody(requests(request(query, args...))).
|
JsonRequestBody(Requests(Request(query, args...))).
|
||||||
JsonResponseBody(&resp).
|
JsonResponseBody(resp).
|
||||||
StatusCodeToError().
|
StatusCodeToError().
|
||||||
Do(ctx)
|
Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -76,11 +78,12 @@ func (d Adapter) SelectRow(ctx context.Context, ptr any, query string, args ...a
|
|||||||
}
|
}
|
||||||
defer httpResp.Close()
|
defer httpResp.Close()
|
||||||
|
|
||||||
if result.Error != "" {
|
err = catchError(resp, result)
|
||||||
return errors.Errorf("sqlite: %s", result.Error)
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
body, _ := httpResp.Body()
|
body, _ := httpResp.UnsafeBody()
|
||||||
rows := gjson.GetBytes(body, "results.0.rows")
|
rows := gjson.GetBytes(body, "results.0.rows")
|
||||||
elems := rows.Array()
|
elems := rows.Array()
|
||||||
if len(elems) == 0 {
|
if len(elems) == 0 {
|
||||||
@@ -95,26 +98,74 @@ func (d Adapter) SelectRow(ctx context.Context, ptr any, query string, args ...a
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d Adapter) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
func (d Adapter) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
||||||
result := &Result{}
|
results, err := d.exec(ctx, false, Requests(Request(query, args...)))
|
||||||
resp := Response{
|
|
||||||
Results: []*Result{result},
|
|
||||||
}
|
|
||||||
err := d.cli.Post("/db/execute").
|
|
||||||
QueryParams(map[string]any{
|
|
||||||
"timings": true,
|
|
||||||
}).JsonRequestBody(requests(request(query, args...))).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
StatusCodeToError().
|
|
||||||
DoWithoutResponse(ctx)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "call rqlite")
|
return nil, err
|
||||||
}
|
}
|
||||||
if result.Error != "" {
|
|
||||||
return nil, errors.Errorf("sqlite: %s", result.Error)
|
if len(results) == 0 {
|
||||||
|
return nil, errors.Errorf("unexpected empty results")
|
||||||
}
|
}
|
||||||
|
result, ok := results[0].(*Result)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.Errorf("unexpected result type: %T", results[0])
|
||||||
|
}
|
||||||
|
err = catchError(nil, result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Adapter) ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error) {
|
func (d Adapter) ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error) {
|
||||||
return d.Exec(ctx, query, arg)
|
return d.Exec(ctx, query, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d Adapter) ExecTransaction(ctx context.Context, requests [][]any) ([]sql.Result, error) {
|
||||||
|
return d.exec(ctx, true, requests)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d Adapter) exec(ctx context.Context, inTx bool, requests [][]any) ([]sql.Result, error) {
|
||||||
|
resp := &Response{
|
||||||
|
Results: []*Result{},
|
||||||
|
}
|
||||||
|
err := d.cli.Post("/db/execute").
|
||||||
|
QueryParams(map[string]any{
|
||||||
|
"timings": true,
|
||||||
|
"transaction": inTx,
|
||||||
|
}).JsonRequestBody(requests).
|
||||||
|
JsonResponseBody(resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "call rqlite")
|
||||||
|
}
|
||||||
|
err = catchError(resp, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
results := make([]sql.Result, 0, len(requests))
|
||||||
|
for _, result := range resp.Results {
|
||||||
|
// rqlite reports per-statement failures in individual results with HTTP 200,
|
||||||
|
// and aborts the whole transaction on the first failed statement.
|
||||||
|
err := catchError(nil, result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessagef(err, "exec transaction on statement: %v", requests[min(len(results), len(requests)-1)])
|
||||||
|
}
|
||||||
|
results = append(results, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func catchError(resp *Response, result *Result) error {
|
||||||
|
if resp != nil && resp.Error != "" {
|
||||||
|
return errors.Errorf("rqlite api: %s", resp.Error)
|
||||||
|
}
|
||||||
|
if result != nil && result.Error != "" {
|
||||||
|
return errors.Errorf("sqlite: %s", result.Error)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -10,4 +10,5 @@ type DB interface {
|
|||||||
SelectRow(ctx context.Context, ptr any, query string, args ...any) error
|
SelectRow(ctx context.Context, ptr any, query string, args ...any) error
|
||||||
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
|
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
|
||||||
ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)
|
ExecNamed(ctx context.Context, query string, arg any) (sql.Result, error)
|
||||||
|
ExecTransaction(ctx context.Context, requests [][]any) ([]sql.Result, error)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
func request(query string, args ...any) []any {
|
func Request(query string, args ...any) []any {
|
||||||
return append([]any{query}, args...)
|
return append([]any{query}, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func requests(requests ...[]any) [][]any {
|
func Requests(requests ...[]any) [][]any {
|
||||||
return requests
|
return requests
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
type Result struct {
|
type Result struct {
|
||||||
LastInsertIdValue int64 `json:"last_insert_id"`
|
LastInsertIdValue int64 `json:"last_insert_id"`
|
||||||
RowsAffectedValue int64 `json:"rows_affected"`
|
RowsAffectedValue int64 `json:"rows_affected"`
|
||||||
@@ -20,4 +21,5 @@ func (r Result) RowsAffected() (int64, error) {
|
|||||||
type Response struct {
|
type Response struct {
|
||||||
Results []*Result `json:"results"`
|
Results []*Result `json:"results"`
|
||||||
Time float64 `json:"time"`
|
Time float64 `json:"time"`
|
||||||
|
Error string `json:"error"`
|
||||||
}
|
}
|
||||||
+1
-459
@@ -2,17 +2,10 @@
|
|||||||
package rqlite
|
package rqlite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"reflect"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -56,440 +49,6 @@ func (s *StringSliceValue) Set(value string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config represents the configuration as set by command-line flags.
|
|
||||||
// All variables will be set, unless explicit noted.
|
|
||||||
type Config struct {
|
|
||||||
// DataPath is path to node data. Always set.
|
|
||||||
DataPath string
|
|
||||||
|
|
||||||
// ExtensionPaths is a comma-delimited list of path to SQLite extensions to be loaded.
|
|
||||||
// Each element may be a directory path, zipfile, or tar.gz file. May not be set.
|
|
||||||
ExtensionPaths StringSliceValue
|
|
||||||
|
|
||||||
// HTTPAddr is the bind network address for the HTTP Server.
|
|
||||||
// It never includes a trailing HTTP or HTTPS.
|
|
||||||
HTTPAddr string
|
|
||||||
|
|
||||||
// HTTPAdv is the advertised HTTP server network.
|
|
||||||
HTTPAdv string
|
|
||||||
|
|
||||||
// HTTPAllowOrigin is the value to set for Access-Control-Allow-Origin HTTP header.
|
|
||||||
HTTPAllowOrigin string
|
|
||||||
|
|
||||||
// AuthFile is the path to the authentication file. May not be set.
|
|
||||||
AuthFile string `filepath:"true"`
|
|
||||||
|
|
||||||
// AutoBackupFile is the path to the auto-backup file. May not be set.
|
|
||||||
AutoBackupFile string `filepath:"true"`
|
|
||||||
|
|
||||||
// AutoRestoreFile is the path to the auto-restore file. May not be set.
|
|
||||||
AutoRestoreFile string `filepath:"true"`
|
|
||||||
|
|
||||||
// HTTPx509CACert is the path to the CA certificate file for when this node verifies
|
|
||||||
// other certificates for any HTTP communications. May not be set.
|
|
||||||
HTTPx509CACert string `filepath:"true"`
|
|
||||||
|
|
||||||
// HTTPx509Cert is the path to the X509 cert for the HTTP server. May not be set.
|
|
||||||
HTTPx509Cert string `filepath:"true"`
|
|
||||||
|
|
||||||
// HTTPx509Key is the path to the private key for the HTTP server. May not be set.
|
|
||||||
HTTPx509Key string `filepath:"true"`
|
|
||||||
|
|
||||||
// HTTPVerifyClient indicates whether the HTTP server should verify client certificates.
|
|
||||||
HTTPVerifyClient bool
|
|
||||||
|
|
||||||
// NodeX509CACert is the path to the CA certificate file for when this node verifies
|
|
||||||
// other certificates for any inter-node communications. May not be set.
|
|
||||||
NodeX509CACert string `filepath:"true"`
|
|
||||||
|
|
||||||
// NodeX509Cert is the path to the X509 cert for the Raft server. May not be set.
|
|
||||||
NodeX509Cert string `filepath:"true"`
|
|
||||||
|
|
||||||
// NodeX509Key is the path to the X509 key for the Raft server. May not be set.
|
|
||||||
NodeX509Key string `filepath:"true"`
|
|
||||||
|
|
||||||
// NoNodeVerify disables checking other nodes' Node X509 certs for validity.
|
|
||||||
NoNodeVerify bool
|
|
||||||
|
|
||||||
// NodeVerifyClient enable mutual TLS for node-to-node communication.
|
|
||||||
NodeVerifyClient bool
|
|
||||||
|
|
||||||
// NodeVerifyServerName is the hostname to verify on the certificates returned by nodes.
|
|
||||||
// If NoNodeVerify is true this field is ignored.
|
|
||||||
NodeVerifyServerName string
|
|
||||||
|
|
||||||
// NodeID is the Raft ID for the node.
|
|
||||||
NodeID string
|
|
||||||
|
|
||||||
// RaftAddr is the bind network address for the Raft server.
|
|
||||||
RaftAddr string
|
|
||||||
|
|
||||||
// RaftAdv is the advertised Raft server address.
|
|
||||||
RaftAdv string
|
|
||||||
|
|
||||||
// JoinAddrs is the list of Raft addresses to use for a join attempt.
|
|
||||||
JoinAddrs string
|
|
||||||
|
|
||||||
// JoinAttempts is the number of times a node should attempt to join using a
|
|
||||||
// given address.
|
|
||||||
JoinAttempts int
|
|
||||||
|
|
||||||
// JoinInterval is the time between retrying failed join operations.
|
|
||||||
JoinInterval time.Duration
|
|
||||||
|
|
||||||
// JoinAs sets the user join attempts should be performed as. May not be set.
|
|
||||||
JoinAs string
|
|
||||||
|
|
||||||
// BootstrapExpect is the minimum number of nodes required for a bootstrap.
|
|
||||||
BootstrapExpect int
|
|
||||||
|
|
||||||
// BootstrapExpectTimeout is the maximum time a bootstrap operation can take.
|
|
||||||
BootstrapExpectTimeout time.Duration
|
|
||||||
|
|
||||||
// DiscoMode sets the discovery mode. May not be set.
|
|
||||||
DiscoMode string
|
|
||||||
|
|
||||||
// DiscoKey sets the discovery prefix key.
|
|
||||||
DiscoKey string
|
|
||||||
|
|
||||||
// DiscoConfig sets the path to any discovery configuration file. May not be set.
|
|
||||||
DiscoConfig string
|
|
||||||
|
|
||||||
// OnDiskPath sets the path to the SQLite file. May not be set.
|
|
||||||
OnDiskPath string
|
|
||||||
|
|
||||||
// FKConstraints enables SQLite foreign key constraints.
|
|
||||||
FKConstraints bool
|
|
||||||
|
|
||||||
// AutoVacInterval sets the automatic VACUUM interval. Use 0s to disable.
|
|
||||||
AutoVacInterval time.Duration
|
|
||||||
|
|
||||||
// AutoOptimizeInterval sets the automatic optimization interval. Use 0s to disable.
|
|
||||||
AutoOptimizeInterval time.Duration
|
|
||||||
|
|
||||||
// RaftLogLevel sets the minimum logging level for the Raft subsystem.
|
|
||||||
RaftLogLevel string
|
|
||||||
|
|
||||||
// RaftNonVoter controls whether this node is a voting, read-only node.
|
|
||||||
RaftNonVoter bool
|
|
||||||
|
|
||||||
// RaftSnapThreshold is the number of outstanding log entries that trigger snapshot.
|
|
||||||
RaftSnapThreshold uint64
|
|
||||||
|
|
||||||
// RaftSnapThreshold is the size of a SQLite WAL file which will trigger a snapshot.
|
|
||||||
RaftSnapThresholdWALSize uint64
|
|
||||||
|
|
||||||
// RaftSnapInterval sets the threshold check interval.
|
|
||||||
RaftSnapInterval time.Duration
|
|
||||||
|
|
||||||
// RaftLeaderLeaseTimeout sets the leader lease timeout.
|
|
||||||
RaftLeaderLeaseTimeout time.Duration
|
|
||||||
|
|
||||||
// RaftHeartbeatTimeout specifies the time in follower state without contact
|
|
||||||
// from a Leader before the node attempts an election.
|
|
||||||
RaftHeartbeatTimeout time.Duration
|
|
||||||
|
|
||||||
// RaftElectionTimeout specifies the time in candidate state without contact
|
|
||||||
// from a Leader before the node attempts an election.
|
|
||||||
RaftElectionTimeout time.Duration
|
|
||||||
|
|
||||||
// RaftApplyTimeout sets the Log-apply timeout.
|
|
||||||
RaftApplyTimeout time.Duration
|
|
||||||
|
|
||||||
// RaftShutdownOnRemove sets whether Raft should be shutdown if the node is removed
|
|
||||||
RaftShutdownOnRemove bool
|
|
||||||
|
|
||||||
// RaftClusterRemoveOnShutdown sets whether the node should remove itself from the cluster on shutdown
|
|
||||||
RaftClusterRemoveOnShutdown bool
|
|
||||||
|
|
||||||
// RaftStepdownOnShutdown sets whether Leadership should be relinquished on shutdown
|
|
||||||
RaftStepdownOnShutdown bool
|
|
||||||
|
|
||||||
// RaftReapNodeTimeout sets the duration after which a non-reachable voting node is
|
|
||||||
// reaped i.e. removed from the cluster.
|
|
||||||
RaftReapNodeTimeout time.Duration
|
|
||||||
|
|
||||||
// RaftReapReadOnlyNodeTimeout sets the duration after which a non-reachable non-voting node is
|
|
||||||
// reaped i.e. removed from the cluster.
|
|
||||||
RaftReapReadOnlyNodeTimeout time.Duration
|
|
||||||
|
|
||||||
// ClusterConnectTimeout sets the timeout when initially connecting to another node in
|
|
||||||
// the cluster, for non-Raft communications.
|
|
||||||
ClusterConnectTimeout time.Duration
|
|
||||||
|
|
||||||
// WriteQueueCap is the default capacity of Execute queues
|
|
||||||
WriteQueueCap int
|
|
||||||
|
|
||||||
// WriteQueueBatchSz is the default batch size for Execute queues
|
|
||||||
WriteQueueBatchSz int
|
|
||||||
|
|
||||||
// WriteQueueTimeout is the default time after which any data will be sent on
|
|
||||||
// Execute queues, if a batch size has not been reached.
|
|
||||||
WriteQueueTimeout time.Duration
|
|
||||||
|
|
||||||
// WriteQueueTx controls whether writes from the queue are done within a transaction.
|
|
||||||
WriteQueueTx bool
|
|
||||||
|
|
||||||
// CPUProfile enables CPU profiling.
|
|
||||||
CPUProfile string
|
|
||||||
|
|
||||||
// MemProfile enables memory profiling.
|
|
||||||
MemProfile string
|
|
||||||
|
|
||||||
// TraceProfile enables trace profiling.
|
|
||||||
TraceProfile string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate checks the configuration for internal consistency, and activates
|
|
||||||
// important rqlite policies. It must be called at least once on a Config
|
|
||||||
// object before the Config object is used. It is OK to call more than
|
|
||||||
// once.
|
|
||||||
func (c *Config) Validate() error {
|
|
||||||
dataPath, err := filepath.Abs(c.DataPath)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to determine absolute data path: %s", err.Error())
|
|
||||||
}
|
|
||||||
c.DataPath = dataPath
|
|
||||||
|
|
||||||
err = c.CheckFilePaths()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = c.CheckDirPaths()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(c.ExtensionPaths) > 0 {
|
|
||||||
for _, p := range c.ExtensionPaths {
|
|
||||||
if !fileExists(p) {
|
|
||||||
return fmt.Errorf("extension path does not exist: %s", p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !bothUnsetSet(c.HTTPx509Cert, c.HTTPx509Key) {
|
|
||||||
return fmt.Errorf("either both -%s and -%s must be set, or neither", HTTPx509CertFlag, HTTPx509KeyFlag)
|
|
||||||
}
|
|
||||||
if !bothUnsetSet(c.NodeX509Cert, c.NodeX509Key) {
|
|
||||||
return fmt.Errorf("either both -%s and -%s must be set, or neither", NodeX509CertFlag, NodeX509KeyFlag)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.RaftAddr == c.HTTPAddr {
|
|
||||||
return errors.New("HTTP and Raft addresses must differ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enforce policies regarding addresses
|
|
||||||
if c.RaftAdv == "" {
|
|
||||||
c.RaftAdv = c.RaftAddr
|
|
||||||
}
|
|
||||||
if c.HTTPAdv == "" {
|
|
||||||
c.HTTPAdv = c.HTTPAddr
|
|
||||||
}
|
|
||||||
|
|
||||||
// Node ID policy
|
|
||||||
if c.NodeID == "" {
|
|
||||||
c.NodeID = c.RaftAdv
|
|
||||||
}
|
|
||||||
|
|
||||||
// Perform some address validity checks.
|
|
||||||
if strings.HasPrefix(strings.ToLower(c.HTTPAddr), "http") ||
|
|
||||||
strings.HasPrefix(strings.ToLower(c.HTTPAdv), "http") {
|
|
||||||
return errors.New("HTTP options should not include protocol (http:// or https://)")
|
|
||||||
}
|
|
||||||
if _, _, err := net.SplitHostPort(c.HTTPAddr); err != nil {
|
|
||||||
return errors.New("HTTP bind address not valid")
|
|
||||||
}
|
|
||||||
|
|
||||||
hadv, _, err := net.SplitHostPort(c.HTTPAdv)
|
|
||||||
if err != nil {
|
|
||||||
return errors.New("HTTP advertised HTTP address not valid")
|
|
||||||
}
|
|
||||||
if addr := net.ParseIP(hadv); addr != nil && addr.IsUnspecified() {
|
|
||||||
return fmt.Errorf("advertised HTTP address is not routable (%s), specify it via -%s or -%s",
|
|
||||||
hadv, HTTPAddrFlag, HTTPAdvAddrFlag)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, rp, err := net.SplitHostPort(c.RaftAddr); err != nil {
|
|
||||||
return errors.New("raft bind address not valid")
|
|
||||||
} else if _, err := strconv.Atoi(rp); err != nil {
|
|
||||||
return errors.New("raft bind port not valid")
|
|
||||||
}
|
|
||||||
|
|
||||||
radv, rp, err := net.SplitHostPort(c.RaftAdv)
|
|
||||||
if err != nil {
|
|
||||||
return errors.New("raft advertised address not valid")
|
|
||||||
}
|
|
||||||
if addr := net.ParseIP(radv); addr != nil && addr.IsUnspecified() {
|
|
||||||
return fmt.Errorf("advertised Raft address is not routable (%s), specify it via -%s or -%s",
|
|
||||||
radv, RaftAddrFlag, RaftAdvAddrFlag)
|
|
||||||
}
|
|
||||||
if _, err := strconv.Atoi(rp); err != nil {
|
|
||||||
return errors.New("raft advertised port is not valid")
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.RaftAdv == c.HTTPAdv {
|
|
||||||
return errors.New("advertised HTTP and Raft addresses must differ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enforce bootstrapping policies
|
|
||||||
if c.BootstrapExpect > 0 && c.RaftNonVoter {
|
|
||||||
return errors.New("bootstrapping only applicable to voting nodes")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Join parameters OK?
|
|
||||||
if c.JoinAddrs != "" {
|
|
||||||
addrs := strings.Split(c.JoinAddrs, ",")
|
|
||||||
for i := range addrs {
|
|
||||||
if _, _, err := net.SplitHostPort(addrs[i]); err != nil {
|
|
||||||
return fmt.Errorf("%s is an invalid join address", addrs[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.BootstrapExpect == 0 {
|
|
||||||
if addrs[i] == c.RaftAdv || addrs[i] == c.RaftAddr {
|
|
||||||
return errors.New("node cannot join with itself unless bootstrapping")
|
|
||||||
}
|
|
||||||
if c.AutoRestoreFile != "" {
|
|
||||||
return errors.New("auto-restoring cannot be used when joining a cluster")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.DiscoMode != "" {
|
|
||||||
return errors.New("disco mode cannot be used when also explicitly joining a cluster")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Valid disco mode?
|
|
||||||
switch c.DiscoMode {
|
|
||||||
case "":
|
|
||||||
case DiscoModeEtcdKV, DiscoModeConsulKV:
|
|
||||||
if c.BootstrapExpect > 0 {
|
|
||||||
return fmt.Errorf("bootstrapping not applicable when using %s", c.DiscoMode)
|
|
||||||
}
|
|
||||||
case DiscoModeDNS, DiscoModeDNSSRV:
|
|
||||||
if c.BootstrapExpect == 0 && !c.RaftNonVoter {
|
|
||||||
return fmt.Errorf("bootstrap-expect value required when using %s with a voting node", c.DiscoMode)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("disco mode must be one of %s, %s, %s, or %s",
|
|
||||||
DiscoModeConsulKV, DiscoModeEtcdKV, DiscoModeDNS, DiscoModeDNSSRV)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// JoinAddresses returns the join addresses set at the command line. Returns nil
|
|
||||||
// if no join addresses were set.
|
|
||||||
func (c *Config) JoinAddresses() []string {
|
|
||||||
if c.JoinAddrs == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return strings.Split(c.JoinAddrs, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
// HTTPURL returns the fully-formed, advertised HTTP API address for this config, including
|
|
||||||
// protocol, host and port.
|
|
||||||
func (c *Config) HTTPURL() string {
|
|
||||||
apiProto := "http"
|
|
||||||
if c.HTTPx509Cert != "" {
|
|
||||||
apiProto = "https"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s://%s", apiProto, c.HTTPAdv)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RaftPort returns the port on which the Raft system is listening. Validate must
|
|
||||||
// have been called before calling this method.
|
|
||||||
func (c *Config) RaftPort() int {
|
|
||||||
_, port, err := net.SplitHostPort(c.RaftAddr)
|
|
||||||
if err != nil {
|
|
||||||
panic("RaftAddr not valid")
|
|
||||||
}
|
|
||||||
p, err := strconv.Atoi(port)
|
|
||||||
if err != nil {
|
|
||||||
panic("RaftAddr port not valid")
|
|
||||||
}
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiscoConfigReader returns a ReadCloser providing access to the Disco config.
|
|
||||||
// The caller must call close on the ReadCloser when finished with it. If no
|
|
||||||
// config was supplied, it returns nil.
|
|
||||||
func (c *Config) DiscoConfigReader() io.ReadCloser {
|
|
||||||
var rc io.ReadCloser
|
|
||||||
if c.DiscoConfig == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open config file. If opening fails, assume string is the literal config.
|
|
||||||
cfgFile, err := os.Open(c.DiscoConfig)
|
|
||||||
if err != nil {
|
|
||||||
rc = io.NopCloser(bytes.NewReader([]byte(c.DiscoConfig)))
|
|
||||||
} else {
|
|
||||||
rc = cfgFile
|
|
||||||
}
|
|
||||||
return rc
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckFilePaths checks that all file paths in the config exist.
|
|
||||||
// Empty filepaths are ignored.
|
|
||||||
func (c *Config) CheckFilePaths() error {
|
|
||||||
v := reflect.ValueOf(c).Elem()
|
|
||||||
|
|
||||||
// Iterate through the fields of the struct
|
|
||||||
for i := 0; i < v.NumField(); i++ {
|
|
||||||
field := v.Type().Field(i)
|
|
||||||
fieldValue := v.Field(i)
|
|
||||||
|
|
||||||
if fieldValue.Kind() != reflect.String {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if tagValue, ok := field.Tag.Lookup("filepath"); ok && tagValue == "true" {
|
|
||||||
filePath := fieldValue.String()
|
|
||||||
if filePath == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !fileExists(filePath) {
|
|
||||||
return fmt.Errorf("%s does not exist", filePath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CheckDirPaths checks that all directory paths in the config exist and are directories.
|
|
||||||
// Empty directory paths are ignored.
|
|
||||||
func (c *Config) CheckDirPaths() error {
|
|
||||||
v := reflect.ValueOf(c).Elem()
|
|
||||||
|
|
||||||
// Iterate through the fields of the struct
|
|
||||||
for i := 0; i < v.NumField(); i++ {
|
|
||||||
field := v.Type().Field(i)
|
|
||||||
fieldValue := v.Field(i)
|
|
||||||
|
|
||||||
if fieldValue.Kind() != reflect.String {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if tagValue, ok := field.Tag.Lookup("dirpath"); ok && tagValue == "true" {
|
|
||||||
dirPath := fieldValue.String()
|
|
||||||
if dirPath == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !fileExists(dirPath) {
|
|
||||||
return fmt.Errorf("%s does not exist", dirPath)
|
|
||||||
}
|
|
||||||
if !isDir(dirPath) {
|
|
||||||
return fmt.Errorf("%s is not a directory", dirPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildInfo is build information for display at command line.
|
// BuildInfo is build information for display at command line.
|
||||||
type BuildInfo struct {
|
type BuildInfo struct {
|
||||||
Version string
|
Version string
|
||||||
@@ -522,6 +81,7 @@ func ParseFlags(name, desc string, build *BuildInfo) (*Config, error) {
|
|||||||
fs.BoolVar(&config.NoNodeVerify, "node-no-verify", false, "Skip verification of any node-node certificate")
|
fs.BoolVar(&config.NoNodeVerify, "node-no-verify", false, "Skip verification of any node-node certificate")
|
||||||
fs.BoolVar(&config.NodeVerifyClient, "node-verify-client", false, "Enable mutual TLS for node-to-node communication")
|
fs.BoolVar(&config.NodeVerifyClient, "node-verify-client", false, "Enable mutual TLS for node-to-node communication")
|
||||||
fs.StringVar(&config.NodeVerifyServerName, "node-verify-server-name", "", "Hostname to verify on certificate returned by a node")
|
fs.StringVar(&config.NodeVerifyServerName, "node-verify-server-name", "", "Hostname to verify on certificate returned by a node")
|
||||||
|
fs.StringVar(&config.NodeVerifyCommonName, "node-verify-common-name", "", "CommonName to verify on certificate returned by a node")
|
||||||
fs.StringVar(&config.AuthFile, "auth", "", "Path to authentication and authorization file. If not set, not enabled")
|
fs.StringVar(&config.AuthFile, "auth", "", "Path to authentication and authorization file. If not set, not enabled")
|
||||||
fs.StringVar(&config.AutoBackupFile, "auto-backup", "", "Path to automatic backup configuration file. If not set, not enabled")
|
fs.StringVar(&config.AutoBackupFile, "auto-backup", "", "Path to automatic backup configuration file. If not set, not enabled")
|
||||||
fs.StringVar(&config.AutoRestoreFile, "auto-restore", "", "Path to automatic restore configuration file. If not set, not enabled")
|
fs.StringVar(&config.AutoRestoreFile, "auto-restore", "", "Path to automatic restore configuration file. If not set, not enabled")
|
||||||
@@ -601,24 +161,6 @@ func errorExit(code int, msg string) {
|
|||||||
os.Exit(code)
|
os.Exit(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// bothUnsetSet returns true if both a and b are unset, or both are set.
|
|
||||||
func bothUnsetSet(a, b string) bool {
|
|
||||||
return (a == "" && b == "") || (a != "" && b != "")
|
|
||||||
}
|
|
||||||
|
|
||||||
func fileExists(path string) bool {
|
|
||||||
_, err := os.Stat(path)
|
|
||||||
return err == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func isDir(path string) bool {
|
|
||||||
fi, err := os.Stat(path)
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return fi.IsDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
func mustParseDuration(d string) time.Duration {
|
func mustParseDuration(d string) time.Duration {
|
||||||
td, err := time.ParseDuration(d)
|
td, err := time.ParseDuration(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package goose_store
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/pressly/goose/v3/database"
|
|
||||||
"isp-config-service/repository"
|
"isp-config-service/repository"
|
||||||
|
|
||||||
|
"github.com/pressly/goose/v3/database"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Store struct {
|
type Store struct {
|
||||||
@@ -30,24 +30,27 @@ func (s Store) Tablename() string {
|
|||||||
|
|
||||||
func (s Store) CreateVersionTable(ctx context.Context, db database.DBTxConn) error {
|
func (s Store) CreateVersionTable(ctx context.Context, db database.DBTxConn) error {
|
||||||
q := s.querier.CreateTable(s.tablename)
|
q := s.querier.CreateTable(s.tablename)
|
||||||
if _, err := s.db.ExecContext(ctx, q); err != nil {
|
_, err := s.db.ExecContext(ctx, q)
|
||||||
return fmt.Errorf("failed to create version table %q: %w", s.tablename, err)
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "failed to create version table %q", s.tablename)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Store) Insert(ctx context.Context, db database.DBTxConn, req database.InsertRequest) error {
|
func (s Store) Insert(ctx context.Context, db database.DBTxConn, req database.InsertRequest) error {
|
||||||
q := s.querier.InsertVersion(s.tablename)
|
q := s.querier.InsertVersion(s.tablename)
|
||||||
if _, err := s.db.ExecContext(ctx, q, req.Version, true); err != nil {
|
_, err := s.db.ExecContext(ctx, q, req.Version, true)
|
||||||
return fmt.Errorf("failed to insert version %d: %w", req.Version, err)
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "failed to insert version %d", req.Version)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Store) Delete(ctx context.Context, db database.DBTxConn, version int64) error {
|
func (s Store) Delete(ctx context.Context, db database.DBTxConn, version int64) error {
|
||||||
q := s.querier.DeleteVersion(s.tablename)
|
q := s.querier.DeleteVersion(s.tablename)
|
||||||
if _, err := s.db.ExecContext(ctx, q, version); err != nil {
|
_, err := s.db.ExecContext(ctx, q, version)
|
||||||
return fmt.Errorf("failed to delete version %d: %w", version, err)
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "failed to delete version %d", version)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -59,10 +62,10 @@ func (s Store) GetMigration(ctx context.Context, db database.DBTxConn, version i
|
|||||||
isApplied := float64(0)
|
isApplied := float64(0)
|
||||||
err := s.db.QueryRowContext(ctx, q, version).Scan(&result.Timestamp, &isApplied)
|
err := s.db.QueryRowContext(ctx, q, version).Scan(&result.Timestamp, &isApplied)
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return nil, fmt.Errorf("%w: %d", database.ErrVersionNotFound, version)
|
return nil, errors.WithMessagef(database.ErrVersionNotFound, "%d", version)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get migration %d: %w", version, err)
|
return nil, errors.WithMessagef(err, "failed to get migration %d", version)
|
||||||
}
|
}
|
||||||
result.IsApplied = isApplied == 0
|
result.IsApplied = isApplied == 0
|
||||||
return &result, nil
|
return &result, nil
|
||||||
@@ -76,7 +79,7 @@ func (s Store) ListMigrations(ctx context.Context, db database.DBTxConn) ([]*dat
|
|||||||
q := s.querier.ListMigrations(s.tablename)
|
q := s.querier.ListMigrations(s.tablename)
|
||||||
rows, err := s.db.QueryContext(ctx, q)
|
rows, err := s.db.QueryContext(ctx, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to list migrations: %w", err)
|
return nil, errors.WithMessage(err, "failed to list migrations")
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
@@ -85,14 +88,16 @@ func (s Store) ListMigrations(ctx context.Context, db database.DBTxConn) ([]*dat
|
|||||||
var result database.ListMigrationsResult
|
var result database.ListMigrationsResult
|
||||||
isApplied := float64(0)
|
isApplied := float64(0)
|
||||||
version := float64(0)
|
version := float64(0)
|
||||||
if err := rows.Scan(&version, &isApplied); err != nil {
|
err = rows.Scan(&version, &isApplied)
|
||||||
return nil, fmt.Errorf("failed to scan list migrations result: %w", err)
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "failed to scan list migrations result")
|
||||||
}
|
}
|
||||||
result.IsApplied = isApplied == 0
|
result.IsApplied = isApplied == 0
|
||||||
result.Version = int64(version)
|
result.Version = int64(version)
|
||||||
migrations = append(migrations, &result)
|
migrations = append(migrations, &result)
|
||||||
}
|
}
|
||||||
if err := rows.Err(); err != nil {
|
err = rows.Err()
|
||||||
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "fetch rows")
|
return nil, errors.WithMessage(err, "fetch rows")
|
||||||
}
|
}
|
||||||
return migrations, nil
|
return migrations, nil
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// nolint
|
||||||
|
package rarchive
|
||||||
|
|
||||||
|
import (
|
||||||
|
"compress/gzip"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsTarGzipFile checks if the file at the given path is a gzipped tarball
|
||||||
|
// by attempting to open it as such.
|
||||||
|
func IsTarGzipFile(path string) bool {
|
||||||
|
f, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
// Attempt to create a gzip reader
|
||||||
|
gzr, err := gzip.NewReader(f)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer gzr.Close()
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// nolint
|
||||||
|
package rarchive
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsZipFile checks if the file at the given path is a ZIP file
|
||||||
|
// by verifying the magic number (the first few bytes of the file).
|
||||||
|
func IsZipFile(path string) bool {
|
||||||
|
f, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
// Read the first 4 bytes of the file to check the magic number
|
||||||
|
buf := make([]byte, 4)
|
||||||
|
_, err = f.Read(buf)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZIP files start with "PK\x03\x04"
|
||||||
|
return bytes.Equal(buf, []byte("PK\x03\x04"))
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// rtls is for creating TLS configurations for use by servers and clients.
|
||||||
|
// nolint
|
||||||
|
package rtls
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MTLSState indicates whether mutual TLS is enabled or disabled.
|
||||||
|
type MTLSState tls.ClientAuthType
|
||||||
|
|
||||||
|
// CreateClientConfig creates a new tls.Config for use by a client. The certFile and keyFile
|
||||||
|
// parameters are the paths to the client's certificate and key files, which will be used to
|
||||||
|
// authenticate the client to the server if mutual TLS is active. The caCertFile parameter
|
||||||
|
// is the path to the CA certificate file, which the client will use to verify any certificate
|
||||||
|
// presented by the server. serverName can also be set, informing the client which hostname
|
||||||
|
// should appear in the returned certificate. If noverify is true, the client will not verify
|
||||||
|
// the server's certificate.
|
||||||
|
func CreateClientConfig(certFile, keyFile, caCertFile, serverName string, noverify bool) (*tls.Config, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
config := createBaseTLSConfig(serverName, noverify)
|
||||||
|
if certFile != "" && keyFile != "" {
|
||||||
|
config.Certificates = make([]tls.Certificate, 1)
|
||||||
|
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if caCertFile != "" {
|
||||||
|
if err := setCertPool(caCertFile, &config.RootCAs); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createBaseTLSConfig(serverName string, noverify bool) *tls.Config {
|
||||||
|
return &tls.Config{
|
||||||
|
ServerName: serverName,
|
||||||
|
InsecureSkipVerify: noverify,
|
||||||
|
NextProtos: []string{"h2", "http/1.1"},
|
||||||
|
MinVersion: uint16(tls.VersionTLS12),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// setCertPool sets the CA certificate pool for the given file. It reads the file and
|
||||||
|
// appends the certificates to the pool. If the file cannot be read or the certificates
|
||||||
|
// cannot be appended, it returns an error.
|
||||||
|
func setCertPool(caCertFile string, pool **x509.CertPool) error {
|
||||||
|
asn1Data, err := os.ReadFile(caCertFile)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*pool = x509.NewCertPool()
|
||||||
|
ok := (*pool).AppendCertsFromPEM(asn1Data)
|
||||||
|
if !ok {
|
||||||
|
return errors.Errorf("failed to load CA certificate(s) for verification in %q", caCertFile)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
// nolint
|
||||||
|
package rtls
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CertReloader is a simple TLS certificate reloader. It loads the certificate
|
||||||
|
// and key files from the specified paths and reloads them if they have been
|
||||||
|
// modified since the last load.
|
||||||
|
type CertReloader struct {
|
||||||
|
certPath, keyPath string
|
||||||
|
modTime time.Time
|
||||||
|
logger *log.Logger
|
||||||
|
|
||||||
|
mu sync.RWMutex
|
||||||
|
cert *tls.Certificate
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCertificate returns the current certificate. It reloads the certificate
|
||||||
|
// if it has been modified since the last load. GetCertificate is thread-safe
|
||||||
|
// and if the cert has not changed this function will execute concurrently with
|
||||||
|
// other GetCertificate calls.
|
||||||
|
func (cr *CertReloader) GetCertificate() (*tls.Certificate, error) {
|
||||||
|
cr.mu.RLock()
|
||||||
|
latestTime, err := latestModTime(cr.certPath, cr.keyPath)
|
||||||
|
if err != nil || !latestTime.After(cr.modTime) {
|
||||||
|
defer cr.mu.RUnlock()
|
||||||
|
if err != nil {
|
||||||
|
cr.logger.Printf("failed to get latest modification time (%s), returning prior cert", err)
|
||||||
|
}
|
||||||
|
return cr.cert, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// The certificate or key file has changed, we need to reload. First we release
|
||||||
|
// the read lock, then we acquire a write lock to reload the certificate.
|
||||||
|
cr.mu.RUnlock()
|
||||||
|
cr.mu.Lock()
|
||||||
|
defer cr.mu.Unlock()
|
||||||
|
|
||||||
|
// Now that we have the write lock, we check again if the certificate has actually
|
||||||
|
// been updated by another concurrent call to this function.
|
||||||
|
latestTime, err = latestModTime(cr.certPath, cr.keyPath)
|
||||||
|
if err != nil || !latestTime.After(cr.modTime) {
|
||||||
|
if err != nil {
|
||||||
|
cr.logger.Printf("failed to get latest modification time (%s), returning prior cert", err)
|
||||||
|
}
|
||||||
|
return cr.cert, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pair, err := loadKeyPair(cr.certPath, cr.keyPath)
|
||||||
|
if err != nil {
|
||||||
|
cr.logger.Printf("failed to reload certificate (%s), returning prior cert", err)
|
||||||
|
return cr.cert, nil
|
||||||
|
}
|
||||||
|
cr.logger.Printf("reloading certificate at %s and key at %s", cr.certPath, cr.keyPath)
|
||||||
|
cr.cert = &pair
|
||||||
|
cr.modTime = latestTime
|
||||||
|
return cr.cert, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// loadKeyPair loads a TLS certificate and key pair from the given files.
|
||||||
|
// It simply wraps tls.LoadX509KeyPair, ensuring that the rest of the code
|
||||||
|
// uses the same function to load the key pair.
|
||||||
|
func loadKeyPair(certFile, keyFile string) (tls.Certificate, error) {
|
||||||
|
return tls.LoadX509KeyPair(certFile, keyFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
// latestModTime returns the latest modification time of the given files.
|
||||||
|
// It returns os.ErrNotExist if no files are provided.
|
||||||
|
func latestModTime(file ...string) (time.Time, error) {
|
||||||
|
if len(file) == 0 {
|
||||||
|
return time.Time{}, os.ErrNotExist
|
||||||
|
}
|
||||||
|
var latest time.Time
|
||||||
|
for _, f := range file {
|
||||||
|
info, err := os.Stat(f)
|
||||||
|
if err != nil {
|
||||||
|
return time.Time{}, err
|
||||||
|
}
|
||||||
|
if info.ModTime().After(latest) {
|
||||||
|
latest = info.ModTime()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return latest, nil
|
||||||
|
}
|
||||||
+65
-30
@@ -7,10 +7,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/rqlite/rqlite-disco-clients/dns"
|
|
||||||
"github.com/rqlite/rqlite-disco-clients/dnssrv"
|
|
||||||
"github.com/txix-open/isp-kit/config"
|
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@@ -20,16 +16,24 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rqlite/rqlite/v8/auth"
|
"isp-config-service/service/rqlite/internal/rarchive"
|
||||||
"github.com/rqlite/rqlite/v8/cluster"
|
"isp-config-service/service/rqlite/internal/rtls"
|
||||||
"github.com/rqlite/rqlite/v8/cmd"
|
|
||||||
"github.com/rqlite/rqlite/v8/db"
|
"github.com/rqlite/rqlite-disco-clients/dns"
|
||||||
"github.com/rqlite/rqlite/v8/extensions"
|
"github.com/rqlite/rqlite-disco-clients/dnssrv"
|
||||||
httpd "github.com/rqlite/rqlite/v8/http"
|
"github.com/rqlite/rqlite/v10/auth"
|
||||||
"github.com/rqlite/rqlite/v8/rarchive"
|
"github.com/rqlite/rqlite/v10/auto/backup"
|
||||||
"github.com/rqlite/rqlite/v8/rtls"
|
"github.com/rqlite/rqlite/v10/cluster"
|
||||||
"github.com/rqlite/rqlite/v8/store"
|
"github.com/rqlite/rqlite/v10/cmd"
|
||||||
"github.com/rqlite/rqlite/v8/tcp"
|
cmdpkg "github.com/rqlite/rqlite/v10/command"
|
||||||
|
"github.com/rqlite/rqlite/v10/db"
|
||||||
|
"github.com/rqlite/rqlite/v10/db/extensions"
|
||||||
|
httpd "github.com/rqlite/rqlite/v10/http"
|
||||||
|
"github.com/rqlite/rqlite/v10/proxy"
|
||||||
|
"github.com/rqlite/rqlite/v10/store"
|
||||||
|
"github.com/rqlite/rqlite/v10/tcp"
|
||||||
|
"github.com/txix-open/isp-kit/config"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const name = `rqlite`
|
const name = `rqlite`
|
||||||
@@ -46,6 +50,7 @@ func init() {
|
|||||||
|
|
||||||
type localConfig struct {
|
type localConfig struct {
|
||||||
Rqlite *Config
|
Rqlite *Config
|
||||||
|
Backup Backup
|
||||||
}
|
}
|
||||||
|
|
||||||
func main(ctx context.Context, r *Rqlite) error {
|
func main(ctx context.Context, r *Rqlite) error {
|
||||||
@@ -54,7 +59,6 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
cfg, err := ParseFlags(name, desc, &BuildInfo{
|
cfg, err := ParseFlags(name, desc, &BuildInfo{
|
||||||
Version: cmd.Version,
|
Version: cmd.Version,
|
||||||
Commit: cmd.Commit,
|
Commit: cmd.Commit,
|
||||||
Branch: cmd.Branch,
|
|
||||||
SQLiteVersion: db.DBVersion,
|
SQLiteVersion: db.DBVersion,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -79,8 +83,8 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
r.localHttpAddr = cfg.HTTPAddr
|
r.localHttpAddr = cfg.HTTPAddr
|
||||||
|
|
||||||
// Configure logging and pump out initial message.
|
// Configure logging and pump out initial message.
|
||||||
log.Printf("%s starting, version %s, SQLite %s, commit %s, branch %s, compiler (toolchain) %s, compiler (command) %s",
|
log.Printf("%s starting, version %s, SQLite %s, commit %s, compiler (toolchain) %s, compiler (command) %s",
|
||||||
name, cmd.Version, db.DBVersion, cmd.Commit, cmd.Branch, runtime.Compiler, cmd.CompilerCommand)
|
name, cmd.Version, db.DBVersion, cmd.Commit, runtime.Compiler, cmd.CompilerCommand)
|
||||||
log.Printf("%s, target architecture is %s, operating system target is %s", runtime.Version(),
|
log.Printf("%s, target architecture is %s, operating system target is %s", runtime.Version(),
|
||||||
runtime.GOARCH, runtime.GOOS)
|
runtime.GOARCH, runtime.GOOS)
|
||||||
log.Printf("launch command: %s", strings.Join(os.Args, " "))
|
log.Printf("launch command: %s", strings.Join(os.Args, " "))
|
||||||
@@ -120,7 +124,7 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
log.Fatalf("failed to create store: %s", err.Error())
|
log.Fatalf("failed to create store: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
r.store = str
|
r.storePtr.Store(str)
|
||||||
|
|
||||||
credStr, err := credentialsStore(r.credentials)
|
credStr, err := credentialsStore(r.credentials)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -147,7 +151,10 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to create cluster client: %s", err.Error())
|
log.Fatalf("failed to create cluster client: %s", err.Error())
|
||||||
}
|
}
|
||||||
httpServ, err := startHTTPService(cfg, str, clstrClient, credStr)
|
pxy := proxy.New(str, clstrClient)
|
||||||
|
pxy.SetAPIAddr(cfg.HTTPAdv)
|
||||||
|
|
||||||
|
httpServ, err := startHTTPService(cfg, str, clstrClient, credStr, pxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to start HTTP server: %s", err.Error())
|
log.Fatalf("failed to start HTTP server: %s", err.Error())
|
||||||
}
|
}
|
||||||
@@ -185,6 +192,15 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
h, p, _ := net.SplitHostPort(cfg.HTTPAdv)
|
h, p, _ := net.SplitHostPort(cfg.HTTPAdv)
|
||||||
log.Printf("connect using the command-line tool via 'rqlite -H %s -p %s'", h, p)
|
log.Printf("connect using the command-line tool via 'rqlite -H %s -p %s'", h, p)
|
||||||
|
|
||||||
|
// Start any requested auto-backups
|
||||||
|
backupSrv, err := startAutoBackups(mainCtx, &localCfg.Backup, str)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to start auto-backups: %s", err.Error())
|
||||||
|
}
|
||||||
|
if backupSrv != nil {
|
||||||
|
httpServ.RegisterStatus("auto_backups", backupSrv)
|
||||||
|
}
|
||||||
|
|
||||||
// Block until done.
|
// Block until done.
|
||||||
<-mainCtx.Done()
|
<-mainCtx.Done()
|
||||||
|
|
||||||
@@ -197,7 +213,7 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
remover := cluster.NewRemover(clstrClient, 5*time.Second, str)
|
remover := cluster.NewRemover(clstrClient, 5*time.Second, str)
|
||||||
remover.SetCredentials(cluster.CredentialsFor(credStr, cfg.JoinAs))
|
remover.SetCredentials(cluster.CredentialsFor(credStr, cfg.JoinAs))
|
||||||
log.Printf("initiating removal of this node from cluster before shutdown")
|
log.Printf("initiating removal of this node from cluster before shutdown")
|
||||||
if err := remover.Do(cfg.NodeID, true); err != nil {
|
if err := remover.Do(mainCtx, cfg.NodeID, true); err != nil {
|
||||||
log.Fatalf("failed to remove this node from cluster before shutdown: %s", err.Error())
|
log.Fatalf("failed to remove this node from cluster before shutdown: %s", err.Error())
|
||||||
}
|
}
|
||||||
log.Printf("removed this node successfully from cluster before shutdown")
|
log.Printf("removed this node successfully from cluster before shutdown")
|
||||||
@@ -209,7 +225,7 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
log.Printf("stepping down as Leader before shutdown")
|
log.Printf("stepping down as Leader before shutdown")
|
||||||
}
|
}
|
||||||
// Perform a stepdown, ignore any errors.
|
// Perform a stepdown, ignore any errors.
|
||||||
str.Stepdown(true)
|
str.Stepdown(true, "")
|
||||||
}
|
}
|
||||||
muxLn.Close()
|
muxLn.Close()
|
||||||
|
|
||||||
@@ -221,6 +237,27 @@ func main(ctx context.Context, r *Rqlite) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startAutoBackups(ctx context.Context, backupCfg *Backup, str *store.Store) (*backup.Uploader, error) {
|
||||||
|
if !backupCfg.Enable {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
backupCfg.SetParams()
|
||||||
|
b, err := json.Marshal(backupCfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Errorf("failed to marshal auto-backup settings: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
uCfg, sc, err := backup.NewStorageClient(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Errorf("failed to parse auto-backup file: %s", err.Error())
|
||||||
|
}
|
||||||
|
provider := store.NewProvider(str, uCfg.Vacuum, !uCfg.NoCompress)
|
||||||
|
u := backup.NewUploader(sc, provider, time.Duration(uCfg.Interval))
|
||||||
|
u.Start(ctx, str.IsLeader)
|
||||||
|
return u, nil
|
||||||
|
}
|
||||||
|
|
||||||
func evaluateAdvAddresses(cfg *config.Config) error {
|
func evaluateAdvAddresses(cfg *config.Config) error {
|
||||||
httpAdv := cfg.Optional().String("rqlite.HTTPAdv", "")
|
httpAdv := cfg.Optional().String("rqlite.HTTPAdv", "")
|
||||||
shouldEvalHttp := strings.Contains(httpAdv, "$HOSTNAME")
|
shouldEvalHttp := strings.Contains(httpAdv, "$HOSTNAME")
|
||||||
@@ -285,15 +322,14 @@ func createExtensionsStore(cfg *Config) (*extensions.Store, error) {
|
|||||||
|
|
||||||
func createStore(cfg *Config, ln *tcp.Layer, extensions []string) (*store.Store, error) {
|
func createStore(cfg *Config, ln *tcp.Layer, extensions []string) (*store.Store, error) {
|
||||||
dbConf := store.NewDBConfig()
|
dbConf := store.NewDBConfig()
|
||||||
dbConf.OnDiskPath = cfg.OnDiskPath
|
|
||||||
dbConf.FKConstraints = cfg.FKConstraints
|
dbConf.FKConstraints = cfg.FKConstraints
|
||||||
dbConf.Extensions = extensions
|
dbConf.Extensions = extensions
|
||||||
|
|
||||||
str := store.New(ln, &store.Config{
|
str := store.New(&store.Config{
|
||||||
DBConf: dbConf,
|
DBConf: dbConf,
|
||||||
Dir: cfg.DataPath,
|
Dir: cfg.DataPath,
|
||||||
ID: cfg.NodeID,
|
ID: cfg.NodeID,
|
||||||
})
|
}, ln)
|
||||||
|
|
||||||
// Set optional parameters on store.
|
// Set optional parameters on store.
|
||||||
str.RaftLogLevel = cfg.RaftLogLevel
|
str.RaftLogLevel = cfg.RaftLogLevel
|
||||||
@@ -320,9 +356,9 @@ func createStore(cfg *Config, ln *tcp.Layer, extensions []string) (*store.Store,
|
|||||||
return str, nil
|
return str, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startHTTPService(cfg *Config, str *store.Store, cltr *cluster.Client, credStr *auth.CredentialsStore) (*httpd.Service, error) {
|
func startHTTPService(cfg *Config, str *store.Store, cltr *cluster.Client, credStr *auth.CredentialsStore, pxy *proxy.Proxy) (*httpd.Service, error) {
|
||||||
// Create HTTP server and load authentication information.
|
// Create HTTP server and load authentication information.
|
||||||
s := httpd.New(cfg.HTTPAddr, str, cltr, credStr)
|
s := httpd.New(cfg.HTTPAddr, str, cltr, pxy, credStr)
|
||||||
|
|
||||||
s.CACertFile = cfg.HTTPx509CACert
|
s.CACertFile = cfg.HTTPx509CACert
|
||||||
s.CertFile = cfg.HTTPx509Cert
|
s.CertFile = cfg.HTTPx509Cert
|
||||||
@@ -334,7 +370,6 @@ func startHTTPService(cfg *Config, str *store.Store, cltr *cluster.Client, credS
|
|||||||
s.DefaultQueueTx = cfg.WriteQueueTx
|
s.DefaultQueueTx = cfg.WriteQueueTx
|
||||||
s.BuildInfo = map[string]interface{}{
|
s.BuildInfo = map[string]interface{}{
|
||||||
"commit": cmd.Commit,
|
"commit": cmd.Commit,
|
||||||
"branch": cmd.Branch,
|
|
||||||
"version": cmd.Version,
|
"version": cmd.Version,
|
||||||
"compiler_toolchain": runtime.Compiler,
|
"compiler_toolchain": runtime.Compiler,
|
||||||
"compiler_command": cmd.CompilerCommand,
|
"compiler_command": cmd.CompilerCommand,
|
||||||
@@ -362,12 +397,12 @@ func startNodeMux(cfg *Config, ln net.Listener) (*tcp.Mux, error) {
|
|||||||
}
|
}
|
||||||
if cfg.NodeVerifyClient {
|
if cfg.NodeVerifyClient {
|
||||||
b.WriteString(", mutual TLS enabled")
|
b.WriteString(", mutual TLS enabled")
|
||||||
|
mux, err = tcp.NewMutualTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key, cfg.NodeX509CACert, cfg.NodeVerifyCommonName)
|
||||||
} else {
|
} else {
|
||||||
b.WriteString(", mutual TLS disabled")
|
b.WriteString(", mutual TLS disabled")
|
||||||
|
mux, err = tcp.NewTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key)
|
||||||
}
|
}
|
||||||
log.Println(b.String())
|
log.Println(b.String())
|
||||||
mux, err = tcp.NewTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key, cfg.NodeX509CACert,
|
|
||||||
cfg.NoNodeVerify, cfg.NodeVerifyClient)
|
|
||||||
} else {
|
} else {
|
||||||
mux, err = tcp.NewMux(ln, adv)
|
mux, err = tcp.NewMux(ln, adv)
|
||||||
}
|
}
|
||||||
@@ -437,7 +472,7 @@ func createCluster(ctx context.Context, cfg *Config, hasPeers bool, client *clus
|
|||||||
leader, _ := str.LeaderAddr()
|
leader, _ := str.LeaderAddr()
|
||||||
return leader != ""
|
return leader != ""
|
||||||
}
|
}
|
||||||
clusterSuf := cluster.VoterSuffrage(!cfg.RaftNonVoter)
|
clusterSuf := cmdpkg.SuffrageNonVoterFromBool(cfg.RaftNonVoter)
|
||||||
|
|
||||||
joiner := cluster.NewJoiner(client, cfg.JoinAttempts, cfg.JoinInterval)
|
joiner := cluster.NewJoiner(client, cfg.JoinAttempts, cfg.JoinInterval)
|
||||||
joiner.SetCredentials(cluster.CredentialsFor(credStr, cfg.JoinAs))
|
joiner.SetCredentials(cluster.CredentialsFor(credStr, cfg.JoinAs))
|
||||||
|
|||||||
+13
-10
@@ -4,14 +4,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/rqlite/rqlite/v8/auth"
|
"sync/atomic"
|
||||||
"github.com/txix-open/isp-kit/http/httpcli"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/rqlite/rqlite/v10/auth"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpcli"
|
||||||
|
|
||||||
_ "github.com/rqlite/gorqlite/stdlib"
|
_ "github.com/rqlite/gorqlite/stdlib"
|
||||||
"github.com/rqlite/rqlite/v8/store"
|
"github.com/rqlite/rqlite/v10/store"
|
||||||
"github.com/txix-open/isp-kit/config"
|
"github.com/txix-open/isp-kit/config"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -24,7 +26,7 @@ type Rqlite struct {
|
|||||||
credentials []auth.Credential
|
credentials []auth.Credential
|
||||||
|
|
||||||
localHttpAddr string
|
localHttpAddr string
|
||||||
store *store.Store
|
storePtr *atomic.Pointer[store.Store]
|
||||||
closed chan struct{}
|
closed chan struct{}
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
}
|
}
|
||||||
@@ -39,6 +41,7 @@ func New(
|
|||||||
internalClientCredential: internalClientCredential,
|
internalClientCredential: internalClientCredential,
|
||||||
credentials: credentials,
|
credentials: credentials,
|
||||||
closed: make(chan struct{}),
|
closed: make(chan struct{}),
|
||||||
|
storePtr: &atomic.Pointer[store.Store]{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,10 +53,10 @@ func (r *Rqlite) Run(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Rqlite) WaitForLeader(timeout time.Duration) error {
|
func (r *Rqlite) WaitForLeader(timeout time.Duration) error {
|
||||||
if r.store == nil {
|
if r.storePtr.Load() == nil {
|
||||||
return ErrNotRun
|
return ErrNotRun
|
||||||
}
|
}
|
||||||
_, err := r.store.WaitForLeader(timeout)
|
_, err := r.storePtr.Load().WaitForLeader(timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "wait for leader in rqlite store")
|
return errors.WithMessage(err, "wait for leader in rqlite store")
|
||||||
}
|
}
|
||||||
@@ -61,14 +64,14 @@ func (r *Rqlite) WaitForLeader(timeout time.Duration) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Rqlite) IsLeader() bool {
|
func (r *Rqlite) IsLeader() bool {
|
||||||
if r.store == nil {
|
if r.storePtr.Load() == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return r.store.IsLeader()
|
return r.storePtr.Load().IsLeader()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Rqlite) SqlDB() (*sql.DB, error) {
|
func (r *Rqlite) SqlDB() (*sql.DB, error) {
|
||||||
if r.store == nil {
|
if r.storePtr.Load() == nil {
|
||||||
return nil, ErrNotRun
|
return nil, ErrNotRun
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+49
-15
@@ -5,28 +5,30 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/pressly/goose/v3"
|
|
||||||
"github.com/txix-open/isp-kit/app"
|
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
|
||||||
"github.com/txix-open/isp-kit/dbx/migration"
|
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
|
||||||
"github.com/txix-open/isp-kit/http"
|
|
||||||
"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/observability/sentry"
|
|
||||||
"isp-config-service/assembly"
|
"isp-config-service/assembly"
|
||||||
"isp-config-service/conf"
|
"isp-config-service/conf"
|
||||||
"isp-config-service/middlewares"
|
"isp-config-service/middlewares"
|
||||||
"isp-config-service/service/rqlite"
|
"isp-config-service/service/rqlite"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
"isp-config-service/service/rqlite/goose_store"
|
"isp-config-service/service/rqlite/goose_store"
|
||||||
|
|
||||||
|
"github.com/pressly/goose/v3"
|
||||||
|
"github.com/txix-open/isp-kit/app"
|
||||||
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/dbx/migration"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/grpc"
|
||||||
|
"github.com/txix-open/isp-kit/http"
|
||||||
|
"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/observability/sentry"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
waitForLeaderTimeout = 30 * time.Second
|
waitForLeaderTimeout = 180 * time.Second
|
||||||
|
waitingLogsTimeout = 30 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
@@ -35,11 +37,12 @@ type Service struct {
|
|||||||
rqlite *rqlite.Rqlite
|
rqlite *rqlite.Rqlite
|
||||||
grpcSrv *grpc.Server
|
grpcSrv *grpc.Server
|
||||||
httpSrv *http.Server
|
httpSrv *http.Server
|
||||||
clusterCli *cluster.Client
|
clusterCli bootstrap.ClusterClient
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
|
|
||||||
// initialized in Run
|
// initialized in Run
|
||||||
locatorConfig *assembly.Config
|
locatorConfig *assembly.Config
|
||||||
|
db db.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(boot *bootstrap.Bootstrap) (*Service, error) {
|
func New(boot *bootstrap.Bootstrap) (*Service, error) {
|
||||||
@@ -97,8 +100,11 @@ func (s *Service) Run(ctx context.Context) error {
|
|||||||
}()
|
}()
|
||||||
time.Sleep(1 * time.Second) // optimistically wait for store initialization
|
time.Sleep(1 * time.Second) // optimistically wait for store initialization
|
||||||
|
|
||||||
s.logger.Debug(ctx, fmt.Sprintf("waiting for cluster startup for %s...", waitForLeaderTimeout))
|
waitingCtx, waitingDone := context.WithCancel(ctx)
|
||||||
|
go s.writeWaitingLogs(waitingCtx)
|
||||||
|
|
||||||
err := s.rqlite.WaitForLeader(waitForLeaderTimeout)
|
err := s.rqlite.WaitForLeader(waitForLeaderTimeout)
|
||||||
|
waitingDone()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "wait for leader")
|
return errors.WithMessage(err, "wait for leader")
|
||||||
}
|
}
|
||||||
@@ -112,6 +118,7 @@ func (s *Service) Run(ctx context.Context) error {
|
|||||||
} else {
|
} else {
|
||||||
s.logger.Debug(ctx, "is not a leader")
|
s.logger.Debug(ctx, "is not a leader")
|
||||||
}
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
rqliteClient := httpclix.Default(httpcli.WithMiddlewares(middlewares.SqlOperationMiddleware()))
|
rqliteClient := httpclix.Default(httpcli.WithMiddlewares(middlewares.SqlOperationMiddleware()))
|
||||||
rqliteClient.GlobalRequestConfig().BaseUrl = s.rqlite.LocalHttpAddr()
|
rqliteClient.GlobalRequestConfig().BaseUrl = s.rqlite.LocalHttpAddr()
|
||||||
@@ -123,6 +130,7 @@ func (s *Service) Run(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "dial to embedded rqlite")
|
return errors.WithMessage(err, "dial to embedded rqlite")
|
||||||
}
|
}
|
||||||
|
s.db = db
|
||||||
|
|
||||||
cfg := assembly.LocalConfig{
|
cfg := assembly.LocalConfig{
|
||||||
Local: s.cfg,
|
Local: s.cfg,
|
||||||
@@ -131,11 +139,16 @@ func (s *Service) Run(ctx context.Context) error {
|
|||||||
s.locatorConfig = assembly.NewLocator(db, s.rqlite, cfg, s.logger).Config()
|
s.locatorConfig = assembly.NewLocator(db, s.rqlite, cfg, s.logger).Config()
|
||||||
s.grpcSrv.Upgrade(s.locatorConfig.GrpcMux)
|
s.grpcSrv.Upgrade(s.locatorConfig.GrpcMux)
|
||||||
s.httpSrv.Upgrade(s.locatorConfig.HttpMux)
|
s.httpSrv.Upgrade(s.locatorConfig.HttpMux)
|
||||||
|
s.boot.InfraServer.Handle("/internal/metrics/autodiscovery", s.locatorConfig.MetricsAdHandler)
|
||||||
|
|
||||||
s.locatorConfig.HandleEventWorker.Run(ctx)
|
s.locatorConfig.HandleEventWorker.Run(ctx)
|
||||||
s.locatorConfig.CleanEventWorker.Run(ctx)
|
s.locatorConfig.CleanEventWorker.Run(ctx)
|
||||||
s.locatorConfig.CleanPhantomBackendWorker.Run(ctx)
|
s.locatorConfig.CleanPhantomBackendWorker.Run(ctx)
|
||||||
|
|
||||||
|
if cfg.Local.Backup.Enable {
|
||||||
|
s.locatorConfig.CleanBackupsWorker.Run(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
s.logger.Debug(ctx, fmt.Sprintf("starting grpc server on %s", s.boot.BindingAddress))
|
s.logger.Debug(ctx, fmt.Sprintf("starting grpc server on %s", s.boot.BindingAddress))
|
||||||
err := s.grpcSrv.ListenAndServe(s.boot.BindingAddress)
|
err := s.grpcSrv.ListenAndServe(s.boot.BindingAddress)
|
||||||
@@ -198,6 +211,11 @@ func (s *Service) Closers() []app.Closer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nolint:ireturn
|
||||||
|
func (s *Service) Db() db.DB {
|
||||||
|
return s.db
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Service) leaderStartup(ctx context.Context) error {
|
func (s *Service) leaderStartup(ctx context.Context) error {
|
||||||
db, err := s.rqlite.SqlDB()
|
db, err := s.rqlite.SqlDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -223,3 +241,19 @@ func internalClientCredentials(cfg conf.Local) (*httpcli.BasicAuth, error) {
|
|||||||
}
|
}
|
||||||
return nil, errors.Errorf("internal client credential '%s' not found", cfg.InternalClientCredential)
|
return nil, errors.Errorf("internal client credential '%s' not found", cfg.InternalClientCredential)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) writeWaitingLogs(ctx context.Context) {
|
||||||
|
s.logger.Debug(ctx, fmt.Sprintf("waiting for cluster startup for %s...", waitForLeaderTimeout))
|
||||||
|
|
||||||
|
t := time.NewTicker(waitingLogsTimeout)
|
||||||
|
defer t.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return
|
||||||
|
case <-t.C:
|
||||||
|
s.logger.Debug(ctx, fmt.Sprintf("continue waiting for cluster startup for %s...", waitForLeaderTimeout))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+123
-43
@@ -2,14 +2,18 @@ package subscription
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/txix-open/etp/v4"
|
"github.com/txix-open/etp/v4"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"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/json"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/helpers"
|
"isp-config-service/helpers"
|
||||||
|
"isp-config-service/service/module/leader"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,7 +23,7 @@ type ModuleRepo interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BackendRepo interface {
|
type BackendRepo interface {
|
||||||
GetByModuleId(ctx context.Context, moduleId string) ([]entity.Backend, error)
|
GetForLeaderElection(ctx context.Context, moduleId string) ([]entity.Backend, error)
|
||||||
All(ctx context.Context) ([]entity.Backend, error)
|
All(ctx context.Context) ([]entity.Backend, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,17 +31,22 @@ type ConfigRepo interface {
|
|||||||
GetActive(ctx context.Context, moduleId string) (*entity.Config, error)
|
GetActive(ctx context.Context, moduleId string) (*entity.Config, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VariableService interface {
|
||||||
|
RenderConfig(ctx context.Context, input []byte) ([]byte, error)
|
||||||
|
}
|
||||||
|
|
||||||
type Emitter interface {
|
type Emitter interface {
|
||||||
Emit(ctx context.Context, conn *etp.Conn, event string, data []byte)
|
Emit(ctx context.Context, conn *etp.Conn, event string, data []byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
moduleRepo ModuleRepo
|
moduleRepo ModuleRepo
|
||||||
backendRepo BackendRepo
|
backendRepo BackendRepo
|
||||||
configRepo ConfigRepo
|
configRepo ConfigRepo
|
||||||
rooms *etp.Rooms
|
rooms *etp.Rooms
|
||||||
emitter Emitter
|
emitter Emitter
|
||||||
logger log.Logger
|
variableService VariableService
|
||||||
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewService(
|
func NewService(
|
||||||
@@ -46,15 +55,17 @@ func NewService(
|
|||||||
configRepo ConfigRepo,
|
configRepo ConfigRepo,
|
||||||
rooms *etp.Rooms,
|
rooms *etp.Rooms,
|
||||||
emitter Emitter,
|
emitter Emitter,
|
||||||
|
variableService VariableService,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
) Service {
|
) Service {
|
||||||
return Service{
|
return Service{
|
||||||
moduleRepo: moduleRepo,
|
moduleRepo: moduleRepo,
|
||||||
backendRepo: backendRepo,
|
backendRepo: backendRepo,
|
||||||
configRepo: configRepo,
|
configRepo: configRepo,
|
||||||
rooms: rooms,
|
rooms: rooms,
|
||||||
emitter: emitter,
|
emitter: emitter,
|
||||||
logger: logger,
|
variableService: variableService,
|
||||||
|
logger: logger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,10 +84,14 @@ func (s Service) NotifyConfigChanged(ctx context.Context, moduleId string) error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "get active config")
|
return errors.WithMessage(err, "get active config")
|
||||||
}
|
}
|
||||||
|
configData, err := s.variableService.RenderConfig(ctx, config.Data)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "render config")
|
||||||
|
}
|
||||||
|
|
||||||
for _, conn := range conns {
|
for _, conn := range conns {
|
||||||
go func() {
|
go func() {
|
||||||
s.emitter.Emit(ctx, conn, cluster.ConfigSendConfigChanged, config.Data)
|
s.emitter.Emit(ctx, conn, cluster.ConfigSendConfigChanged, configData)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,32 +150,6 @@ func (s Service) NotifyBackendsChanged(ctx context.Context, moduleId string) err
|
|||||||
return s.notifyBackendsChanged(ctx, moduleId, module.Name, conns)
|
return s.notifyBackendsChanged(ctx, moduleId, module.Name, conns)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Service) notifyBackendsChanged(
|
|
||||||
ctx context.Context,
|
|
||||||
moduleId string,
|
|
||||||
moduleName string,
|
|
||||||
conns []*etp.Conn,
|
|
||||||
) error {
|
|
||||||
ctx = db.NoneConsistency().ToContext(ctx)
|
|
||||||
backends, err := s.backendRepo.GetByModuleId(ctx, moduleId)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "get backends by module id")
|
|
||||||
}
|
|
||||||
|
|
||||||
addresses := make([]cluster.AddressConfiguration, 0)
|
|
||||||
for _, backend := range backends {
|
|
||||||
addr, err := helpers.SplitAddress(backend)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "split address")
|
|
||||||
}
|
|
||||||
addresses = append(addresses, addr)
|
|
||||||
}
|
|
||||||
|
|
||||||
s.emitModuleConnectedEvent(ctx, conns, moduleName, addresses)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Service) SubscribeToRoutingChanges(ctx context.Context, conn *etp.Conn) error {
|
func (s Service) SubscribeToRoutingChanges(ctx context.Context, conn *etp.Conn) error {
|
||||||
err := s.notifyRoutingChanged(ctx, cluster.ConfigSendRoutesWhenConnected, []*etp.Conn{conn})
|
err := s.notifyRoutingChanged(ctx, cluster.ConfigSendRoutesWhenConnected, []*etp.Conn{conn})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -180,6 +169,60 @@ func (s Service) NotifyRoutingChanged(ctx context.Context) error {
|
|||||||
return s.notifyRoutingChanged(ctx, cluster.ConfigSendRoutesChanged, conns)
|
return s.notifyRoutingChanged(ctx, cluster.ConfigSendRoutesChanged, conns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s Service) notifyBackendsChanged(
|
||||||
|
ctx context.Context,
|
||||||
|
moduleId string,
|
||||||
|
moduleName string,
|
||||||
|
conns []*etp.Conn,
|
||||||
|
) error {
|
||||||
|
ctx = db.NoneConsistency().ToContext(ctx)
|
||||||
|
backends, err := s.backendRepo.GetForLeaderElection(ctx, moduleId)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get backends by module id")
|
||||||
|
}
|
||||||
|
|
||||||
|
election := leader.Derive(backends)
|
||||||
|
if election.HasElection {
|
||||||
|
return s.emitLeaderAddress(ctx, moduleName, election, conns)
|
||||||
|
}
|
||||||
|
|
||||||
|
addresses, err := moduleAddresses(backends)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "split address")
|
||||||
|
}
|
||||||
|
|
||||||
|
s.emitModuleConnectedEvent(ctx, conns, moduleName, addresses)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) emitLeaderAddress(
|
||||||
|
ctx context.Context,
|
||||||
|
moduleName string,
|
||||||
|
election leader.Result,
|
||||||
|
conns []*etp.Conn,
|
||||||
|
) error {
|
||||||
|
addresses := make([]cluster.AddressConfiguration, 0, 1)
|
||||||
|
leaderAddress := ""
|
||||||
|
if election.Found {
|
||||||
|
address, err := helpers.SplitAddress(election.Leader)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "split address")
|
||||||
|
}
|
||||||
|
address.IsModuleLeader = true
|
||||||
|
addresses = append(addresses, address)
|
||||||
|
leaderAddress = election.Leader.Address
|
||||||
|
}
|
||||||
|
|
||||||
|
s.logger.Info(ctx, "module address list narrowed to the leader",
|
||||||
|
log.String("moduleName", moduleName),
|
||||||
|
log.String("leaderAddress", leaderAddress))
|
||||||
|
|
||||||
|
s.emitModuleConnectedEvent(ctx, conns, moduleName, addresses)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s Service) notifyRoutingChanged(ctx context.Context, event string, conns []*etp.Conn) error {
|
func (s Service) notifyRoutingChanged(ctx context.Context, event string, conns []*etp.Conn) error {
|
||||||
ctx = db.NoneConsistency().ToContext(ctx)
|
ctx = db.NoneConsistency().ToContext(ctx)
|
||||||
backends, err := s.backendRepo.All(ctx)
|
backends, err := s.backendRepo.All(ctx)
|
||||||
@@ -187,22 +230,46 @@ func (s Service) notifyRoutingChanged(ctx context.Context, event string, conns [
|
|||||||
return errors.WithMessage(err, "get all backends")
|
return errors.WithMessage(err, "get all backends")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elections := leader.DeriveByModule(backends)
|
||||||
|
moduleLeaders := make([]string, 0, len(elections))
|
||||||
|
|
||||||
routingConfig := cluster.RoutingConfig{}
|
routingConfig := cluster.RoutingConfig{}
|
||||||
for _, backend := range backends {
|
for _, backend := range backends {
|
||||||
addr, err := helpers.SplitAddress(backend)
|
election := elections[backend.ModuleId]
|
||||||
|
if election.HasElection && election.Leader.WsConnectionId != backend.WsConnectionId {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
address, err := helpers.SplitAddress(backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "split address")
|
return errors.WithMessage(err, "split address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if election.HasElection {
|
||||||
|
moduleLeaders = append(moduleLeaders, backend.ModuleName+"="+backend.Address)
|
||||||
|
}
|
||||||
|
|
||||||
declaration := cluster.BackendDeclaration{
|
declaration := cluster.BackendDeclaration{
|
||||||
ModuleName: backend.ModuleName,
|
ModuleName: backend.ModuleName,
|
||||||
Version: backend.Version,
|
Version: backend.Version,
|
||||||
LibVersion: backend.LibVersion,
|
LibVersion: backend.LibVersion,
|
||||||
|
Transport: backend.Transport,
|
||||||
Endpoints: backend.Endpoints.Value,
|
Endpoints: backend.Endpoints.Value,
|
||||||
RequiredModules: backend.RequiredModules.Value,
|
RequiredModules: backend.RequiredModules.Value,
|
||||||
Address: addr,
|
Address: cluster.AddressConfiguration{
|
||||||
|
IP: address.IP,
|
||||||
|
Port: address.Port,
|
||||||
|
IsModuleLeader: election.HasElection,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
routingConfig = append(routingConfig, declaration)
|
routingConfig = append(routingConfig, declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(moduleLeaders) > 0 {
|
||||||
|
s.logger.Info(ctx, "routing map publishes module leaders",
|
||||||
|
log.String("moduleLeaders", strings.Join(moduleLeaders, ",")))
|
||||||
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(routingConfig)
|
data, err := json.Marshal(routingConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "marshal routing config")
|
return errors.WithMessage(err, "marshal routing config")
|
||||||
@@ -231,3 +298,16 @@ func (s Service) emitModuleConnectedEvent(
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAddresses(backends []entity.Backend) ([]cluster.AddressConfiguration, error) {
|
||||||
|
addresses := make([]cluster.AddressConfiguration, 0, len(backends))
|
||||||
|
for i := range slices.Backward(backends) {
|
||||||
|
address, err := helpers.SplitAddress(backends[i])
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "split address")
|
||||||
|
}
|
||||||
|
addresses = append(addresses, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
return addresses, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,189 @@
|
|||||||
|
package subscription_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"isp-config-service/entity"
|
||||||
|
"isp-config-service/service/subscription"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/etp/v4"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
testModuleId = "test-module-id"
|
||||||
|
testModuleName = "test-module"
|
||||||
|
|
||||||
|
leaderConnId = "conn-1"
|
||||||
|
followerConnId = "conn-2"
|
||||||
|
|
||||||
|
leaderAddress = "10.0.0.1:9000"
|
||||||
|
successorAddress = "10.0.0.2:9000"
|
||||||
|
plainAddress = "10.0.0.3:9000"
|
||||||
|
)
|
||||||
|
|
||||||
|
type storedLog struct {
|
||||||
|
message any
|
||||||
|
fields map[string]string
|
||||||
|
}
|
||||||
|
|
||||||
|
type loggerSpy struct {
|
||||||
|
infos []storedLog
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Info(ctx context.Context, message any, fields ...log.Field) {
|
||||||
|
entry := storedLog{
|
||||||
|
message: message,
|
||||||
|
fields: make(map[string]string, len(fields)),
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
entry.fields[field.Key] = field.String
|
||||||
|
}
|
||||||
|
l.infos = append(l.infos, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Error(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Warn(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
func (l *loggerSpy) Debug(ctx context.Context, message any, fields ...log.Field) {}
|
||||||
|
|
||||||
|
type moduleRepoSpy struct{}
|
||||||
|
|
||||||
|
func (r *moduleRepoSpy) GetByNames(ctx context.Context, names []string) ([]entity.Module, error) {
|
||||||
|
return []entity.Module{{Id: testModuleId, Name: testModuleName}}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *moduleRepoSpy) GetById(ctx context.Context, id string) (*entity.Module, error) {
|
||||||
|
return &entity.Module{Id: testModuleId, Name: testModuleName}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type backendRepoSpy struct {
|
||||||
|
forLeaderElection []entity.Backend
|
||||||
|
all []entity.Backend
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *backendRepoSpy) GetForLeaderElection(ctx context.Context, moduleId string) ([]entity.Backend, error) {
|
||||||
|
return r.forLeaderElection, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *backendRepoSpy) All(ctx context.Context) ([]entity.Backend, error) {
|
||||||
|
return r.all, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type configRepoSpy struct{}
|
||||||
|
|
||||||
|
func (r *configRepoSpy) GetActive(ctx context.Context, moduleId string) (*entity.Config, error) {
|
||||||
|
return &entity.Config{ModuleId: moduleId}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type variableServiceSpy struct{}
|
||||||
|
|
||||||
|
func (s *variableServiceSpy) RenderConfig(ctx context.Context, input []byte) ([]byte, error) {
|
||||||
|
return input, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type emitterSpy struct{}
|
||||||
|
|
||||||
|
func (e *emitterSpy) Emit(ctx context.Context, conn *etp.Conn, event string, data []byte) {}
|
||||||
|
|
||||||
|
// The on-call engineer answers "who is accepting sessions of this module" from the log of the node that
|
||||||
|
// emitted the address list: the same derivation the subscriber received, logged where it is published.
|
||||||
|
func TestNotifyBackendsChangedLogsTheLeaderItPublishes(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
logger := &loggerSpy{}
|
||||||
|
rooms := etp.NewServer().Rooms()
|
||||||
|
rooms.Join(&etp.Conn{}, subscription.BackendsChangingRoom(testModuleName))
|
||||||
|
service := newService(logger, rooms, &backendRepoSpy{
|
||||||
|
forLeaderElection: []entity.Backend{
|
||||||
|
electedInstance(leaderConnId, leaderAddress),
|
||||||
|
electedInstance(followerConnId, successorAddress),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
err := service.NotifyBackendsChanged(t.Context(), testModuleId)
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Len(logger.infos, 1)
|
||||||
|
require.Equal("module address list narrowed to the leader", logger.infos[0].message)
|
||||||
|
require.Equal(testModuleName, logger.infos[0].fields["moduleName"])
|
||||||
|
require.Equal(leaderAddress, logger.infos[0].fields["leaderAddress"],
|
||||||
|
"the logged leader is the oldest elected instance, the one the subscriber received")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotifyRoutingChangedLogsPublishedLeaders(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
logger := &loggerSpy{}
|
||||||
|
rooms := etp.NewServer().Rooms()
|
||||||
|
rooms.Join(&etp.Conn{}, subscription.RoutingChangingRoom())
|
||||||
|
service := newService(logger, rooms, &backendRepoSpy{
|
||||||
|
all: []entity.Backend{
|
||||||
|
electedInstance(leaderConnId, leaderAddress),
|
||||||
|
electedInstance(followerConnId, successorAddress),
|
||||||
|
plainInstance("conn-3", plainAddress),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
err := service.NotifyRoutingChanged(t.Context())
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Len(logger.infos, 1, "one summary line per routing rebuild")
|
||||||
|
require.Equal("routing map publishes module leaders", logger.infos[0].message)
|
||||||
|
require.Equal(testModuleName+"="+leaderAddress, logger.infos[0].fields["moduleLeaders"],
|
||||||
|
"only the elected module and only its leader are published, the plain module is not listed")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNotifyRoutingChangedWithoutElectionLogsNothing(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
logger := &loggerSpy{}
|
||||||
|
rooms := etp.NewServer().Rooms()
|
||||||
|
rooms.Join(&etp.Conn{}, subscription.RoutingChangingRoom())
|
||||||
|
service := newService(logger, rooms, &backendRepoSpy{
|
||||||
|
all: []entity.Backend{plainInstance("conn-3", plainAddress)},
|
||||||
|
})
|
||||||
|
|
||||||
|
err := service.NotifyRoutingChanged(t.Context())
|
||||||
|
|
||||||
|
require.NoError(err)
|
||||||
|
require.Empty(logger.infos, "modules without election keep the previous behaviour, including the log")
|
||||||
|
}
|
||||||
|
|
||||||
|
func electedInstance(connId string, address string) entity.Backend {
|
||||||
|
return entity.Backend{
|
||||||
|
WsConnectionId: connId,
|
||||||
|
ModuleId: testModuleId,
|
||||||
|
ModuleName: testModuleName,
|
||||||
|
Address: address,
|
||||||
|
ModuleLeaderMode: cluster.ModuleLeaderModeRequestElection,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func plainInstance(connId string, address string) entity.Backend {
|
||||||
|
return entity.Backend{
|
||||||
|
WsConnectionId: connId,
|
||||||
|
ModuleId: "plain-module-id",
|
||||||
|
ModuleName: "plain-module",
|
||||||
|
Address: address,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newService(logger log.Logger, rooms *etp.Rooms, backendRepo subscription.BackendRepo) subscription.Service {
|
||||||
|
return subscription.NewService(
|
||||||
|
&moduleRepoSpy{},
|
||||||
|
backendRepo,
|
||||||
|
&configRepoSpy{},
|
||||||
|
rooms,
|
||||||
|
&emitterSpy{},
|
||||||
|
&variableServiceSpy{},
|
||||||
|
logger,
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,327 @@
|
|||||||
|
package variable
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"isp-config-service/domain"
|
||||||
|
"isp-config-service/entity"
|
||||||
|
"isp-config-service/entity/xtypes"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Repo interface {
|
||||||
|
All(ctx context.Context) ([]entity.Variable, error)
|
||||||
|
GetByName(ctx context.Context, name string) (*entity.Variable, error)
|
||||||
|
Insert(ctx context.Context, variable entity.Variable) error
|
||||||
|
Update(ctx context.Context, variable entity.Variable) (bool, error)
|
||||||
|
Upsert(ctx context.Context, variables []entity.Variable) error
|
||||||
|
Delete(ctx context.Context, name string) (bool, error)
|
||||||
|
UpsertLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigRepo interface {
|
||||||
|
GetMetaByVariables(ctx context.Context, variables []string) (map[string][]entity.ConfigMetaWithVariable, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type EventRepo interface {
|
||||||
|
Insert(ctx context.Context, event entity.Event) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
repo Repo
|
||||||
|
configRepo ConfigRepo
|
||||||
|
eventRepo EventRepo
|
||||||
|
stringToIntRegexp *regexp.Regexp
|
||||||
|
variableRegexp *regexp.Regexp
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewService(
|
||||||
|
repo Repo,
|
||||||
|
configRepo ConfigRepo,
|
||||||
|
eventRepo EventRepo,
|
||||||
|
) Service {
|
||||||
|
return Service{
|
||||||
|
repo: repo,
|
||||||
|
configRepo: configRepo,
|
||||||
|
eventRepo: eventRepo,
|
||||||
|
stringToIntRegexp: regexp.MustCompile(`"_ToInt\((\d+)\)"`),
|
||||||
|
variableRegexp: regexp.MustCompile(`_Var\((.*?)\)`),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) All(ctx context.Context) ([]domain.Variable, error) {
|
||||||
|
variables, err := s.repo.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get all variables")
|
||||||
|
}
|
||||||
|
if len(variables) == 0 {
|
||||||
|
return []domain.Variable{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
varNames := make([]string, 0, len(variables))
|
||||||
|
for _, v := range variables {
|
||||||
|
varNames = append(varNames, v.Name)
|
||||||
|
}
|
||||||
|
metaByVariables, err := s.configRepo.GetMetaByVariables(ctx, varNames)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get meta by variables")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]domain.Variable, 0, len(variables))
|
||||||
|
for _, v := range variables {
|
||||||
|
result = append(result, s.toDto(v, metaByVariables))
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) GetByName(ctx context.Context, name string) (*domain.Variable, error) {
|
||||||
|
variable, err := s.repo.GetByName(ctx, name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get variable by name")
|
||||||
|
}
|
||||||
|
if variable == nil {
|
||||||
|
return nil, entity.ErrVariableNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
metaByVariables, err := s.configRepo.GetMetaByVariables(ctx, []string{name})
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get meta by variables")
|
||||||
|
}
|
||||||
|
|
||||||
|
return new(s.toDto(*variable, metaByVariables)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Create(ctx context.Context, req domain.CreateVariableRequest) error {
|
||||||
|
variable := entity.Variable{
|
||||||
|
Name: req.Name,
|
||||||
|
Description: req.Description,
|
||||||
|
Type: req.Type,
|
||||||
|
Value: req.Value,
|
||||||
|
}
|
||||||
|
err := s.repo.Insert(ctx, variable)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "insert variable")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Update(ctx context.Context, req domain.UpdateVariableRequest) error {
|
||||||
|
variable := entity.Variable{
|
||||||
|
Name: req.Name,
|
||||||
|
Description: req.Description,
|
||||||
|
Value: req.Value,
|
||||||
|
}
|
||||||
|
updated, err := s.repo.Update(ctx, variable)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "update variable")
|
||||||
|
}
|
||||||
|
if !updated {
|
||||||
|
return entity.ErrVariableNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.syncConfigsByVariables(ctx, []string{variable.Name})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "sync configs by variables")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Upsert(ctx context.Context, req []domain.UpsertVariableRequest) error {
|
||||||
|
if len(req) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
variables := make([]entity.Variable, 0, len(req))
|
||||||
|
variableNames := make([]string, 0, len(req))
|
||||||
|
for _, request := range req {
|
||||||
|
variables = append(variables, entity.Variable{
|
||||||
|
Name: request.Name,
|
||||||
|
Description: request.Description,
|
||||||
|
Type: request.Type,
|
||||||
|
Value: request.Value,
|
||||||
|
})
|
||||||
|
variableNames = append(variableNames, request.Name)
|
||||||
|
}
|
||||||
|
err := s.repo.Upsert(ctx, variables)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "upsert variables")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.syncConfigsByVariables(ctx, variableNames)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "sync configs by variables")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) Delete(ctx context.Context, name string) error {
|
||||||
|
metaByVariables, err := s.configRepo.GetMetaByVariables(ctx, []string{name})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get meta by variables")
|
||||||
|
}
|
||||||
|
if len(metaByVariables[name]) > 0 {
|
||||||
|
return entity.ErrVariableUsedInConfigs
|
||||||
|
}
|
||||||
|
|
||||||
|
deleted, err := s.repo.Delete(ctx, name)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "delete variable")
|
||||||
|
}
|
||||||
|
if !deleted {
|
||||||
|
return entity.ErrVariableNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:funlen
|
||||||
|
func (s Service) RenderConfig(ctx context.Context, input []byte) ([]byte, error) {
|
||||||
|
variables, err := s.repo.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get all variables")
|
||||||
|
}
|
||||||
|
if len(variables) == 0 {
|
||||||
|
return input, nil
|
||||||
|
}
|
||||||
|
varsMap := make(map[string]string, len(variables))
|
||||||
|
for _, variable := range variables {
|
||||||
|
varsMap[variable.Name] = variable.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
undefinedVariables := make([]string, 0)
|
||||||
|
withReplacedVars := s.variableRegexp.ReplaceAllStringFunc(string(input), func(group string) string {
|
||||||
|
varName := s.variableRegexp.FindStringSubmatch(group)[1]
|
||||||
|
|
||||||
|
value, ok := varsMap[varName]
|
||||||
|
if !ok {
|
||||||
|
undefinedVariables = append(undefinedVariables, varName)
|
||||||
|
return varName
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
})
|
||||||
|
if len(undefinedVariables) > 0 {
|
||||||
|
return nil, errors.Errorf("undefined variables: [%s]", strings.Join(undefinedVariables, ", "))
|
||||||
|
}
|
||||||
|
|
||||||
|
result := s.stringToIntRegexp.ReplaceAll([]byte(withReplacedVars), []byte("$1"))
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) ExtractVariables(ctx context.Context, configId string, input []byte) (*domain.VariableExtractionResult, error) {
|
||||||
|
matches := s.variableRegexp.FindAllStringSubmatch(string(input), -1)
|
||||||
|
seen := make(map[string]bool, len(matches))
|
||||||
|
varNames := make([]string, 0, len(matches))
|
||||||
|
for _, match := range matches {
|
||||||
|
name := match[1]
|
||||||
|
if seen[name] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
seen[name] = true
|
||||||
|
varNames = append(varNames, name)
|
||||||
|
}
|
||||||
|
if len(varNames) == 0 {
|
||||||
|
return &domain.VariableExtractionResult{
|
||||||
|
VariableLinks: []entity.ConfigHasVariable{},
|
||||||
|
AbsentVariables: []string{},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
allVariables, err := s.repo.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.WithMessage(err, "get all variables")
|
||||||
|
}
|
||||||
|
allVariablesMap := make(map[string]bool, len(allVariables))
|
||||||
|
for _, variable := range allVariables {
|
||||||
|
allVariablesMap[variable.Name] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
absentVariables := make([]string, 0)
|
||||||
|
variableLinks := make([]entity.ConfigHasVariable, 0)
|
||||||
|
for _, name := range varNames {
|
||||||
|
if !allVariablesMap[name] {
|
||||||
|
absentVariables = append(absentVariables, name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
variableLinks = append(variableLinks, entity.ConfigHasVariable{
|
||||||
|
ConfigId: configId,
|
||||||
|
VariableName: name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return &domain.VariableExtractionResult{
|
||||||
|
VariableLinks: variableLinks,
|
||||||
|
AbsentVariables: absentVariables,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) SaveVariableLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error {
|
||||||
|
err := s.repo.UpsertLinks(ctx, configId, links)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "upsert links")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) toDto(variable entity.Variable, metaByVariables map[string][]entity.ConfigMetaWithVariable) domain.Variable {
|
||||||
|
value := variable.Value
|
||||||
|
if variable.Type == "SECRET" {
|
||||||
|
value = ""
|
||||||
|
}
|
||||||
|
containsInConfigs := []domain.LinkedConfig{}
|
||||||
|
for _, metaWithVariable := range metaByVariables[variable.Name] {
|
||||||
|
containsInConfigs = append(containsInConfigs, domain.LinkedConfig{
|
||||||
|
Id: metaWithVariable.Id,
|
||||||
|
ModuleId: metaWithVariable.ModuleId,
|
||||||
|
Name: metaWithVariable.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return domain.Variable{
|
||||||
|
Name: variable.Name,
|
||||||
|
Description: variable.Description,
|
||||||
|
Type: variable.Type,
|
||||||
|
Value: value,
|
||||||
|
CreatedAt: time.Time(variable.CreatedAt),
|
||||||
|
UpdatedAt: time.Time(variable.UpdatedAt),
|
||||||
|
ContainsInConfigs: containsInConfigs,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s Service) syncConfigsByVariables(ctx context.Context, variables []string) error {
|
||||||
|
metaByVariables, err := s.configRepo.GetMetaByVariables(ctx, variables)
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessage(err, "get meta by variables")
|
||||||
|
}
|
||||||
|
modulesToSync := make(map[string]bool)
|
||||||
|
for _, variable := range variables {
|
||||||
|
for _, withVariable := range metaByVariables[variable] {
|
||||||
|
if !withVariable.Active {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
modulesToSync[withVariable.ModuleId] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for moduleId := range modulesToSync {
|
||||||
|
err := s.eventRepo.Insert(ctx, entity.Event{
|
||||||
|
Payload: xtypes.Json[entity.EventPayload]{
|
||||||
|
Value: entity.EventPayload{
|
||||||
|
ConfigUpdated: &entity.PayloadConfigUpdated{
|
||||||
|
ModuleId: moduleId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return errors.WithMessagef(err, "insert change config event for moduleId: %s", moduleId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
+108
-38
@@ -1,3 +1,4 @@
|
|||||||
|
// nolint:ireturn
|
||||||
package tests_test
|
package tests_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -8,6 +9,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"isp-config-service/conf"
|
||||||
|
"isp-config-service/domain"
|
||||||
|
"isp-config-service/service/rqlite/db"
|
||||||
|
"isp-config-service/service/startup"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
@@ -15,44 +21,22 @@ import (
|
|||||||
"github.com/txix-open/isp-kit/json"
|
"github.com/txix-open/isp-kit/json"
|
||||||
"github.com/txix-open/isp-kit/log"
|
"github.com/txix-open/isp-kit/log"
|
||||||
"github.com/txix-open/isp-kit/rc/schema"
|
"github.com/txix-open/isp-kit/rc/schema"
|
||||||
"isp-config-service/conf"
|
|
||||||
"isp-config-service/domain"
|
|
||||||
"isp-config-service/service/startup"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:funlen
|
//nolint:funlen,paralleltest
|
||||||
func TestAcceptance(t *testing.T) {
|
func TestAcceptance(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
logger := setupTest(t)
|
||||||
|
|
||||||
t.Setenv("APP_CONFIG_PATH", "../conf/config.yml")
|
clientA1 := newClusterClient(t, "A", "10.2.9.1", logger)
|
||||||
t.Setenv("DefaultRemoteConfigPath", "../conf/default_remote_config.json")
|
|
||||||
boot := bootstrap.New("1.0.0", conf.Remote{}, nil)
|
|
||||||
boot.MigrationsDir = "../migrations"
|
|
||||||
dataPath := dataDir(t)
|
|
||||||
boot.App.Config().Set("rqlite.DataPath", dataPath)
|
|
||||||
logger := boot.App.Logger()
|
|
||||||
|
|
||||||
startup, err := startup.New(boot)
|
|
||||||
require.NoError(err)
|
|
||||||
t.Cleanup(func() {
|
|
||||||
for _, closer := range startup.Closers() {
|
|
||||||
err := closer.Close()
|
|
||||||
require.NoError(err)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
err = startup.Run(context.Background())
|
|
||||||
require.NoError(err)
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
|
|
||||||
clientA1 := newClusterClient("A", "10.2.9.1", logger)
|
|
||||||
go func() {
|
go func() {
|
||||||
handler := cluster.NewEventHandler()
|
handler := cluster.NewEventHandler()
|
||||||
err := clientA1.Run(context.Background(), handler)
|
err := clientA1.Run(t.Context(), handler)
|
||||||
require.NoError(err) //nolint:testifylint
|
require.NoError(err) //nolint:testifylint
|
||||||
}()
|
}()
|
||||||
|
|
||||||
clientA2 := newClusterClient("A", "10.2.9.2", logger)
|
clientA2 := newClusterClient(t, "A", "10.2.9.2", logger)
|
||||||
clientA2Ctx, cancelClient2 := context.WithCancel(context.Background())
|
clientA2Ctx, cancelClient2 := context.WithCancel(t.Context())
|
||||||
go func() {
|
go func() {
|
||||||
handler := cluster.NewEventHandler()
|
handler := cluster.NewEventHandler()
|
||||||
err := clientA2.Run(clientA2Ctx, handler)
|
err := clientA2.Run(clientA2Ctx, handler)
|
||||||
@@ -60,14 +44,14 @@ func TestAcceptance(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
clientB := newClusterClient("B", "10.2.9.2", logger)
|
clientB := newClusterClient(t, "B", "10.2.9.2", logger)
|
||||||
eventHandler := newClusterEventHandler()
|
eventHandler := newClusterEventHandler()
|
||||||
go func() {
|
go func() {
|
||||||
handler := cluster.NewEventHandler().
|
handler := cluster.NewEventHandler().
|
||||||
RemoteConfigReceiver(eventHandler).
|
RemoteConfigReceiver(eventHandler).
|
||||||
RequireModule("A", eventHandler).
|
RequireModule("A", eventHandler).
|
||||||
RoutesReceiver(eventHandler)
|
RoutesReceiver(eventHandler)
|
||||||
err := clientB.Run(context.Background(), handler)
|
err := clientB.Run(t.Context(), handler)
|
||||||
require.NoError(err) //nolint:testifylint
|
require.NoError(err) //nolint:testifylint
|
||||||
}()
|
}()
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
@@ -80,7 +64,7 @@ func TestAcceptance(t *testing.T) {
|
|||||||
err = apiCli.Invoke("config/config/get_active_config_by_module_name").
|
err = apiCli.Invoke("config/config/get_active_config_by_module_name").
|
||||||
JsonRequestBody(domain.GetByModuleNameRequest{ModuleName: "B"}).
|
JsonRequestBody(domain.GetByModuleNameRequest{ModuleName: "B"}).
|
||||||
JsonResponseBody(&activeConfig).
|
JsonResponseBody(&activeConfig).
|
||||||
Do(context.Background())
|
Do(t.Context())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
updateConfigReq := domain.CreateUpdateConfigRequest{
|
updateConfigReq := domain.CreateUpdateConfigRequest{
|
||||||
Id: activeConfig.Id,
|
Id: activeConfig.Id,
|
||||||
@@ -91,7 +75,7 @@ func TestAcceptance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
err = apiCli.Invoke("config/config/create_update_config").
|
err = apiCli.Invoke("config/config/create_update_config").
|
||||||
JsonRequestBody(updateConfigReq).
|
JsonRequestBody(updateConfigReq).
|
||||||
Do(context.Background())
|
Do(t.Context())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
cancelClient2()
|
cancelClient2()
|
||||||
@@ -107,11 +91,17 @@ func TestAcceptance(t *testing.T) {
|
|||||||
require.EqualValues([]string{"10.2.9.1:9999"}, eventHandler.ReceivedHosts()[1])
|
require.EqualValues([]string{"10.2.9.1:9999"}, eventHandler.ReceivedHosts()[1])
|
||||||
|
|
||||||
require.Len(eventHandler.ReceivedRoutes(), 3)
|
require.Len(eventHandler.ReceivedRoutes(), 3)
|
||||||
|
for _, routes := range eventHandler.ReceivedRoutes() {
|
||||||
|
for _, declaration := range routes {
|
||||||
|
require.EqualValues(cluster.ModuleLeaderModeNone, declaration.ModuleLeaderMode)
|
||||||
|
require.False(declaration.Address.IsModuleLeader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
statusResponse := make([]domain.ModuleInfo, 0)
|
statusResponse := make([]domain.ModuleInfo, 0)
|
||||||
err = apiCli.Invoke("config/module/get_modules_info").
|
err = apiCli.Invoke("config/module/get_modules_info").
|
||||||
JsonResponseBody(&statusResponse).
|
JsonResponseBody(&statusResponse).
|
||||||
Do(context.Background())
|
Do(t.Context())
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
require.Len(statusResponse, 3)
|
require.Len(statusResponse, 3)
|
||||||
require.EqualValues("A", statusResponse[0].Name)
|
require.EqualValues("A", statusResponse[0].Name)
|
||||||
@@ -138,16 +128,54 @@ type testModuleRemoteConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newClusterClient(
|
func newClusterClient(
|
||||||
|
t *testing.T,
|
||||||
moduleName string,
|
moduleName string,
|
||||||
host string,
|
host string,
|
||||||
logger log.Logger,
|
logger log.Logger,
|
||||||
) *cluster.Client {
|
) *cluster.Client {
|
||||||
schema := schema.NewGenerator().Generate(testModuleRemoteConfig{})
|
t.Helper()
|
||||||
|
return newClusterClientWith(t, moduleName, host, testModuleRemoteConfig{}, []byte("{}"), nil, logger)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newClusterClientWith(
|
||||||
|
t *testing.T,
|
||||||
|
moduleName string,
|
||||||
|
host string,
|
||||||
|
config any,
|
||||||
|
defaultRemoteConfig []byte,
|
||||||
|
metricsAd *cluster.MetricsAutodiscovery,
|
||||||
|
logger log.Logger,
|
||||||
|
) *cluster.Client {
|
||||||
|
t.Helper()
|
||||||
|
return newClusterClientFull(
|
||||||
|
t,
|
||||||
|
moduleName,
|
||||||
|
host,
|
||||||
|
config,
|
||||||
|
defaultRemoteConfig,
|
||||||
|
metricsAd,
|
||||||
|
cluster.ModuleLeaderModeNone,
|
||||||
|
logger,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newClusterClientFull(
|
||||||
|
t *testing.T,
|
||||||
|
moduleName string,
|
||||||
|
host string,
|
||||||
|
config any,
|
||||||
|
defaultRemoteConfig []byte,
|
||||||
|
metricsAd *cluster.MetricsAutodiscovery,
|
||||||
|
moduleLeaderMode string,
|
||||||
|
logger log.Logger,
|
||||||
|
) *cluster.Client {
|
||||||
|
t.Helper()
|
||||||
|
schema := schema.NewGenerator().Generate(config)
|
||||||
schemaData, err := json.Marshal(schema)
|
schemaData, err := json.Marshal(schema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return cluster.NewClient(cluster.ModuleInfo{
|
cli := cluster.NewClient(cluster.ModuleInfo{
|
||||||
ModuleName: moduleName,
|
ModuleName: moduleName,
|
||||||
ModuleVersion: "1.0.0",
|
ModuleVersion: "1.0.0",
|
||||||
LibVersion: "1.0.0",
|
LibVersion: "1.0.0",
|
||||||
@@ -155,10 +183,52 @@ func newClusterClient(
|
|||||||
IP: host,
|
IP: host,
|
||||||
Port: "9999",
|
Port: "9999",
|
||||||
},
|
},
|
||||||
Endpoints: nil,
|
EndpointsResolver: cluster.StaticEndpointResolver{},
|
||||||
|
MetricsAutodiscovery: metricsAd,
|
||||||
|
ModuleLeaderMode: moduleLeaderMode,
|
||||||
}, cluster.ConfigData{
|
}, cluster.ConfigData{
|
||||||
Version: "1.0.0",
|
Version: "1.0.0",
|
||||||
Schema: schemaData,
|
Schema: schemaData,
|
||||||
Config: []byte(`{}`),
|
Config: defaultRemoteConfig,
|
||||||
}, []string{"127.0.0.1:9001"}, logger)
|
}, []string{"127.0.0.1:9001"}, 5*time.Second, logger)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
_ = cli.Close()
|
||||||
|
})
|
||||||
|
return cli
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupTest(t *testing.T) log.Logger {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
_, logger, _ := setupTestApp(t)
|
||||||
|
return logger
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:ireturn
|
||||||
|
func setupTestApp(t *testing.T) (*require.Assertions, log.Logger, db.DB) {
|
||||||
|
t.Helper()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
t.Setenv("APP_CONFIG_PATH", "../conf/config.yml")
|
||||||
|
t.Setenv("DefaultRemoteConfigPath", "../conf/default_remote_config.json")
|
||||||
|
boot := bootstrap.New("1.0.0", conf.Remote{}, nil, cluster.GrpcTransport)
|
||||||
|
boot.MigrationsDir = "../migrations"
|
||||||
|
dataPath := dataDir(t)
|
||||||
|
boot.App.Config().Set("rqlite.DataPath", dataPath)
|
||||||
|
boot.App.Config().Set("backup.Enable", false)
|
||||||
|
logger := boot.App.Logger()
|
||||||
|
|
||||||
|
startup, err := startup.New(boot)
|
||||||
|
require.NoError(err)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
for _, closer := range startup.Closers() {
|
||||||
|
err := closer.Close()
|
||||||
|
require.NoError(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
err = startup.Run(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
|
return require, logger, startup.Db()
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package tests_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"math/rand"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"isp-config-service/conf"
|
||||||
|
"isp-config-service/domain"
|
||||||
|
"isp-config-service/service/startup"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/bootstrap"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/http/httpclix"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
"github.com/txix-open/isp-kit/test/fake"
|
||||||
|
)
|
||||||
|
|
||||||
|
// nolint:paralleltest
|
||||||
|
func TestMetricsAutodiscovery(t *testing.T) {
|
||||||
|
require, logger := setupTestWithAppRun(t)
|
||||||
|
|
||||||
|
cli := httpclix.DefaultWithBalancer([]string{"127.0.0.1:9006"})
|
||||||
|
resp := make(domain.AutodiscoveryResponse, 0)
|
||||||
|
err := cli.Get("/internal/metrics/autodiscovery").
|
||||||
|
JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
configTarget := domain.PrometheusTargets{
|
||||||
|
Targets: []string{"isp-config-service:9006"},
|
||||||
|
Labels: map[string]string{
|
||||||
|
"app": "isp-config-service",
|
||||||
|
"__metrics_path__": "/internal/metrics",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
require.Equal(domain.AutodiscoveryResponse{configTarget}, resp)
|
||||||
|
|
||||||
|
const (
|
||||||
|
iterCount = 8
|
||||||
|
chanceToMetricsAd = 0.5
|
||||||
|
)
|
||||||
|
expected := make(domain.AutodiscoveryResponse, 0, iterCount+1)
|
||||||
|
for i := range iterCount {
|
||||||
|
metricsAd := generateMetricsAdWithChance(chanceToMetricsAd)
|
||||||
|
if metricsAd != nil {
|
||||||
|
expected = append(expected, domain.PrometheusTargets{
|
||||||
|
Targets: []string{metricsAd.Address},
|
||||||
|
Labels: metricsAd.Labels,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
clusterCli := newClusterClientWith(
|
||||||
|
t,
|
||||||
|
strconv.Itoa(i),
|
||||||
|
"10.2.9.1",
|
||||||
|
testModuleRemoteConfig{},
|
||||||
|
[]byte("{}"),
|
||||||
|
metricsAd,
|
||||||
|
logger,
|
||||||
|
)
|
||||||
|
go func() {
|
||||||
|
err := clusterCli.Run(t.Context(), cluster.NewEventHandler())
|
||||||
|
require.NoError(err) // nolint:testifylint
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
expected = append(expected, configTarget)
|
||||||
|
|
||||||
|
resp = make(domain.AutodiscoveryResponse, 0)
|
||||||
|
err = cli.Get("/internal/metrics/autodiscovery").
|
||||||
|
JsonResponseBody(&resp).
|
||||||
|
StatusCodeToError().
|
||||||
|
DoWithoutResponse(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
require.Equal(expected, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateMetricsAdWithChance(chance float64) *cluster.MetricsAutodiscovery {
|
||||||
|
if rand.Float64() > chance { // nolint:gosec
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fake.It[*cluster.MetricsAutodiscovery]()
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:ireturn
|
||||||
|
func setupTestWithAppRun(t *testing.T) (*require.Assertions, log.Logger) {
|
||||||
|
t.Helper()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
t.Setenv("APP_CONFIG_PATH", "../conf/config.yml")
|
||||||
|
t.Setenv("DefaultRemoteConfigPath", "../conf/default_remote_config.json")
|
||||||
|
boot := bootstrap.New("1.0.0", conf.Remote{}, nil, cluster.GrpcTransport)
|
||||||
|
boot.MigrationsDir = "../migrations"
|
||||||
|
dataPath := dataDir(t)
|
||||||
|
boot.App.Config().Set("rqlite.DataPath", dataPath)
|
||||||
|
boot.App.Config().Set("backup.Enable", false)
|
||||||
|
logger := boot.App.Logger()
|
||||||
|
|
||||||
|
startup, err := startup.New(boot)
|
||||||
|
require.NoError(err)
|
||||||
|
t.Cleanup(func() {
|
||||||
|
for _, closer := range startup.Closers() {
|
||||||
|
err := closer.Close()
|
||||||
|
require.NoError(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
err = startup.Run(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err = boot.App.Run()
|
||||||
|
require.NoError(err) // nolint:testifylint
|
||||||
|
}()
|
||||||
|
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
|
||||||
|
return require, logger
|
||||||
|
}
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
package tests_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net"
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"isp-config-service/domain"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
apiObserverModule = "apiobserver"
|
||||||
|
apiObserverIP = "10.2.9.20"
|
||||||
|
|
||||||
|
apiSilentModule = "apisilent"
|
||||||
|
apiSilentHost = "10.2.9.21"
|
||||||
|
|
||||||
|
modulesInfoEndpoint = "config/module/get_modules_info"
|
||||||
|
routesEndpoint = "config/routing/get_routes"
|
||||||
|
)
|
||||||
|
|
||||||
|
//nolint:funlen,paralleltest
|
||||||
|
func TestModuleLeaderApiFlag(t *testing.T) {
|
||||||
|
require, logger, testDb := setupTestApp(t)
|
||||||
|
ctx := t.Context()
|
||||||
|
|
||||||
|
apiCli, err := client.Default()
|
||||||
|
require.NoError(err)
|
||||||
|
apiCli.Upgrade([]string{"127.0.0.1:9002"})
|
||||||
|
|
||||||
|
observer := newClusterEventHandler()
|
||||||
|
runClusterClient(ctx, require,
|
||||||
|
newClusterClient(t, apiObserverModule, apiObserverIP, logger),
|
||||||
|
cluster.NewEventHandler().RequireModule(electionModule, observer).RoutesReceiver(observer),
|
||||||
|
)
|
||||||
|
|
||||||
|
instances := []moduleInstance{
|
||||||
|
startModuleInstance(t, electionModule, electionHostOne, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
startModuleInstance(t, electionModule, electionHostTwo, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
startModuleInstance(t, electionModule, electionHostThree, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
startModuleInstance(t, plainModule, plainHostOne, cluster.ModuleLeaderModeNone, logger),
|
||||||
|
startModuleInstance(t, plainModule, plainHostTwo, cluster.ModuleLeaderModeNone, logger),
|
||||||
|
startModuleInstance(t, apiSilentModule, apiSilentHost, cluster.ModuleLeaderModeNone, logger),
|
||||||
|
}
|
||||||
|
|
||||||
|
byHost := make(map[string]moduleInstance, len(instances))
|
||||||
|
for _, instance := range instances {
|
||||||
|
byHost[instance.host] = instance
|
||||||
|
}
|
||||||
|
|
||||||
|
connected := map[string]int{electionModule: 3, plainModule: 2, apiSilentModule: 1}
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(selectLeaderOrder(ctx, testDb, electionModule)) == 3 &&
|
||||||
|
len(selectLeaderOrder(ctx, testDb, plainModule)) == 2 &&
|
||||||
|
len(selectLeaderOrder(ctx, testDb, apiSilentModule)) == 1
|
||||||
|
}, announceTimeout, announceTick, "every instance must be connected")
|
||||||
|
|
||||||
|
elected := selectLeaderOrder(ctx, testDb, electionModule)
|
||||||
|
derivedLeader := elected[0].Address
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return slices.Equal(lastHosts(observer), []string{derivedLeader})
|
||||||
|
}, announceTimeout, announceTick, "the subscriber must be balanced to the derived leader")
|
||||||
|
observedLeader := lastHosts(observer)[0]
|
||||||
|
|
||||||
|
status := requireApiCounts(t, ctx, apiCli, modulesInfoEndpoint, instanceCount, connected)
|
||||||
|
|
||||||
|
electionInfo := findModule(status, electionModule)
|
||||||
|
require.NotNil(electionInfo, electionModule)
|
||||||
|
require.True(electionInfo.Active)
|
||||||
|
require.Len(electionInfo.Status, 3, "modules info must keep every instance of the elected module")
|
||||||
|
|
||||||
|
apiLeader := requireSingleLeader(require, electionInfo.Status)
|
||||||
|
require.Equal(derivedLeader, apiLeader, "the leader of the API must be the leader derived from the DB")
|
||||||
|
require.Equal(observedLeader, apiLeader, "the leader of the API must be the address the subscriber receives")
|
||||||
|
|
||||||
|
requireNoLeaders(require, connectionsOf(status, plainModule), plainModule)
|
||||||
|
requireNoLeaders(require, connectionsOf(status, apiSilentModule), apiSilentModule)
|
||||||
|
|
||||||
|
routes := requireApiCounts(t, ctx, apiCli, routesEndpoint, connectionCount, connected)
|
||||||
|
require.Len(connectionsOfModule(routes, electionModule), 3, "routes must not narrow the elected module")
|
||||||
|
require.Equal(apiLeader, requireSingleLeader(require, connectionsOfModule(routes, electionModule)),
|
||||||
|
"routes must mark the same leader as modules info")
|
||||||
|
requireNoLeaders(require, connectionsOfModule(routes, plainModule), plainModule)
|
||||||
|
|
||||||
|
byHost[apiSilentHost].disconnect(t)
|
||||||
|
|
||||||
|
byHost[hostOf(t, elected[1].Address)].disconnect(t)
|
||||||
|
byHost[hostOf(t, elected[2].Address)].disconnect(t)
|
||||||
|
|
||||||
|
status = requireApiCounts(t, ctx, apiCli, modulesInfoEndpoint, instanceCount, map[string]int{
|
||||||
|
electionModule: 1,
|
||||||
|
plainModule: 2,
|
||||||
|
apiSilentModule: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
silentInfo := findModule(status, apiSilentModule)
|
||||||
|
require.NotNil(silentInfo, apiSilentModule)
|
||||||
|
require.False(silentInfo.Active)
|
||||||
|
require.Empty(silentInfo.Status, "a module without instances has no connection to mark")
|
||||||
|
|
||||||
|
electionInfo = findModule(status, electionModule)
|
||||||
|
require.NotNil(electionInfo, electionModule)
|
||||||
|
require.True(electionInfo.Active)
|
||||||
|
require.Len(electionInfo.Status, 1)
|
||||||
|
require.True(electionInfo.Status[0].IsModuleLeader, "the only instance of an elected module is its leader")
|
||||||
|
require.Equal(derivedLeader, connectionAddress(electionInfo.Status[0]),
|
||||||
|
"dropping standbys must not move leadership")
|
||||||
|
}
|
||||||
|
|
||||||
|
func connectionsOf(modules []domain.ModuleInfo, moduleName string) []domain.Connection {
|
||||||
|
for _, module := range modules {
|
||||||
|
if module.Name == moduleName {
|
||||||
|
return module.Status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func connectionsOfModule(connections []domain.Connection, moduleName string) []domain.Connection {
|
||||||
|
ofModule := make([]domain.Connection, 0, len(connections))
|
||||||
|
for _, connection := range connections {
|
||||||
|
if connection.ModuleName == moduleName {
|
||||||
|
ofModule = append(ofModule, connection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ofModule
|
||||||
|
}
|
||||||
|
|
||||||
|
func connectionAddress(connection domain.Connection) string {
|
||||||
|
return net.JoinHostPort(connection.Address.Ip, connection.Address.Port)
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireSingleLeader(require *require.Assertions, connections []domain.Connection) string {
|
||||||
|
leaders := make([]string, 0, 1)
|
||||||
|
for _, connection := range connections {
|
||||||
|
if connection.IsModuleLeader {
|
||||||
|
leaders = append(leaders, connectionAddress(connection))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require.Len(leaders, 1, "an elected module must expose exactly one leader")
|
||||||
|
|
||||||
|
return leaders[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireNoLeaders(require *require.Assertions, connections []domain.Connection, moduleName string) {
|
||||||
|
require.NotEmpty(connections, moduleName)
|
||||||
|
for _, connection := range connections {
|
||||||
|
require.False(connection.IsModuleLeader, "a module without election must not expose a leader: "+moduleName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func instanceCount(module domain.ModuleInfo) map[string]int {
|
||||||
|
return map[string]int{module.Name: len(module.Status)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func connectionCount(connection domain.Connection) map[string]int {
|
||||||
|
return map[string]int{connection.ModuleName: 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireApiCounts[T any](
|
||||||
|
t *testing.T,
|
||||||
|
ctx context.Context,
|
||||||
|
apiCli *client.Client,
|
||||||
|
endpoint string,
|
||||||
|
countsOf func(row T) map[string]int,
|
||||||
|
expected map[string]int,
|
||||||
|
) []T {
|
||||||
|
t.Helper()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
rows := make([]T, 0)
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
latest := make([]T, 0)
|
||||||
|
err := apiCli.Invoke(endpoint).JsonResponseBody(&latest).Do(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
rows = latest
|
||||||
|
|
||||||
|
return countsMatch(countsByModule(rows, countsOf), expected)
|
||||||
|
}, announceTimeout, announceTick, endpoint+" must report every instance")
|
||||||
|
|
||||||
|
return rows
|
||||||
|
}
|
||||||
|
|
||||||
|
func countsByModule[T any](rows []T, countsOf func(row T) map[string]int) map[string]int {
|
||||||
|
counts := make(map[string]int, len(rows))
|
||||||
|
for _, row := range rows {
|
||||||
|
for moduleName, total := range countsOf(row) {
|
||||||
|
counts[moduleName] += total
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return counts
|
||||||
|
}
|
||||||
|
|
||||||
|
func countsMatch(counts, expected map[string]int) bool {
|
||||||
|
for moduleName, total := range expected {
|
||||||
|
if counts[moduleName] != total {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -0,0 +1,349 @@
|
|||||||
|
package tests_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net"
|
||||||
|
"slices"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"isp-config-service/service/rqlite/db"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
electionHostOne = "10.2.9.1"
|
||||||
|
electionHostTwo = "10.2.9.2"
|
||||||
|
electionHostThree = "10.2.9.3"
|
||||||
|
|
||||||
|
plainModule = "plain"
|
||||||
|
plainHostOne = "10.2.9.7"
|
||||||
|
plainHostTwo = "10.2.9.8"
|
||||||
|
plainObserverModule = "plainobserver"
|
||||||
|
plainObserverIP = "10.2.9.10"
|
||||||
|
|
||||||
|
electionObserverModule = "electionobserver"
|
||||||
|
electionObserverIP = "10.2.9.9"
|
||||||
|
|
||||||
|
lateObserverModule = "lateobserver"
|
||||||
|
lateObserverIP = "10.2.9.11"
|
||||||
|
|
||||||
|
noLeaderModule = "noleader"
|
||||||
|
noLeaderHostOne = "10.2.9.12"
|
||||||
|
noLeaderHostTwo = "10.2.9.13"
|
||||||
|
noLeaderObserverIP = "10.2.9.14"
|
||||||
|
noLeaderObserverName = "noleaderobserver"
|
||||||
|
|
||||||
|
instancePort = "9999"
|
||||||
|
)
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
|
type leaderOrderRow struct {
|
||||||
|
WsConnectionId string `json:"ws_connection_id"`
|
||||||
|
Address string `json:"address"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
|
type schemaNameRow struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type moduleInstance struct {
|
||||||
|
host string
|
||||||
|
cli *cluster.Client
|
||||||
|
cancel context.CancelFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:funlen,paralleltest
|
||||||
|
func TestModuleLeaderElection(t *testing.T) {
|
||||||
|
require, logger, testDb := setupTestApp(t)
|
||||||
|
ctx := t.Context()
|
||||||
|
|
||||||
|
electionObserver := newClusterEventHandler()
|
||||||
|
runClusterClient(ctx, require,
|
||||||
|
newClusterClient(t, electionObserverModule, electionObserverIP, logger),
|
||||||
|
cluster.NewEventHandler().RequireModule(electionModule, electionObserver).RoutesReceiver(electionObserver),
|
||||||
|
)
|
||||||
|
|
||||||
|
plainObserver := newClusterEventHandler()
|
||||||
|
runClusterClient(ctx, require,
|
||||||
|
newClusterClient(t, plainObserverModule, plainObserverIP, logger),
|
||||||
|
cluster.NewEventHandler().RequireModule(plainModule, plainObserver).RoutesReceiver(plainObserver),
|
||||||
|
)
|
||||||
|
|
||||||
|
electedInstances := []moduleInstance{
|
||||||
|
startModuleInstance(t, electionModule, electionHostOne, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
startModuleInstance(t, electionModule, electionHostTwo, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
startModuleInstance(t, electionModule, electionHostThree, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
}
|
||||||
|
|
||||||
|
byHost := make(map[string]moduleInstance, len(electedInstances))
|
||||||
|
for _, instance := range electedInstances {
|
||||||
|
byHost[instance.host] = instance
|
||||||
|
}
|
||||||
|
|
||||||
|
startModuleInstance(t, plainModule, plainHostOne, cluster.ModuleLeaderModeNone, logger)
|
||||||
|
startModuleInstance(t, plainModule, plainHostTwo, cluster.ModuleLeaderModeNone, logger)
|
||||||
|
|
||||||
|
announced := []string{addressOf(electionHostOne), addressOf(electionHostTwo), addressOf(electionHostThree)}
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(selectLeaderOrder(ctx, testDb, electionModule)) == 3
|
||||||
|
}, announceTimeout, announceTick, "all three instances of %s must be connected", electionModule)
|
||||||
|
|
||||||
|
elected := selectLeaderOrder(ctx, testDb, electionModule)
|
||||||
|
expectedLeader := elected[0].Address
|
||||||
|
expectedSuccessor := elected[1].Address
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return slices.Equal(lastHosts(electionObserver), []string{expectedLeader})
|
||||||
|
}, announceTimeout, announceTick, "the address list of an elected module must keep exactly the derived leader")
|
||||||
|
|
||||||
|
received := lastHosts(electionObserver)
|
||||||
|
require.Len(received, 1, "an elected module must be balanced to a single address")
|
||||||
|
require.Contains(announced, received[0], "the leader must be one of the announced instances")
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return routingLeaderOf(electionObserver, electionModule) == expectedLeader
|
||||||
|
}, announceTimeout, announceTick, "the routing map of an elected module must publish only the leader")
|
||||||
|
requireRoutingLeader(require, lastRoutesOf(electionObserver, electionModule), expectedLeader)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(lastRoutesOf(electionObserver, plainModule)) == 2
|
||||||
|
}, announceTimeout, announceTick, "a module without election must publish every instance")
|
||||||
|
requireRoutingUntouched(require, lastRoutesOf(electionObserver, plainModule), plainHosts())
|
||||||
|
|
||||||
|
lateObserver := newClusterEventHandler()
|
||||||
|
runClusterClient(ctx, require,
|
||||||
|
newClusterClient(t, lateObserverModule, lateObserverIP, logger),
|
||||||
|
cluster.NewEventHandler().RequireModule(electionModule, lateObserver).RoutesReceiver(lateObserver),
|
||||||
|
)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return slices.Equal(lastHosts(lateObserver), []string{expectedLeader}) &&
|
||||||
|
routingLeaderOf(lateObserver, electionModule) == expectedLeader
|
||||||
|
}, announceTimeout, announceTick, "a subscriber connected after the election must see the same leader")
|
||||||
|
requireRoutingLeader(require, lastRoutesOf(lateObserver, electionModule), expectedLeader)
|
||||||
|
|
||||||
|
standbySnapshots := len(electionObserver.ReceivedHosts())
|
||||||
|
byHost[hostOf(t, elected[2].Address)].disconnect(t)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(electionObserver.ReceivedHosts()) > standbySnapshots
|
||||||
|
}, announceTimeout, announceTick, "disconnecting a standby must re-emit the address list")
|
||||||
|
require.Equal([]string{expectedLeader}, lastHosts(electionObserver),
|
||||||
|
"disconnecting a standby must not move leadership")
|
||||||
|
|
||||||
|
leaderSnapshots := len(electionObserver.ReceivedHosts())
|
||||||
|
byHost[hostOf(t, expectedLeader)].disconnect(t)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return slices.Equal(lastHosts(electionObserver), []string{expectedSuccessor})
|
||||||
|
}, announceTimeout, announceTick, "disconnecting the leader must move leadership to the next one in derivation order")
|
||||||
|
require.Equal(expectedSuccessor, selectLeaderOrder(ctx, testDb, electionModule)[0].Address)
|
||||||
|
requireRoutingLeader(require, lastRoutesOf(electionObserver, electionModule), expectedSuccessor)
|
||||||
|
|
||||||
|
require.Greater(len(electionObserver.ReceivedHosts()), leaderSnapshots,
|
||||||
|
"disconnecting the leader must re-emit the address list")
|
||||||
|
|
||||||
|
lastSnapshots := len(electionObserver.ReceivedHosts())
|
||||||
|
byHost[hostOf(t, expectedSuccessor)].disconnect(t)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(electionObserver.ReceivedHosts()) > lastSnapshots
|
||||||
|
}, announceTimeout, announceTick, "disconnecting the last instance must re-emit the address list")
|
||||||
|
require.Empty(lastHosts(electionObserver), "with no instances left the subscriber must receive an empty list")
|
||||||
|
require.Empty(selectLeaderOrder(ctx, testDb, electionModule))
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return slices.Equal(lastHosts(plainObserver), selectEmittedAddresses(ctx, testDb, plainModule))
|
||||||
|
}, announceTimeout, announceTick, "a module without election keeps its newest-first address list")
|
||||||
|
requireRoutingUntouched(require, lastRoutesOf(plainObserver, plainModule), plainHosts())
|
||||||
|
|
||||||
|
requireNoLeaderState(t, testDb)
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:paralleltest
|
||||||
|
func TestModuleLeaderElectionWithoutLeader(t *testing.T) {
|
||||||
|
require, logger, testDb := setupTestApp(t)
|
||||||
|
ctx := t.Context()
|
||||||
|
|
||||||
|
observer := newClusterEventHandler()
|
||||||
|
runClusterClient(ctx, require,
|
||||||
|
newClusterClient(t, noLeaderObserverName, noLeaderObserverIP, logger),
|
||||||
|
cluster.NewEventHandler().RequireModule(noLeaderModule, observer).RoutesReceiver(observer),
|
||||||
|
)
|
||||||
|
|
||||||
|
byHost := map[string]moduleInstance{
|
||||||
|
noLeaderHostOne: startModuleInstance(t, noLeaderModule, noLeaderHostOne, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
noLeaderHostTwo: startModuleInstance(t, noLeaderModule, noLeaderHostTwo, cluster.ModuleLeaderModeRequestElection, logger),
|
||||||
|
}
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(selectLeaderOrder(ctx, testDb, noLeaderModule)) == 2
|
||||||
|
}, announceTimeout, announceTick, "both instances of %s must be connected", noLeaderModule)
|
||||||
|
|
||||||
|
order := selectLeaderOrder(ctx, testDb, noLeaderModule)
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return slices.Equal(lastHosts(observer), []string{order[0].Address})
|
||||||
|
}, announceTimeout, announceTick, "the leader address must be the only published address")
|
||||||
|
requireRoutingLeader(require, lastRoutesOf(observer, noLeaderModule), order[0].Address)
|
||||||
|
|
||||||
|
byHost[hostOf(t, order[0].Address)].disconnect(t)
|
||||||
|
|
||||||
|
var remaining []leaderOrderRow
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
remaining = selectLeaderOrder(ctx, testDb, noLeaderModule)
|
||||||
|
return len(remaining) == 1 && slices.Equal(lastHosts(observer), []string{remaining[0].Address})
|
||||||
|
}, announceTimeout, announceTick, "leadership must move to the remaining instance")
|
||||||
|
|
||||||
|
snapshots := len(observer.ReceivedHosts())
|
||||||
|
byHost[hostOf(t, remaining[0].Address)].disconnect(t)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(observer.ReceivedHosts()) > snapshots && len(lastHosts(observer)) == 0
|
||||||
|
}, announceTimeout, announceTick, "with no instances left the subscriber must receive an empty address list")
|
||||||
|
require.Empty(lastHosts(observer), "the client must receive an empty list, not the previous address")
|
||||||
|
require.Empty(selectLeaderOrder(ctx, testDb, noLeaderModule))
|
||||||
|
require.Empty(lastRoutesOf(observer, noLeaderModule), "a module without instances publishes no declaration")
|
||||||
|
}
|
||||||
|
|
||||||
|
func startModuleInstance(
|
||||||
|
t *testing.T,
|
||||||
|
moduleName string,
|
||||||
|
host string,
|
||||||
|
moduleLeaderMode string,
|
||||||
|
logger log.Logger,
|
||||||
|
) moduleInstance {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
cli := newClusterClientFull(t, moduleName, host, testModuleRemoteConfig{}, []byte("{}"), nil, moduleLeaderMode, logger)
|
||||||
|
ctx, cancel := context.WithCancel(t.Context())
|
||||||
|
runClusterClient(ctx, require.New(t), cli, cluster.NewEventHandler())
|
||||||
|
|
||||||
|
return moduleInstance{host: host, cli: cli, cancel: cancel}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i moduleInstance) disconnect(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
i.cancel()
|
||||||
|
require.NoError(t, i.cli.Close())
|
||||||
|
}
|
||||||
|
|
||||||
|
func addressOf(host string) string {
|
||||||
|
return net.JoinHostPort(host, instancePort)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hostOf(t *testing.T, address string) string {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
host, _, err := net.SplitHostPort(address)
|
||||||
|
require.New(t).NoError(err)
|
||||||
|
|
||||||
|
return host
|
||||||
|
}
|
||||||
|
|
||||||
|
func plainHosts() []string {
|
||||||
|
return []string{addressOf(plainHostOne), addressOf(plainHostTwo)}
|
||||||
|
}
|
||||||
|
|
||||||
|
func lastHosts(handler *clusterEventHandler) []string {
|
||||||
|
snapshots := handler.ReceivedHosts()
|
||||||
|
if len(snapshots) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshots[len(snapshots)-1]
|
||||||
|
}
|
||||||
|
|
||||||
|
func lastRoutesOf(handler *clusterEventHandler, moduleName string) []cluster.BackendDeclaration {
|
||||||
|
snapshots := handler.ReceivedRoutes()
|
||||||
|
if len(snapshots) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
declarations := make([]cluster.BackendDeclaration, 0)
|
||||||
|
for _, declaration := range snapshots[len(snapshots)-1] {
|
||||||
|
if declaration.ModuleName == moduleName {
|
||||||
|
declarations = append(declarations, declaration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return declarations
|
||||||
|
}
|
||||||
|
|
||||||
|
func routingLeaderOf(handler *clusterEventHandler, moduleName string) string {
|
||||||
|
declarations := lastRoutesOf(handler, moduleName)
|
||||||
|
if len(declarations) != 1 || !declarations[0].Address.IsModuleLeader {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return addressOf(declarations[0].Address.IP)
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireRoutingLeader(require *require.Assertions, declarations []cluster.BackendDeclaration, leaderAddress string) {
|
||||||
|
require.Len(declarations, 1, "the routing map of an elected module must publish only the leader")
|
||||||
|
require.Equal(leaderAddress, addressOf(declarations[0].Address.IP))
|
||||||
|
require.True(declarations[0].Address.IsModuleLeader, "the leader declaration must carry the leader flag")
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireRoutingUntouched(require *require.Assertions, declarations []cluster.BackendDeclaration, announced []string) {
|
||||||
|
require.Len(declarations, len(announced), "a module without election must publish every instance")
|
||||||
|
|
||||||
|
addresses := make([]string, 0, len(declarations))
|
||||||
|
for _, declaration := range declarations {
|
||||||
|
require.False(declaration.Address.IsModuleLeader)
|
||||||
|
addresses = append(addresses, addressOf(declaration.Address.IP))
|
||||||
|
}
|
||||||
|
require.ElementsMatch(announced, addresses)
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectLeaderOrder(ctx context.Context, testDb db.DB, moduleName string) []leaderOrderRow {
|
||||||
|
rows := make([]leaderOrderRow, 0)
|
||||||
|
_ = testDb.Select(ctx, &rows, `
|
||||||
|
select ws_connection_id, address
|
||||||
|
from isp_config_service__backend
|
||||||
|
where module_name = ?
|
||||||
|
order by created_at asc, ws_connection_id asc`, moduleName)
|
||||||
|
|
||||||
|
return rows
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectEmittedAddresses(ctx context.Context, testDb db.DB, moduleName string) []string {
|
||||||
|
rows := selectLeaderOrder(ctx, testDb, moduleName)
|
||||||
|
addresses := make([]string, 0, len(rows))
|
||||||
|
for i := range slices.Backward(rows) {
|
||||||
|
addresses = append(addresses, rows[i].Address)
|
||||||
|
}
|
||||||
|
|
||||||
|
return addresses
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireNoLeaderState(t *testing.T, testDb db.DB) {
|
||||||
|
t.Helper()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
columns := make([]schemaNameRow, 0)
|
||||||
|
err := testDb.Select(t.Context(), &columns, `pragma table_info('isp_config_service__backend')`)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
leaderColumns := make([]string, 0)
|
||||||
|
for _, column := range columns {
|
||||||
|
if strings.Contains(strings.ToLower(column.Name), "leader") {
|
||||||
|
leaderColumns = append(leaderColumns, column.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require.Equal([]string{"module_leader_mode"}, leaderColumns,
|
||||||
|
"only the announced mode is stored, the derived leader never is")
|
||||||
|
|
||||||
|
objects := make([]schemaNameRow, 0)
|
||||||
|
err = testDb.Select(t.Context(), &objects, `
|
||||||
|
select name from sqlite_master
|
||||||
|
where lower(name) like '%leader%' and type in ('table','view','index','trigger')`)
|
||||||
|
require.NoError(err)
|
||||||
|
require.Empty(objects, "leader election must not add a table, view, index, or trigger")
|
||||||
|
}
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
package tests_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"slices"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"isp-config-service/domain"
|
||||||
|
"isp-config-service/service/rqlite/db"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/errors"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
|
"github.com/txix-open/isp-kit/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
electionModule = "election"
|
||||||
|
noneModule = "none"
|
||||||
|
leaderModule = "imleader"
|
||||||
|
followerModule = "imfollower"
|
||||||
|
garbageModule = "garbage"
|
||||||
|
observerModule = "observer"
|
||||||
|
|
||||||
|
garbageLeaderMode = "SOMETHING_ELSE"
|
||||||
|
|
||||||
|
announceTimeout = 20 * time.Second
|
||||||
|
announceTick = 200 * time.Millisecond
|
||||||
|
)
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
|
type backendRow struct {
|
||||||
|
WsConnectionId string `json:"ws_connection_id"`
|
||||||
|
CreatedAt int64 `json:"created_at"`
|
||||||
|
ModuleLeaderMode *string `json:"module_leader_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
|
type backendCountRow struct {
|
||||||
|
Total int `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:tagliatelle
|
||||||
|
type epochAdvancedRow struct {
|
||||||
|
Advanced int `json:"advanced"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r backendRow) moduleLeaderMode() string {
|
||||||
|
if r.ModuleLeaderMode == nil {
|
||||||
|
return "null"
|
||||||
|
}
|
||||||
|
return *r.ModuleLeaderMode
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:funlen,paralleltest
|
||||||
|
func TestModuleLeaderMode(t *testing.T) {
|
||||||
|
require, logger, testDb := setupTestApp(t)
|
||||||
|
ctx := t.Context()
|
||||||
|
|
||||||
|
routes := newClusterEventHandler()
|
||||||
|
runClusterClient(ctx, require,
|
||||||
|
newClusterClient(t, observerModule, "10.2.9.9", logger),
|
||||||
|
cluster.NewEventHandler().RoutesReceiver(routes),
|
||||||
|
)
|
||||||
|
|
||||||
|
electionCli := newClusterClientWithLeaderMode(t, electionModule, "10.2.9.1", cluster.ModuleLeaderModeRequestElection, logger)
|
||||||
|
runClusterClient(ctx, require, electionCli, cluster.NewEventHandler())
|
||||||
|
|
||||||
|
noneCli := newClusterClient(t, noneModule, "10.2.9.2", logger)
|
||||||
|
runClusterClient(ctx, require, noneCli, cluster.NewEventHandler())
|
||||||
|
|
||||||
|
leaderCli := newClusterClientWithLeaderMode(t, leaderModule, "10.2.9.3", cluster.ModuleLeaderModeImLeader, logger)
|
||||||
|
runClusterClient(ctx, require, leaderCli, cluster.NewEventHandler())
|
||||||
|
|
||||||
|
followerCli := newClusterClientWithLeaderMode(t, followerModule, "10.2.9.4", cluster.ModuleLeaderModeImFollower, logger)
|
||||||
|
runClusterClient(ctx, require, followerCli, cluster.NewEventHandler())
|
||||||
|
|
||||||
|
garbageCli := newClusterClientWithLeaderMode(t, garbageModule, "10.2.9.5", garbageLeaderMode, logger)
|
||||||
|
runClusterClient(ctx, require, garbageCli, cluster.NewEventHandler())
|
||||||
|
|
||||||
|
electionRow := requireBackendRow(t, testDb, electionModule)
|
||||||
|
require.Equal(cluster.ModuleLeaderModeRequestElection, electionRow.moduleLeaderMode())
|
||||||
|
|
||||||
|
noneRow := requireBackendRow(t, testDb, noneModule)
|
||||||
|
require.NotNil(noneRow.ModuleLeaderMode, "mode announced as empty must be stored as empty string")
|
||||||
|
require.Equal(cluster.ModuleLeaderModeNone, noneRow.moduleLeaderMode())
|
||||||
|
t.Logf("rqlite returns module_leader_mode of %s as %q", noneModule, noneRow.moduleLeaderMode())
|
||||||
|
|
||||||
|
reserved := []struct {
|
||||||
|
moduleName string
|
||||||
|
cli *cluster.Client
|
||||||
|
}{
|
||||||
|
{moduleName: leaderModule, cli: leaderCli},
|
||||||
|
{moduleName: followerModule, cli: followerCli},
|
||||||
|
{moduleName: garbageModule, cli: garbageCli},
|
||||||
|
}
|
||||||
|
for _, instance := range reserved {
|
||||||
|
row := requireBackendRow(t, testDb, instance.moduleName)
|
||||||
|
require.NotNil(row.ModuleLeaderMode, "reserved mode must be stored as empty string")
|
||||||
|
require.Equal(cluster.ModuleLeaderModeNone, row.moduleLeaderMode(), instance.moduleName)
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return instance.cli.Healthcheck(ctx) == nil
|
||||||
|
}, announceTimeout, announceTick, "handshake of %s must not be rejected", instance.moduleName)
|
||||||
|
}
|
||||||
|
|
||||||
|
requireAcceptedModules(require, ctx, leaderModule, followerModule, garbageModule)
|
||||||
|
|
||||||
|
for _, routing := range requireReceivedRoutes(require, routes) {
|
||||||
|
for _, declaration := range routing {
|
||||||
|
// electionModule declared REQUEST_ELECTION: its leader is published with the leader flag set.
|
||||||
|
if declaration.ModuleName == electionModule {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
require.False(declaration.Address.IsModuleLeader)
|
||||||
|
require.Equal(cluster.ModuleLeaderModeNone, declaration.ModuleLeaderMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return backendCreatedAtPassed(t, testDb, electionModule)
|
||||||
|
}, announceTimeout, announceTick, "created_at must be older than now to detect a move")
|
||||||
|
|
||||||
|
beforeReannounce, err := selectBackendRow(t, testDb, electionModule)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
err = electionCli.SendModuleReady(ctx)
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
reannouncedRow, err := selectBackendRow(t, testDb, electionModule)
|
||||||
|
require.NoError(err)
|
||||||
|
require.Equal(beforeReannounce.WsConnectionId, reannouncedRow.WsConnectionId)
|
||||||
|
require.Equal(beforeReannounce.CreatedAt, reannouncedRow.CreatedAt, "re-announcement must not move the instance")
|
||||||
|
require.Equal(cluster.ModuleLeaderModeRequestElection, reannouncedRow.moduleLeaderMode())
|
||||||
|
|
||||||
|
count := selectBackendCount(t, testDb, electionModule)
|
||||||
|
require.Equal(1, count.Total)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newClusterClientWithLeaderMode(
|
||||||
|
t *testing.T,
|
||||||
|
moduleName string,
|
||||||
|
host string,
|
||||||
|
moduleLeaderMode string,
|
||||||
|
logger log.Logger,
|
||||||
|
) *cluster.Client {
|
||||||
|
t.Helper()
|
||||||
|
return newClusterClientFull(
|
||||||
|
t,
|
||||||
|
moduleName,
|
||||||
|
host,
|
||||||
|
testModuleRemoteConfig{},
|
||||||
|
[]byte("{}"),
|
||||||
|
nil,
|
||||||
|
moduleLeaderMode,
|
||||||
|
logger,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runClusterClient(
|
||||||
|
ctx context.Context,
|
||||||
|
require *require.Assertions,
|
||||||
|
cli *cluster.Client,
|
||||||
|
handler *cluster.EventHandler,
|
||||||
|
) {
|
||||||
|
go func() {
|
||||||
|
err := cli.Run(ctx, handler)
|
||||||
|
require.NoError(err) //nolint:testifylint
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectBackendRow(t *testing.T, testDb db.DB, moduleName string) (backendRow, error) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
var row backendRow
|
||||||
|
err := testDb.SelectRow(t.Context(), &row, `
|
||||||
|
select ws_connection_id, created_at, module_leader_mode
|
||||||
|
from isp_config_service__backend
|
||||||
|
where module_name = ?`, moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return backendRow{}, errors.WithMessagef(err, "select backend row of module %s", moduleName)
|
||||||
|
}
|
||||||
|
|
||||||
|
return row, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireBackendRow(t *testing.T, testDb db.DB, moduleName string) backendRow {
|
||||||
|
t.Helper()
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
var row backendRow
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
stored, err := selectBackendRow(t, testDb, moduleName)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
row = stored
|
||||||
|
return true
|
||||||
|
}, announceTimeout, announceTick, "module %s announcement is not stored", moduleName)
|
||||||
|
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
|
||||||
|
func backendCreatedAtPassed(t *testing.T, testDb db.DB, moduleName string) bool {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
var row epochAdvancedRow
|
||||||
|
err := testDb.SelectRow(t.Context(), &row, `
|
||||||
|
select unixepoch() > created_at as advanced
|
||||||
|
from isp_config_service__backend
|
||||||
|
where module_name = ?`, moduleName)
|
||||||
|
|
||||||
|
return err == nil && row.Advanced == 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func selectBackendCount(t *testing.T, testDb db.DB, moduleName string) backendCountRow {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
row := backendCountRow{}
|
||||||
|
err := testDb.SelectRow(t.Context(), &row, `
|
||||||
|
select count(*) as total
|
||||||
|
from isp_config_service__backend
|
||||||
|
where module_name = ?`, moduleName)
|
||||||
|
require.New(t).NoError(err)
|
||||||
|
|
||||||
|
return row
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireAcceptedModules(require *require.Assertions, ctx context.Context, moduleNames ...string) {
|
||||||
|
apiCli, err := client.Default()
|
||||||
|
require.NoError(err)
|
||||||
|
apiCli.Upgrade([]string{"127.0.0.1:9002"})
|
||||||
|
|
||||||
|
modules := make([]domain.ModuleInfo, 0)
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
modules = modules[:0]
|
||||||
|
err = apiCli.Invoke("config/module/get_modules_info").
|
||||||
|
JsonResponseBody(&modules).
|
||||||
|
Do(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
connected := make([]string, 0, len(modules))
|
||||||
|
for _, module := range modules {
|
||||||
|
connected = append(connected, module.Name)
|
||||||
|
}
|
||||||
|
for _, moduleName := range moduleNames {
|
||||||
|
if !slices.Contains(connected, moduleName) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}, announceTimeout, announceTick, "announced modules must be visible in modules info")
|
||||||
|
|
||||||
|
for _, moduleName := range moduleNames {
|
||||||
|
module := findModule(modules, moduleName)
|
||||||
|
require.NotNil(module, moduleName)
|
||||||
|
require.Len(module.Status, 1, moduleName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func findModule(modules []domain.ModuleInfo, moduleName string) *domain.ModuleInfo {
|
||||||
|
for i := range modules {
|
||||||
|
if modules[i].Name == moduleName {
|
||||||
|
return &modules[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func requireReceivedRoutes(require *require.Assertions, handler *clusterEventHandler) []cluster.RoutingConfig {
|
||||||
|
require.Eventually(func() bool {
|
||||||
|
return len(handler.ReceivedRoutes()) > 0
|
||||||
|
}, announceTimeout, announceTick, "routing configuration must be received")
|
||||||
|
|
||||||
|
return handler.ReceivedRoutes()
|
||||||
|
}
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
package tests_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/txix-open/isp-kit/cluster"
|
||||||
|
"github.com/txix-open/isp-kit/grpc/client"
|
||||||
|
"github.com/txix-open/isp-kit/json"
|
||||||
|
"github.com/txix-open/isp-kit/test/fake"
|
||||||
|
"isp-config-service/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaultRemoteConfigsWithVariables = `
|
||||||
|
{
|
||||||
|
"varA": "_Var(varA)",
|
||||||
|
"varB": "_ToInt(_Var(varB))",
|
||||||
|
"varC": "{{ msp_pgsql_name }}"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
type configWithVars struct {
|
||||||
|
VarA string
|
||||||
|
VarB int
|
||||||
|
VarC string
|
||||||
|
}
|
||||||
|
|
||||||
|
// nolint:funlen,paralleltest
|
||||||
|
func TestVariableAcceptance(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
logger := setupTest(t)
|
||||||
|
|
||||||
|
apiCli, err := client.Default()
|
||||||
|
require.NoError(err)
|
||||||
|
apiCli.Upgrade([]string{"127.0.0.1:9002"})
|
||||||
|
varAValue := fake.It[string]()
|
||||||
|
varA := domain.CreateVariableRequest{
|
||||||
|
Name: "varA",
|
||||||
|
Description: fake.It[string](),
|
||||||
|
Type: "TEXT",
|
||||||
|
Value: varAValue,
|
||||||
|
}
|
||||||
|
err = apiCli.Invoke("config/variable/create").
|
||||||
|
JsonRequestBody(varA).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
err = apiCli.Invoke("config/variable/create").
|
||||||
|
JsonRequestBody(varA).
|
||||||
|
Do(t.Context())
|
||||||
|
require.Error(err)
|
||||||
|
|
||||||
|
varBValue := fake.It[int]()
|
||||||
|
err = apiCli.Invoke("config/variable/upsert").
|
||||||
|
JsonRequestBody([]domain.UpsertVariableRequest{{
|
||||||
|
Name: "varB",
|
||||||
|
Description: "test",
|
||||||
|
Type: "SECRET",
|
||||||
|
Value: strconv.Itoa(varBValue),
|
||||||
|
}}).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
eventHandler := newClusterEventHandler()
|
||||||
|
clientA1 := newClusterClientWith(
|
||||||
|
t,
|
||||||
|
"A",
|
||||||
|
"10.2.9.1",
|
||||||
|
configWithVars{},
|
||||||
|
[]byte(defaultRemoteConfigsWithVariables),
|
||||||
|
nil,
|
||||||
|
logger,
|
||||||
|
)
|
||||||
|
go func() {
|
||||||
|
handler := cluster.NewEventHandler().RemoteConfigReceiver(eventHandler)
|
||||||
|
err := clientA1.Run(t.Context(), handler)
|
||||||
|
require.NoError(err) //nolint:testifylint
|
||||||
|
}()
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
|
firstConfig := unmarshalConfig(require, eventHandler.ReceivedConfigs()[0])
|
||||||
|
expected := configWithVars{
|
||||||
|
VarA: varAValue,
|
||||||
|
VarB: varBValue,
|
||||||
|
VarC: "{{ msp_pgsql_name }}",
|
||||||
|
}
|
||||||
|
require.EqualValues(expected, firstConfig)
|
||||||
|
|
||||||
|
err = apiCli.Invoke("config/variable/delete").
|
||||||
|
JsonRequestBody(domain.VariableByNameRequest{Name: "varB"}).
|
||||||
|
Do(t.Context())
|
||||||
|
require.Error(err)
|
||||||
|
|
||||||
|
varBValue = fake.It[int]()
|
||||||
|
err = apiCli.Invoke("config/variable/upsert").
|
||||||
|
JsonRequestBody([]domain.UpsertVariableRequest{{
|
||||||
|
Name: "varB",
|
||||||
|
Description: "test",
|
||||||
|
Type: "SECRET",
|
||||||
|
Value: strconv.Itoa(varBValue),
|
||||||
|
}}).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
|
secondConfig := unmarshalConfig(require, eventHandler.ReceivedConfigs()[1])
|
||||||
|
expected = configWithVars{
|
||||||
|
VarA: varAValue,
|
||||||
|
VarB: varBValue,
|
||||||
|
VarC: "{{ msp_pgsql_name }}",
|
||||||
|
}
|
||||||
|
require.EqualValues(expected, secondConfig)
|
||||||
|
|
||||||
|
allResponse := []domain.Variable{}
|
||||||
|
err = apiCli.Invoke("config/variable/all").
|
||||||
|
JsonResponseBody(&allResponse).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
require.Len(allResponse, 2)
|
||||||
|
require.EqualValues(varAValue, allResponse[0].Value)
|
||||||
|
require.EqualValues("TEXT", allResponse[0].Type)
|
||||||
|
require.Empty(allResponse[1].Value) // secret
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint:funlen,paralleltest
|
||||||
|
func TestVariableLinksAfterConfigUpdate(t *testing.T) {
|
||||||
|
require := require.New(t)
|
||||||
|
logger := setupTest(t)
|
||||||
|
|
||||||
|
apiCli, err := client.Default()
|
||||||
|
require.NoError(err)
|
||||||
|
apiCli.Upgrade([]string{"127.0.0.1:9002"})
|
||||||
|
|
||||||
|
err = apiCli.Invoke("config/variable/create").
|
||||||
|
JsonRequestBody(domain.CreateVariableRequest{
|
||||||
|
Name: "linkVar",
|
||||||
|
Description: "test",
|
||||||
|
Type: "TEXT",
|
||||||
|
Value: fake.It[string](),
|
||||||
|
}).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
type linkTestConfig struct {
|
||||||
|
Addr string
|
||||||
|
Alias string
|
||||||
|
}
|
||||||
|
clientC := newClusterClientWith(
|
||||||
|
t,
|
||||||
|
"LinkTestModule",
|
||||||
|
"10.2.9.77",
|
||||||
|
linkTestConfig{},
|
||||||
|
[]byte(`{"addr":"init","alias":"init"}`),
|
||||||
|
nil,
|
||||||
|
logger,
|
||||||
|
)
|
||||||
|
go func() {
|
||||||
|
handler := cluster.NewEventHandler()
|
||||||
|
err := clientC.Run(t.Context(), handler)
|
||||||
|
require.NoError(err) //nolint:testifylint
|
||||||
|
}()
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
|
activeConfig := domain.Config{}
|
||||||
|
err = apiCli.Invoke("config/config/get_active_config_by_module_name").
|
||||||
|
JsonRequestBody(domain.GetByModuleNameRequest{ModuleName: "LinkTestModule"}).
|
||||||
|
JsonResponseBody(&activeConfig).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
// The same variable is referenced twice in the config data.
|
||||||
|
err = apiCli.Invoke("config/config/create_update_config").
|
||||||
|
JsonRequestBody(domain.CreateUpdateConfigRequest{
|
||||||
|
Id: activeConfig.Id,
|
||||||
|
Name: activeConfig.Name,
|
||||||
|
ModuleId: activeConfig.ModuleId,
|
||||||
|
Version: activeConfig.Version,
|
||||||
|
Data: []byte(`{"addr":"_Var(linkVar)","alias":"prefix/_Var(linkVar)"}`),
|
||||||
|
}).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
varResponse := []domain.Variable{}
|
||||||
|
err = apiCli.Invoke("config/variable/all").
|
||||||
|
JsonResponseBody(&varResponse).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
require.Len(varResponse, 1)
|
||||||
|
require.Equal("linkVar", varResponse[0].Name)
|
||||||
|
require.Len(varResponse[0].ContainsInConfigs, 1)
|
||||||
|
require.Equal(activeConfig.Id, varResponse[0].ContainsInConfigs[0].Id)
|
||||||
|
|
||||||
|
// Re-saving identical config data must keep the links.
|
||||||
|
err = apiCli.Invoke("config/config/create_update_config").
|
||||||
|
JsonRequestBody(domain.CreateUpdateConfigRequest{
|
||||||
|
Id: activeConfig.Id,
|
||||||
|
Name: activeConfig.Name,
|
||||||
|
ModuleId: activeConfig.ModuleId,
|
||||||
|
Version: activeConfig.Version,
|
||||||
|
Data: []byte(`{"alias":"prefix/_Var(linkVar)","addr":"_Var(linkVar)"}`),
|
||||||
|
}).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
|
||||||
|
varResponse = []domain.Variable{}
|
||||||
|
err = apiCli.Invoke("config/variable/all").
|
||||||
|
JsonResponseBody(&varResponse).
|
||||||
|
Do(t.Context())
|
||||||
|
require.NoError(err)
|
||||||
|
require.Len(varResponse[0].ContainsInConfigs, 1)
|
||||||
|
require.Equal(activeConfig.Id, varResponse[0].ContainsInConfigs[0].Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func unmarshalConfig(require *require.Assertions, configData []byte) configWithVars {
|
||||||
|
firstConfig := configWithVars{}
|
||||||
|
err := json.Unmarshal(configData, &firstConfig)
|
||||||
|
require.NoError(err)
|
||||||
|
return firstConfig
|
||||||
|
}
|
||||||
Reference in new issue
Block a user