Compare commits

...
17 Commits
Author SHA1 Message Date
txix 5e248d85fe 2025-06-06 17:09:42: merge [main:eb7997476085e283af784adf7ada881a3d37e535];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-06-06 17:09:42 +03:00
txix 7ec4962301 2025-06-06 16:56:57: merge [main:350d22ae7512add0069a2d5ac30546bd8b32d979]; 2025-06-06 16:56:57 +03:00
txix 6b7ddafa32 2025-05-27 14:44:20: merge [main:3e7f2358764cd22b6766b4ea57d14a429cfb06ab]; 2025-05-27 14:44:20 +03:00
txix 7ba1f0a5e8 2025-04-18 12:20:59: merge [main:aefc14ece9229d4d8e88c117a09f85d1a6775b46]; 2025-04-18 12:20:59 +03:00
txix 18205b2e66 2025-04-17 18:01:00: merge [main:0e6b5dec5225670f20a213993b54e1c0fcd44c63]; 2025-04-17 18:01:00 +03:00
txix 22baffabfb 2025-03-24 15:30:34: merge [main:7a1d8822489f02be3b825bb1224de48bab9c1657]; 2025-03-24 15:30:34 +03:00
txix 4a95b4b578 2024-12-27 16:47:46: merge [main:69567c48694f02359eecd8e696669f7c3de0b398]; 2024-12-27 16:47:46 +03:00
txix 0fbe723485 2024-12-12 13:56:05: merge [main:5fbfe1b039c8b70814b6262508bfeda3a8069dd2]; 2024-12-12 13:56:05 +03:00
txix e81f8c64cf 2024-11-27 12:16:06: merge [master:8f9dc2048fde1f9cb1c40e716e65dd91b77256b8]; 2024-11-27 12:16:06 +03:00
txix 802ce18a5e 2024-11-26 19:14:10: merge [master:16d2701e265c75b03df0b81a0cefc06bc9563e7a]; 2024-11-26 19:14:10 +03:00
txix 77244d4997 2024-11-20 14:39:28: merge [master:83355f8bbc6bf330c8f3d946415d732d2590d17d]; 2024-11-20 14:39:28 +03:00
txix 12b71a1777 2024-11-15 13:12:14: merge [master:93f2a5ed50211ee88fbdb241f4dbaa4af50d1d38]; 2024-11-15 13:12:14 +03:00
txix 1badb6b931 2024-04-24 17:59:21: merge [master:5e72ec386437c66661a2a98b1a232a3ad49af893]; 2024-04-24 17:59:21 +03:00
txix 14221f778c 2024-03-25 17:42:24: merge [master:e2419e2c4bf843e66dc679b387cbb6900599ee22]; 2024-03-25 17:42:24 +03:00
txix a5ca7b230a 2024-03-25 17:06:20: merge [master:72afc94782d802dbef7d4b1b092b6b1d02301edf]; 2024-03-25 17:06:20 +03:00
txix 3427a92d08 2024-03-25 16:52:24: merge [master:02070b1db1d2009dc917980dfc5e731e9508b8d0]; 2024-03-25 16:52:24 +03:00
txix ef7c017e4c 2024-03-25 16:23:54: merge [master:2fc6c7ba91a773e1055473094b8e3d7192bf4df4]; 2024-03-25 16:23:54 +03:00
155 changed files with 9671 additions and 4792 deletions

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
name: Create and publish a Docker image
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
APP_NAME: ${{ github.event.repository.name }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version from tag
id: version_reader
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_reader.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ steps.version_reader.outputs.version }}
build-args: |
app_name=${{ env.APP_NAME }}
version=${{ steps.version_reader.outputs.version }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
+6 -2
View File
@@ -9,8 +9,8 @@
.idea/**/tasks.xml
.idea/dictionaries
*.iml
config_service
config-service
convert_service
convert-service
# Sensitive or high-churn files:
.idea/**/dataSources/
@@ -69,3 +69,7 @@ fabric.properties
/node_modules/
/vendor/
package.json
yarn.lock
conf/config_dev.yml
+3
View File
@@ -0,0 +1,3 @@
include:
- project: '$CI_PROJECT_PATH'
file: '/ci-isp-go-service.yml'
+69
View File
@@ -0,0 +1,69 @@
version: "2"
run:
allow-parallel-runners: true
linters:
default: all
disable:
- contextcheck # не имеет смысла
- depguard # не всегда имеет смысл
- dupword # не имеет смысла
- exhaustruct # не имеет смысла
- godot # не актуально для swagger
- godox # не позволяет оставлять todo
- gomoddirectives
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
- nlreturn # не всегда имеет смысл
- nolintlint # Goland все равно форматирует с отступом
- perfsprint # мнимая производительность в угоду читаемости
- tagalign # не всегда имеет смысл
- varnamelen # очень индивидуально (db)
- wsl # расставление пробелов очень индивидуально
settings:
cyclop:
max-complexity: 15 # по умолчанию 10 мало
funlen:
lines: 80
lll:
line-length: 150
revive:
rules:
- name: var-naming # отключаем Id -> ID
disabled: true
staticcheck:
checks: # отключаем Id -> ID
- -ST1000
- -ST1016
- -ST1020
- -ST1021
- -ST1022
testifylint:
disable:
- compares
- equal-values
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- wrapcheck
path: controller # достаточное кол-во контекста на уровне контроллеров
- linters:
- wrapcheck
path: transaction # транзакции прозрачны
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
+1 -1
View File
@@ -1 +1 @@
0.3.0
3.3.1
+42
View File
@@ -0,0 +1,42 @@
FROM golang:1.24-alpine as builder
WORKDIR /build
ARG version
ENV version_env=$version
ARG app_name
ENV app_name_env=$app_name
COPY . .
RUN apk update && apk upgrade && apk add --no-cache gcc musl-dev
RUN go build -ldflags="-X 'main.version=$version_env'" -o /main .
WORKDIR cmd/migrate
RUN CGO_ENABLED=1 go build -o /migrate .
FROM alpine:3.21
RUN apk add --no-cache tzdata
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
RUN echo "Europe/Moscow" > /etc/timezone
COPY --from=builder migrate /migrate/migrate
COPY cmd/migrate/config.yml /migrate/config.yml
RUN chmod 666 /migrate/config.yml
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
USER appuser
WORKDIR /app
ARG app_name
ENV app_name_env=$app_name
COPY --from=builder main /app/$app_name_env
COPY /conf/config.yml /app/config.yml
COPY /conf/default_remote_config.json* /app/default_remote_config.json
COPY /migrations /app/migrations
ENTRYPOINT /app/$app_name_env
+41
View File
@@ -0,0 +1,41 @@
FROM dockerhub.mos.ru/mosos/arbat:15.5 as builder
RUN zypper --no-gpg-checks update -y && zypper --no-gpg-checks install -y go1.24 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 .
FROM dockerhub.mos.ru/mosos/arbat:15.5
RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime
RUN echo "Europe/Moscow" > /etc/timezone
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
Generated
-618
View File
@@ -1,618 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
digest = "1:e92f5581902c345eb4ceffdcd4a854fb8f73cf436d47d837d1ec98ef1fe0a214"
name = "github.com/StackExchange/wmi"
packages = ["."]
pruneopts = "UT"
revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338"
version = "1.0.0"
[[projects]]
digest = "1:320e7ead93de9fd2b0e59b50fd92a4d50c1f8ab455d96bc2eb083267453a9709"
name = "github.com/asaskevich/govalidator"
packages = ["."]
pruneopts = "UT"
revision = "ccb8e960c48f04d6935e72476ae4a51028f9e22f"
version = "v9"
[[projects]]
digest = "1:652880afc6b57ce0a67173f552cb35ccda816493a1da6ca20e5074a66bcd083f"
name = "github.com/buaazp/fasthttprouter"
packages = ["."]
pruneopts = "UT"
revision = "ade4e2031af3aed7fffd241084aad80a58faf421"
version = "v0.1.1"
[[projects]]
digest = "1:553f73a4171c265045ae4f5d3122429ecf2c9c0c232c91f336127fe45480104a"
name = "github.com/cenkalti/backoff"
packages = ["."]
pruneopts = "UT"
revision = "62661b46c4093e2c1f38d943e663db1a29873e80"
version = "v2.1.0"
[[projects]]
digest = "1:abeb38ade3f32a92943e5be54f55ed6d6e3b6602761d74b4aab4c9dd45c18abd"
name = "github.com/fsnotify/fsnotify"
packages = ["."]
pruneopts = "UT"
revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9"
version = "v1.4.7"
[[projects]]
digest = "1:64a5a67c69b70c2420e607a8545d674a23778ed9c3e80607bfd17b77c6c87f6a"
name = "github.com/go-ole/go-ole"
packages = [
".",
"oleutil",
]
pruneopts = "UT"
revision = "a41e3c4b706f6ae8dfbff342b06e40fa4d2d0506"
version = "v1.2.1"
[[projects]]
digest = "1:e7f1117ec9d37b59ba6d70bbd8feaa9cd2d1c6f676dc88ee152f5a57908fea4b"
name = "github.com/go-pg/pg"
packages = [
".",
"internal",
"internal/parser",
"internal/pool",
"orm",
"types",
]
pruneopts = "UT"
revision = "514bed76d8f579d6ff8d40294fa77e476a5c1b3f"
version = "v6.15.0"
[[projects]]
digest = "1:fa5e9e1af8a8645086811ec5ab003806026babc57c8bb3a6f7e1ab34b80e2ff1"
name = "github.com/golang/protobuf"
packages = [
"jsonpb",
"proto",
"protoc-gen-go/descriptor",
"ptypes",
"ptypes/any",
"ptypes/duration",
"ptypes/struct",
"ptypes/timestamp",
]
pruneopts = "UT"
revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
version = "v1.2.0"
[[projects]]
branch = "master"
digest = "1:324591cd9122f94cc39a87bd44ec71153672c239e2cff5743bfad96b60be3749"
name = "github.com/googollee/go-engine.io"
packages = [
".",
"message",
"parser",
"polling",
"transport",
"websocket",
]
pruneopts = "UT"
revision = "e2f255711dcb2ea41e42c6d9d98c172d7edf6509"
[[projects]]
branch = "master"
digest = "1:3eb026ba34d6dd12b45bb6abd63b4e917ebca8d8f3022a139c0881d900ad1bee"
name = "github.com/googollee/go-socket.io"
packages = ["."]
pruneopts = "UT"
revision = "c8aeb1ed9b49d7de8fef8662efb18f1d289c5f2e"
[[projects]]
digest = "1:7b5c6e2eeaa9ae5907c391a91c132abfd5c9e8a784a341b5625e750c67e6825d"
name = "github.com/gorilla/websocket"
packages = ["."]
pruneopts = "UT"
revision = "66b9c49e59c6c48f0ffce28c2d8b8a5678502c6d"
version = "v1.4.0"
[[projects]]
digest = "1:d544928ef5b57ff39325b4fea31f262db66c9241324aee38ba55dfe3e836e2c8"
name = "github.com/grpc-ecosystem/grpc-gateway"
packages = [
"runtime",
"runtime/internal",
"utilities",
]
pruneopts = "UT"
revision = "e8bd377da7395186f2f042ee6b366fa5a11d2b39"
[[projects]]
digest = "1:c0d19ab64b32ce9fe5cf4ddceba78d5bc9807f0016db6b1183599da3dcc24d10"
name = "github.com/hashicorp/hcl"
packages = [
".",
"hcl/ast",
"hcl/parser",
"hcl/printer",
"hcl/scanner",
"hcl/strconv",
"hcl/token",
"json/parser",
"json/scanner",
"json/token",
]
pruneopts = "UT"
revision = "8cb6e5b959231cc1119e43259c4a608f9c51a241"
version = "v1.0.0"
[[projects]]
branch = "master"
digest = "1:1b1d9534e35d61e861a7356f7f2d766e57e2777dbf79be60e1ac56bbd60adf51"
name = "github.com/integration-system/go-cmp"
packages = [
"cmp",
"cmp/internal/diff",
"cmp/internal/function",
"cmp/internal/value",
]
pruneopts = "UT"
revision = "ed1c8d9bf7906aec13cf28080fdf069d7687471a"
[[projects]]
branch = "master"
digest = "1:9e2fd899fdb17e28e9d036fe7a604a1e04918aa4865d5a2150008fc12c6134be"
name = "github.com/integration-system/golang-socketio"
packages = [
".",
"protocol",
"transport",
]
pruneopts = "UT"
revision = "5959fcea049facd9441fff9de976191accd3cf9f"
[[projects]]
branch = "master"
digest = "1:900583da99fb5a30a9c3b829bab8acca29a9474d5b40a5c3cb28e7bc7cd27788"
name = "github.com/integration-system/isp-lib"
packages = [
"backend",
"bootstrap",
"config",
"config/schema",
"controller",
"database",
"http",
"logger",
"metric",
"proto/stubs",
"socket",
"streaming",
"structure",
"utils",
]
pruneopts = "UT"
revision = "0f71aaf83133a59c9fc143faecbd38b86ed068e2"
[[projects]]
branch = "master"
digest = "1:a992b3ab79433b828258f9fe99af29da5aeb2e48bf8076a41ba556ac90ac04d3"
name = "github.com/integration-system/jsonschema"
packages = ["."]
pruneopts = "UT"
revision = "170a88febd847f36821e99ec54a095e6cec48528"
[[projects]]
branch = "master"
digest = "1:fd97437fbb6b7dce04132cf06775bd258cce305c44add58eb55ca86c6c325160"
name = "github.com/jinzhu/inflection"
packages = ["."]
pruneopts = "UT"
revision = "04140366298a54a039076d798123ffa108fff46c"
[[projects]]
digest = "1:5d713dbcad44f3358fec51fd5573d4f733c02cac5a40dcb177787ad5ffe9272f"
name = "github.com/json-iterator/go"
packages = [
".",
"extra",
]
pruneopts = "UT"
revision = "1624edc4454b8682399def8740d46db5e4362ba4"
version = "v1.1.5"
[[projects]]
digest = "1:aaa8e0e7e35d92e21daed3f241832cee73d15ca1cd3302ba3843159a959a7eac"
name = "github.com/klauspost/compress"
packages = [
"flate",
"gzip",
"zlib",
]
pruneopts = "UT"
revision = "30be6041bed523c18e269a700ebd9c2ea9328574"
version = "v1.4.1"
[[projects]]
digest = "1:2d643962fac133904694fffa959bc3c5dcfdcee38c6f5ffdd99a3c93eb9c835c"
name = "github.com/klauspost/cpuid"
packages = ["."]
pruneopts = "UT"
revision = "e7e905edc00ea8827e58662220139109efea09db"
version = "v1.2.0"
[[projects]]
digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
name = "github.com/konsorten/go-windows-terminal-sequences"
packages = ["."]
pruneopts = "UT"
revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242"
version = "v1.0.1"
[[projects]]
digest = "1:8ef506fc2bb9ced9b151dafa592d4046063d744c646c1bbe801982ce87e4bc24"
name = "github.com/lib/pq"
packages = [
".",
"oid",
]
pruneopts = "UT"
revision = "4ded0e9383f75c197b3a2aaa6d590ac52df6fd79"
version = "v1.0.0"
[[projects]]
digest = "1:c568d7727aa262c32bdf8a3f7db83614f7af0ed661474b24588de635c20024c7"
name = "github.com/magiconair/properties"
packages = ["."]
pruneopts = "UT"
revision = "c2353362d570a7bfa228149c62842019201cfb71"
version = "v1.8.0"
[[projects]]
digest = "1:c658e84ad3916da105a761660dcaeb01e63416c8ec7bc62256a9b411a05fcd67"
name = "github.com/mattn/go-colorable"
packages = ["."]
pruneopts = "UT"
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
version = "v0.0.9"
[[projects]]
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
name = "github.com/mattn/go-isatty"
packages = ["."]
pruneopts = "UT"
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.4"
[[projects]]
branch = "master"
digest = "1:2b32af4d2a529083275afc192d1067d8126b578c7a9613b26600e4df9c735155"
name = "github.com/mgutz/ansi"
packages = ["."]
pruneopts = "UT"
revision = "9520e82c474b0a04dd04f8a40959027271bab992"
[[projects]]
digest = "1:53bc4cd4914cd7cd52139990d5170d6dc99067ae31c56530621b18b35fc30318"
name = "github.com/mitchellh/mapstructure"
packages = ["."]
pruneopts = "UT"
revision = "3536a929edddb9a5b34bd6861dc4a9647cb459fe"
version = "v1.1.2"
[[projects]]
digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563"
name = "github.com/modern-go/concurrent"
packages = ["."]
pruneopts = "UT"
revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94"
version = "1.0.3"
[[projects]]
digest = "1:e32bdbdb7c377a07a9a46378290059822efdce5c8d96fe71940d87cb4f918855"
name = "github.com/modern-go/reflect2"
packages = ["."]
pruneopts = "UT"
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
version = "1.0.1"
[[projects]]
branch = "master"
digest = "1:84bd7f8a2e0bcd53ddc33c3b47c34c1fe340c8632cbe928f7f8ae10ec6ecdd62"
name = "github.com/mohae/deepcopy"
packages = ["."]
pruneopts = "UT"
revision = "c48cc78d482608239f6c4c92a4abd87eb8761c90"
[[projects]]
digest = "1:95741de3af260a92cc5c7f3f3061e85273f5a81b5db20d4bd68da74bd521675e"
name = "github.com/pelletier/go-toml"
packages = ["."]
pruneopts = "UT"
revision = "c01d1270ff3e442a8a57cddc1c92dc1138598194"
version = "v1.2.0"
[[projects]]
digest = "1:d4c5d57ac0163eb71e09f1a94ca998961668700232f948d47a6269c8d7651d38"
name = "github.com/pressly/goose"
packages = ["."]
pruneopts = "UT"
revision = "7a98874933001af28951c83e958b1db750f39f8d"
version = "v2.4.5"
[[projects]]
branch = "master"
digest = "1:d38f81081a389f1466ec98192cf9115a82158854d6f01e1c23e2e7554b97db71"
name = "github.com/rcrowley/go-metrics"
packages = ["."]
pruneopts = "UT"
revision = "3113b8401b8a98917cde58f8bbd42a1b1c03b1fd"
[[projects]]
digest = "1:564e4136357b9d481ad8eb9d87f7fc144a28bb41cb0e29e739db3535e2d87575"
name = "github.com/shirou/gopsutil"
packages = [
"cpu",
"internal/common",
]
pruneopts = "UT"
revision = "0f70a4a06f7a1039305ec9b3ba9c2800f8929fba"
version = "v2.18.11"
[[projects]]
digest = "1:69b1cc331fca23d702bd72f860c6a647afd0aa9fcbc1d0659b1365e26546dd70"
name = "github.com/sirupsen/logrus"
packages = ["."]
pruneopts = "UT"
revision = "bcd833dfe83d3cebad139e4a29ed79cb2318bf95"
version = "v1.2.0"
[[projects]]
digest = "1:6a4a11ba764a56d2758899ec6f3848d24698d48442ebce85ee7a3f63284526cd"
name = "github.com/spf13/afero"
packages = [
".",
"mem",
]
pruneopts = "UT"
revision = "d40851caa0d747393da1ffb28f7f9d8b4eeffebd"
version = "v1.1.2"
[[projects]]
digest = "1:08d65904057412fc0270fc4812a1c90c594186819243160dc779a402d4b6d0bc"
name = "github.com/spf13/cast"
packages = ["."]
pruneopts = "UT"
revision = "8c9545af88b134710ab1cd196795e7f2388358d7"
version = "v1.3.0"
[[projects]]
digest = "1:68ea4e23713989dc20b1bded5d9da2c5f9be14ff9885beef481848edd18c26cb"
name = "github.com/spf13/jwalterweatherman"
packages = ["."]
pruneopts = "UT"
revision = "4a4406e478ca629068e7768fc33f3f044173c0a6"
version = "v1.0.0"
[[projects]]
digest = "1:c1b1102241e7f645bc8e0c22ae352e8f0dc6484b6cb4d132fa9f24174e0119e2"
name = "github.com/spf13/pflag"
packages = ["."]
pruneopts = "UT"
revision = "298182f68c66c05229eb03ac171abe6e309ee79a"
version = "v1.0.3"
[[projects]]
digest = "1:214775c11fd26da94a100111a62daa25339198a4f9c57cb4aab352da889f5b93"
name = "github.com/spf13/viper"
packages = ["."]
pruneopts = "UT"
revision = "2c12c60302a5a0e62ee102ca9bc996277c2f64f5"
version = "v1.2.1"
[[projects]]
branch = "master"
digest = "1:d32b64a7a82dd36b674fb73ff767e949eb7155b6b574ff276f49d4edc8af105f"
name = "github.com/thecodeteam/goodbye"
packages = ["."]
pruneopts = "UT"
revision = "a83968bda2d37294a3541b7d2207fb6f5a3559a3"
[[projects]]
digest = "1:c468422f334a6b46a19448ad59aaffdfc0a36b08fdcc1c749a0b29b6453d7e59"
name = "github.com/valyala/bytebufferpool"
packages = ["."]
pruneopts = "UT"
revision = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7"
version = "v1.0.0"
[[projects]]
branch = "master"
digest = "1:c911cc6a838b0d6be5de154aaea7b36530d5c97e019c3bb56b67fa8531aa17df"
name = "github.com/valyala/fasthttp"
packages = [
".",
"fasthttputil",
"stackless",
]
pruneopts = "UT"
revision = "1d2d99cba311e04b8d58f5d113ee07086c3e64f6"
[[projects]]
branch = "master"
digest = "1:c83590426ecf1362e77a9054afed570b201de1a353398a6157ecce06583ea024"
name = "github.com/vmihailenco/sasl"
packages = ["."]
pruneopts = "UT"
revision = "2f13c189728a02f8cc31b3b9cc06047b383c21cc"
[[projects]]
digest = "1:39a425f98fb19427061a693fe6bf0683c9bddec4b25b17067e34fdb465e39cb9"
name = "github.com/x-cray/logrus-prefixed-formatter"
packages = ["."]
pruneopts = "UT"
revision = "bb2702d423886830dee131692131d35648c382e2"
version = "v0.5.2"
[[projects]]
branch = "master"
digest = "1:9ff2b9f8d4e47013a213b9ea0d850ed787c51f5eab2038842d82397ad85a19c1"
name = "golang.org/x/crypto"
packages = [
"pbkdf2",
"ssh/terminal",
]
pruneopts = "UT"
revision = "505ab145d0a99da450461ae2c1a9f6cd10d1f447"
[[projects]]
branch = "master"
digest = "1:7a2e3d6819e7a97a877f8604e737901c6941e76d56ae98a51a1ca2f13de351fb"
name = "golang.org/x/net"
packages = [
"context",
"http/httpguts",
"http2",
"http2/hpack",
"idna",
"internal/timeseries",
"trace",
]
pruneopts = "UT"
revision = "351d144fa1fc0bd934e2408202be0c29f25e35a0"
[[projects]]
branch = "master"
digest = "1:b9dceb1408ba5105803d5859193bc7d89ac3199b611cf8681dbaa0aa09c10d9c"
name = "golang.org/x/sys"
packages = [
"unix",
"windows",
]
pruneopts = "UT"
revision = "a5c9d58dba9a56f97aaa86f55e638b718c5a6c42"
[[projects]]
digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18"
name = "golang.org/x/text"
packages = [
"collate",
"collate/build",
"internal/colltab",
"internal/gen",
"internal/tag",
"internal/triegen",
"internal/ucd",
"language",
"secure/bidirule",
"transform",
"unicode/bidi",
"unicode/cldr",
"unicode/norm",
"unicode/rangetable",
]
pruneopts = "UT"
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
branch = "master"
digest = "1:6aec038013fe4a5de91d89b51283cd0ddc0b8ed60ac58e0a173a9d8cf39438c5"
name = "google.golang.org/genproto"
packages = [
"googleapis/api/annotations",
"googleapis/rpc/errdetails",
"googleapis/rpc/status",
]
pruneopts = "UT"
revision = "bd91e49a0898e27abb88c339b432fa53d7497ac0"
[[projects]]
digest = "1:9edd250a3c46675d0679d87540b30c9ed253b19bd1fd1af08f4f5fb3c79fc487"
name = "google.golang.org/grpc"
packages = [
".",
"balancer",
"balancer/base",
"balancer/roundrobin",
"binarylog/grpc_binarylog_v1",
"codes",
"connectivity",
"credentials",
"credentials/internal",
"encoding",
"encoding/proto",
"grpclog",
"internal",
"internal/backoff",
"internal/binarylog",
"internal/channelz",
"internal/envconfig",
"internal/grpcrand",
"internal/grpcsync",
"internal/syscall",
"internal/transport",
"keepalive",
"metadata",
"naming",
"peer",
"resolver",
"resolver/dns",
"resolver/passthrough",
"stats",
"status",
"tap",
]
pruneopts = "UT"
revision = "df014850f6dee74ba2fc94874043a9f3f75fbfd8"
version = "v1.17.0"
[[projects]]
digest = "1:c805e517269b0ba4c21ded5836019ed7d16953d4026cb7d00041d039c7906be9"
name = "gopkg.in/natefinch/lumberjack.v2"
packages = ["."]
pruneopts = "UT"
revision = "a96e63847dc3c67d17befa69c303767e2f84e54f"
version = "v2.1"
[[projects]]
digest = "1:4d2e5a73dc1500038e504a8d78b986630e3626dc027bc030ba5c75da257cdb96"
name = "gopkg.in/yaml.v2"
packages = ["."]
pruneopts = "UT"
revision = "51d6538a90f86fe93ac480b35f37b2be17fef232"
version = "v2.2.2"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
input-imports = [
"github.com/asaskevich/govalidator",
"github.com/cenkalti/backoff",
"github.com/go-pg/pg",
"github.com/go-pg/pg/orm",
"github.com/golang/protobuf/proto",
"github.com/golang/protobuf/ptypes/struct",
"github.com/googollee/go-socket.io",
"github.com/grpc-ecosystem/grpc-gateway/runtime",
"github.com/grpc-ecosystem/grpc-gateway/utilities",
"github.com/integration-system/isp-lib/backend",
"github.com/integration-system/isp-lib/bootstrap",
"github.com/integration-system/isp-lib/config",
"github.com/integration-system/isp-lib/config/schema",
"github.com/integration-system/isp-lib/controller",
"github.com/integration-system/isp-lib/database",
"github.com/integration-system/isp-lib/logger",
"github.com/integration-system/isp-lib/metric",
"github.com/integration-system/isp-lib/socket",
"github.com/integration-system/isp-lib/structure",
"github.com/integration-system/isp-lib/utils",
"github.com/valyala/fasthttp",
"golang.org/x/net/context",
"google.golang.org/genproto/googleapis/api/annotations",
"google.golang.org/grpc",
"google.golang.org/grpc/codes",
"google.golang.org/grpc/grpclog",
"google.golang.org/grpc/status",
]
solver-name = "gps-cdcl"
solver-version = 1
-33
View File
@@ -1,33 +0,0 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[prune]
go-tests = true
unused-packages = true
[[constraint]]
name = "github.com/grpc-ecosystem/grpc-gateway"
revision = "e8bd377da7395186f2f042ee6b366fa5a11d2b39"
+1 -91
View File
@@ -1,92 +1,2 @@
## Contents
## [1. Installing](#installing)
## [2. Using](#using)
## [3. Environment variables](#environment-variables)
# isp-config-service
## Installing
### 1. Download dependencies
```
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go
```
### 2. Generate GRPC, GRPC-gateway, GRPC-gateway-swagger
###### WINDOWS
```cmd
protoc ^
-I. -I%GOPATH%\src ^
-I%GOPATH%\src\github.com\grpc-ecosystem\grpc-gateway\third_party\googleapis ^
--go_out=plugins=grpc:. --grpc-gateway_out=logtostderr=true:. --swagger_out=logtostderr=true:. ^
proto\config_service.proto
```
###### LINUX
```bash
protoc -I. \
-I$GOPATH \
-I$GOPATH/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--go_out=plugins=grpc:. --grpc-gateway_out=logtostderr=true:. --swagger_out=logtostderr=true:. \
proto/config_service.proto
```
## Using
### 1. GRPC
Default GRPC port is: `5001`, might be changed in config file
Proto file is: `proto/config_service.proto`
### 2. REST proxy to GRPC
Default port is: `5000`, might be changed in config file
Swagger work on http://0.0.0.0:5000/swagger
### 3. SocketIO
For connect to this server two variables must be sent in query path:
1. `module_name` - Module name, for example `auth`.
2. `instance_uuid` - UUID - instance identity.
#### Events
##### Event to a client
`CONFIG:SEND_CONFIG_WHEN_CONNECTED` - When a connection is established to a client will send an event.
`CONFIG:SEND_CONFIG_CHANGED` - When config for particular module had been changed this event with new config will send to a client.
`CONFIG:SEND_CONFIG_ON_REQUEST` - the server will send to a client actual config with this event after `CONFIG:REQUEST_CONFIG`
###### The next events work on both sides. First, when new backend publishes new methods at config service there is incoming one of this events:
`ROUTES:SEND_ROUTES_WHEN_CONNECTED` - A backend sends this event when a connection is established with a config server.
`ROUTES:SEND_ROUTES_CHANGED` - Any module can say that something had changed in its methods.
`ROUTES:SEND_ROUTES_ON_REQUEST` - A config service is able to make a request to renew list methods.
###### A config service, in turn, send the same events types in each its connection.
For all of this events we wait for next data structure:
```json
{
"address": {
"ip": "10.10.10.10",
"port": "5001"
},
"endpoints": [
{"path": "/api/user/get"},
{"path": "/api/user/save"},
{"path": "/api/user/delete"}
]
}
```
##### Event to the server
`CONFIG:REQUEST_CONFIG` - A client can request current config with this event.
## Environment variables
`APP_PROFILE` - Name for config file, default is `config`. Will seek file with name: `config.yml`.
`APP_CONFIG_PATH` - Absolute path where a config file is. If a variable hadn't been specified config will seek into the same directory, when binary file placed.
`LOG_LEVEL` - Log level, the default is `INFO`.
`APP_MODE` - If set to `dev` logger for SQL will be on and if `LOG_LEVEL` hadn't been specified it will set to `DEBUG`.
## Changes
#### 0.2.2 - 2018-10-05
- Add default config for mdm module
+190
View File
@@ -0,0 +1,190 @@
package assembly
import (
"context"
"net/http"
"net/http/httputil"
"net/url"
"time"
"isp-config-service/conf"
"isp-config-service/service/module/backend"
"isp-config-service/service/variable"
"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"
"isp-config-service/controller"
"isp-config-service/controller/api"
"isp-config-service/repository"
"isp-config-service/routes"
apisvs "isp-config-service/service/api"
"isp-config-service/service/event"
"isp-config-service/service/module"
"isp-config-service/service/rqlite/db"
"isp-config-service/service/subscription"
)
const (
wsReadLimit = 4 * 1024 * 1024
handleEventsInterval = 500 * time.Millisecond
cleanEventInterval = 60 * time.Second
cleanPhantomBackendsInterval = 5 * time.Minute
eventTtl = 60 * time.Second
)
type LocalConfig struct {
Local conf.Local
RqliteAddress string
}
type Locator struct {
db db.DB
cfg LocalConfig
leaderChecker LeaderChecker
logger log.Logger
}
type LeaderChecker interface {
IsLeader() bool
}
type OwnBackendsCleaner interface {
DeleteOwnBackends(ctx context.Context)
}
func NewLocator(
db db.DB,
leaderChecker LeaderChecker,
cfg LocalConfig,
logger log.Logger,
) Locator {
return Locator{
db: db,
leaderChecker: leaderChecker,
cfg: cfg,
logger: logger,
}
}
type Config struct {
GrpcMux *grpc.Mux
HttpMux http.Handler
EtpSrv *etp.Server
HandleEventWorker *worker.Worker
CleanEventWorker *worker.Worker
CleanPhantomBackendWorker *worker.Worker
OwnBackendsCleaner OwnBackendsCleaner
}
//nolint:funlen
func (l Locator) Config() *Config {
moduleRepo := repository.NewModule(l.db)
backendRepo := repository.NewBackend(l.db)
eventRepo := repository.NewEvent(l.db)
configRepo := repository.NewConfig(l.db)
configSchemaRepo := repository.NewConfigSchema(l.db)
configHistoryRepo := repository.NewConfigHistory(l.db)
variableRepo := repository.NewVariable(l.db)
variableService := variable.NewService(variableRepo, configRepo, eventRepo)
variableController := api.NewVariable(variableService)
etpSrv := etp.NewServer(
etp.WithServerReadLimit(wsReadLimit),
etp.WithServerAcceptOptions(&etp.AcceptOptions{
InsecureSkipVerify: true,
}),
)
emitter := module.NewEmitter(l.logger)
subscriptionService := subscription.NewService(
moduleRepo,
backendRepo,
configRepo,
etpSrv.Rooms(),
emitter,
variableService,
l.logger,
)
backendService := backend.NewBackend(
backendRepo,
eventRepo,
l.cfg.Local.Rqlite.NodeId,
etpSrv.Rooms(),
l.logger,
)
cleanPhantomBackendJob := backend.NewCleaner(backendService, l.logger)
cleanPhantomBackendWorker := worker.New(cleanPhantomBackendJob, worker.WithInterval(cleanPhantomBackendsInterval))
moduleService := module.NewService(
moduleRepo,
backendService,
configRepo,
configSchemaRepo,
subscriptionService,
emitter,
variableService,
l.logger,
)
moduleController := controller.NewModule(moduleService, l.logger)
configHistoryApiService := apisvs.NewConfigHistory(configRepo, configHistoryRepo, l.cfg.Local.KeepConfigVersions, l.logger)
configHistoryController := api.NewConfigHistory(configHistoryApiService)
moduleApiService := apisvs.NewModule(moduleRepo, backendRepo, configSchemaRepo)
moduleApiController := api.NewModule(moduleApiService)
configApiService := apisvs.NewConfig(
configRepo,
moduleRepo,
configSchemaRepo,
eventRepo,
configHistoryApiService,
variableService,
l.logger,
)
configApiController := api.NewConfig(configApiService)
configSchemaApiService := apisvs.NewConfigSchema(configSchemaRepo)
configSchemaController := api.NewConfigSchema(configSchemaApiService)
controllers := routes.Controllers{
Module: moduleController,
ModuleApi: moduleApiController,
ConfigApi: configApiController,
ConfigHistoryApi: configHistoryController,
ConfigSchemaApi: configSchemaController,
VariableApi: variableController,
}
mapper := endpoint.DefaultWrapper(l.logger)
grpcMux := routes.GrpcHandler(mapper, controllers)
routes.BindEtp(etpSrv, controllers, l.logger)
rqliteUrl, err := url.Parse(l.cfg.RqliteAddress)
if err != nil {
panic(err)
}
rqliteProxy := httputil.NewSingleHostReverseProxy(rqliteUrl)
httpMux := routes.HttpHandler(etpSrv, l.cfg.Local, rqliteProxy)
eventHandler := event.NewHandler(subscriptionService, l.logger)
handleEventJob := event.NewWorker(eventRepo, eventHandler, l.logger)
handleEventWorker := worker.New(handleEventJob, worker.WithInterval(handleEventsInterval))
cleanerJob := event.NewCleaner(eventRepo, l.leaderChecker, eventTtl, l.logger)
cleanEventWorker := worker.New(cleanerJob, worker.WithInterval(cleanEventInterval))
return &Config{
GrpcMux: grpcMux,
EtpSrv: etpSrv,
HttpMux: httpMux,
HandleEventWorker: handleEventWorker,
CleanEventWorker: cleanEventWorker,
CleanPhantomBackendWorker: cleanPhantomBackendWorker,
OwnBackendsCleaner: backendService,
}
}
+22
View File
@@ -0,0 +1,22 @@
## v3.3.1
* добавлен скрипт для сборки и публикации образа в `GitHub Contaier Registry`
* обновлены зависимости
## v3.3.0
* обновлены зависимости
* добавлен новый эндпоинт `config/config/update_config_name` для изменения названия конфигурации без повышения версии и рассылки события
* теперь эндпоинт `config/config/get_all_version` первым элементом возвращает актуальную версию конфигурации
* добавлен новый эндпоинт `/config/config/sync` для синхронизации актуальной конфигурации пришедшего модуля
* добавлена оптимизация в `config/config/create_update_config`: если в запросе `data` и `name` не отличаются от текущей версии конфигурации, то событие логируется на уровне `info` без обновления конфигурации; возвращается текущая версия конфигурации
## v3.2.0
* добавлена поддержка переменных в конфигурациях
## v3.1.2
* возвращена поддержка rqlite.DiscoMode `dns` и `dns-srv`
* добавлена поддержка работы в `kubernetes` c autodiscovery
## v3.1.1
* инструмент миграции перенесен внутрь контейнера
## v3.1.0
* добавлено возможность анонсировать несколько бекендов с одинаковыми адресами
* реализован механизм поиска и очистки фантомных бекендов (те который отключились, но остались висеть в таблице маршрутизации)
* добавлена очистка таблицы маршрутизации в момент отключения самого модуля
## v3.0.2
* Новая реализация модуля на базе rqlite
+12
View File
@@ -0,0 +1,12 @@
db:
host: 127.0.0.1
port: 5432
database: test
username: test
password: test
schema: config_service
newConfigService:
address: http://127.0.0.1:9001/
username: default
password: test
+43
View File
@@ -0,0 +1,43 @@
package main
import (
"time"
"github.com/txix-open/isp-kit/json"
)
type Module struct {
Id string
Name string
LastConnectedAt *time.Time
LastDisconnectedAt *time.Time
CreatedAt time.Time
}
type Config struct {
Id string
ModuleId string
Name string
Version int
Active bool
Data json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
type ConfigHistory struct {
Id string
ConfigId string
ConfigVersion int
Data json.RawMessage
CreatedAt time.Time
}
type ConfigSchema struct {
Id string
ModuleId string
Version string
Schema json.RawMessage
CreatedAt time.Time
UpdatedAt time.Time
}
+76
View File
@@ -0,0 +1,76 @@
module isp-config-service/migrate
go 1.24
replace isp-config-service => ../..
require (
github.com/jmoiron/sqlx v1.4.0
github.com/mattn/go-sqlite3 v1.14.24
github.com/pkg/errors v0.9.1
github.com/pressly/goose/v3 v3.24.3
github.com/txix-open/isp-kit v1.51.0
isp-config-service v0.0.0-00010101000000-000000000000
)
require (
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.13 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.4 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_golang v1.22.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.64.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/tidwall/gjson v1.18.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/txix-open/bellows v1.2.0 // indirect
github.com/txix-open/etp/v4 v4.0.1 // indirect
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0 // indirect
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 // indirect
go.opentelemetry.io/otel/metric v1.36.0 // indirect
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.opentelemetry.io/proto/otlp v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
google.golang.org/grpc v1.72.2 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+214
View File
@@ -0,0 +1,214 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8=
github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/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/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/getsentry/sentry-go v0.33.0 h1:YWyDii0KGVov3xOaamOnF0mjOrqSjBqwv48UEzn7QFg=
github.com/getsentry/sentry-go v0.33.0/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE=
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.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/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.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU=
github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg=
github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pressly/goose/v3 v3.24.3 h1:DSWWNwwggVUsYZ0X2VitiAa9sKuqtBfe+Jr9zFGwWlM=
github.com/pressly/goose/v3 v3.24.3/go.mod h1:v9zYL4xdViLHCUUJh/mhjnm6JrK7Eul8AS93IxiZM4E=
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQPGO4=
github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
github.com/txix-open/isp-kit v1.51.0 h1:sSDs/M5EaAiIJGbefRprbZH2GgCfdjwgpUV94NWd73A=
github.com/txix-open/isp-kit v1.51.0/go.mod h1:OkscabRkpFGjUOFrbPM7yTKD/Br2/iv5/PWr/T2Jtd4=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0 h1:lREC4C0ilyP4WibDhQ7Gg2ygAQFP8oR07Fst/5cafwI=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0/go.mod h1:HfvuU0kW9HewH14VCOLImqKvUgONodURG7Alj/IrnGI=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 h1:dNzwXjZKpMpE2JhmO+9HsPl42NIXFIFSUSSs0fiqra0=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0/go.mod h1:90PoxvaEB5n6AOdZvi+yWJQoE95U8Dhhw2bSyRqnTD0=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 h1:nRVXXvf78e00EwY6Wp0YII8ww2JVWshZ20HfTlE11AM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0/go.mod h1:r49hO7CgrxY9Voaj3Xe8pANWtr0Oq916d0XAmOoCZAQ=
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
go.opentelemetry.io/proto/otlp v1.6.0 h1:jQjP+AQyTf+Fe7OKj/MfkDrmK4MNVtw2NpXsf9fefDI=
go.opentelemetry.io/proto/otlp v1.6.0/go.mod h1:cicgGehlFuNdgZkcALOCh3VE6K/u2tAjzlRhDwmVpZc=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0=
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8=
google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/libc v1.65.0 h1:e183gLDnAp9VJh6gWKdTy0CThL9Pt7MfcR/0bgb7Y1Y=
modernc.org/libc v1.65.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.10.0 h1:fzumd51yQ1DxcOxSO+S6X7+QTuVU+n8/Aj7swYjFfC4=
modernc.org/memory v1.10.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
+204
View File
@@ -0,0 +1,204 @@
package main
import (
"context"
"database/sql"
"fmt"
"os"
"time"
"github.com/pressly/goose/v3"
"github.com/txix-open/isp-kit/config"
"github.com/txix-open/isp-kit/dbx"
"github.com/txix-open/isp-kit/http/httpcli"
"github.com/txix-open/isp-kit/http/httpclix"
"github.com/txix-open/isp-kit/log"
"github.com/txix-open/isp-kit/validator"
"isp-config-service/service/rqlite/goose_store"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/app"
"github.com/txix-open/isp-kit/db"
"isp-config-service/entity"
"isp-config-service/entity/xtypes"
"isp-config-service/migrate/migration"
"isp-config-service/migrations"
"isp-config-service/repository"
)
type Cfg struct {
Db dbx.Config
NewConfigService struct {
Address string
Username string
Password string
}
}
type dbClient struct {
*db.Client
}
func (d dbClient) ExecTransaction(ctx context.Context, requests [][]any) ([]sql.Result, error) {
panic("implement me")
}
func main() {
app, err := app.New(app.WithConfigOptions(
config.WithValidator(validator.Default),
config.WithExtraSource(config.NewYamlConfig("config.yml")),
))
if err != nil {
panic(err)
}
logger := app.Logger()
logger.SetLevel(log.DebugLevel)
ctx := app.Context()
cfg := Cfg{}
err = app.Config().Read(&cfg)
if err != nil {
panic(errors.WithMessage(err, "read config"))
}
pgDb, err := dbx.Open(ctx, cfg.Db, dbx.WithQueryTracer(dbx.NewLogTracer(logger)))
if err != nil {
panic(err)
}
defer pgDb.Close()
fileName := fmt.Sprintf("db_%d.sqlite", time.Now().Unix())
dbClient := dbClient{&db.Client{}}
dbClient.DB, err = sqlx.Open("sqlite3", fileName)
dbClient.DB.MapperFunc(db.ToSnakeCase)
if err != nil {
panic(errors.WithMessage(err, "err opening db"))
}
defer dbClient.Close()
migrationStore := goose_store.NewStore(dbClient.DB.DB)
mr := migration.NewRunner("", migrations.Migrations, logger)
err = mr.Run(ctx, dbClient.DB.DB, goose.WithStore(migrationStore))
if err != nil {
panic(errors.WithMessage(err, "err connecting to db"))
}
moduleRepo := repository.NewModule(dbClient)
configRepo := repository.NewConfig(dbClient)
configSchemaRepo := repository.NewConfigSchema(dbClient)
configHistoryRepo := repository.NewConfigHistory(dbClient)
logger.Info(ctx, "start modules migration")
modules := make([]Module, 0)
err = pgDb.Select(ctx, &modules, "select * from modules")
if err != nil {
panic(errors.WithMessage(err, "err selecting modules"))
}
for _, module := range modules {
result := entity.Module{
Id: module.Id,
Name: module.Name,
CreatedAt: xtypes.Time(module.CreatedAt),
}
_, _ = moduleRepo.Upsert(ctx, result)
}
logger.Info(ctx, "modules migrated")
logger.Info(ctx, "start configs migration")
configs := make([]Config, 0)
err = pgDb.Select(ctx, &configs, "select id, module_id, version, active, created_at, updated_at, data, name from configs")
if err != nil {
panic(errors.WithMessage(err, "err selecting configs"))
}
for _, config := range configs {
result := entity.Config{
Id: config.Id,
Name: config.Name,
ModuleId: config.ModuleId,
Data: config.Data,
Version: config.Version,
Active: xtypes.Bool(config.Active),
AdminId: 0,
CreatedAt: xtypes.Time(config.CreatedAt),
UpdatedAt: xtypes.Time(config.UpdatedAt),
}
err := configRepo.Insert(ctx, result)
if err != nil {
panic(errors.WithMessagef(err, "err inserting config: %s", config.Id))
}
}
logger.Info(ctx, "configs migrated")
logger.Info(ctx, "start config schemas migration")
schemas := make([]ConfigSchema, 0)
err = pgDb.Select(ctx, &schemas, "select * from config_schemas")
if err != nil {
panic(errors.WithMessage(err, "err selecting schemas"))
}
for _, schema := range schemas {
result := entity.ConfigSchema{
Id: schema.Id,
ModuleId: schema.ModuleId,
Data: schema.Schema,
ModuleVersion: schema.Version,
CreatedAt: xtypes.Time(schema.CreatedAt),
UpdatedAt: xtypes.Time(schema.UpdatedAt),
}
err := configSchemaRepo.Upsert(ctx, result)
if err != nil {
panic(errors.WithMessagef(err, "err upserting config_schema: %s", schema.Id))
}
}
logger.Info(ctx, "config schemas migrated")
logger.Info(ctx, "start config history migration")
configHistories := make([]ConfigHistory, 0)
err = pgDb.Select(ctx, &configHistories, "select * from version_config")
if err != nil {
panic(errors.WithMessage(err, "err selecting configs"))
}
for _, history := range configHistories {
result := entity.ConfigHistory{
Id: history.Id,
ConfigId: history.ConfigId,
Data: history.Data,
Version: history.ConfigVersion,
AdminId: 0,
CreatedAt: xtypes.Time(history.CreatedAt),
}
err := configHistoryRepo.Insert(ctx, result)
if err != nil {
panic(errors.WithMessagef(err, "err inserting config_history: %s", history.Id))
}
}
logger.Info(ctx, "config history migrated")
logger.Info(ctx, "close sqlite db")
_ = dbClient.Close()
logger.Info(ctx, "loading db to isp-config-service")
sqliteFile, err := os.ReadFile(fileName)
if err != nil {
panic(errors.WithMessage(err, "err opening sqlite file"))
}
cli := httpcli.New(httpcli.WithMiddlewares(httpclix.Log(logger)))
cli.GlobalRequestConfig().BaseUrl = cfg.NewConfigService.Address
cli.GlobalRequestConfig().BasicAuth = &httpcli.BasicAuth{
Username: cfg.NewConfigService.Username,
Password: cfg.NewConfigService.Password,
}
ctx = httpclix.LogConfigToContext(ctx, false, true)
err = cli.Post("/db/load").
Header("Content-Type", "application/octet-stream").
RequestBody(sqliteFile).
StatusCodeToError().
Timeout(60 * time.Second).
DoWithoutResponse(ctx)
if err != nil {
panic(errors.WithMessage(err, "load sqlite file"))
}
logger.Info(ctx, "done!")
}
+86
View File
@@ -0,0 +1,86 @@
package migration
import (
"context"
"database/sql"
"fmt"
"io/fs"
"path/filepath"
"strings"
"time"
"github.com/pkg/errors"
"github.com/pressly/goose/v3"
"github.com/txix-open/isp-kit/log"
)
const (
DialectPostgreSQL = goose.DialectPostgres
DialectSqlite3 = goose.DialectSQLite3
DialectClickhouse = goose.DialectClickHouse
)
type Runner struct {
dialect goose.Dialect
fs fs.FS
logger log.Logger
}
func NewRunner(
dialect goose.Dialect,
fs fs.FS,
logger log.Logger,
) Runner {
return Runner{
dialect: dialect,
fs: fs,
logger: logger,
}
}
func (r Runner) Run(ctx context.Context, db *sql.DB, gooseOpts ...goose.ProviderOption) error {
ctx = log.ToContext(ctx, log.String("worker", "goose_db_migration"))
provider, err := goose.NewProvider(r.dialect, db, r.fs, gooseOpts...)
if err != nil {
return errors.WithMessage(err, "get goose provider")
}
dbVersion, err := provider.GetDBVersion(ctx)
if err != nil {
return errors.WithMessage(err, "get db version")
}
r.logger.Info(ctx, fmt.Sprintf("current db version: %d", dbVersion))
migrations, err := provider.Status(ctx)
if err != nil {
return errors.WithMessage(err, "get status migrations")
}
r.logger.Info(ctx, "print migration list")
if len(migrations) == 0 {
r.logger.Info(ctx, "no migrations")
}
for _, migration := range migrations {
appliedAt := "Pending"
if !migration.AppliedAt.IsZero() {
appliedAt = migration.AppliedAt.Format(time.RFC3339)
}
msg := fmt.Sprintf(
"migration: %s %s %s",
filepath.Base(migration.Source.Path),
strings.ToUpper(string(migration.State)),
appliedAt,
)
r.logger.Info(ctx, msg)
}
result, err := provider.Up(ctx)
if err != nil {
return errors.WithMessage(err, "apply pending migrations")
}
for _, migrationResult := range result {
r.logger.Info(ctx, fmt.Sprintf("applied migration: %s", migrationResult.String()))
}
return nil
}
+35 -27
View File
@@ -1,30 +1,38 @@
database:
address: "127.0.0.1"
schema: "config_service"
database: "isp"
port: "5432"
username: "isp"
password: "isp_password"
createSchema: true
moduleName: "config"
grpcOuterAddress:
ip: 127.0.0.1
configServiceAddress:
ip: localhost
port: 9001
grpcOuterAddress:
ip: isp-config-service
port: 9002
grpcInnerAddress:
ip: 0.0.0.0
port: 9002
moduleName: isp-config-service
ws:
rest:
port: "9001"
ip: "0.0.0.0"
grpc:
port: "9002"
ip: "0.0.0.0"
infraServerPort: 9006
metrics:
gc: true
memory: true
address:
addressConfiguration:
ip: "0.0.0.0"
port: "9551"
path: "/metrics"
logLevel: debug
maintenanceMode: false
keepConfigVersions: 64
credentials:
- username: default
password: 38kPk0upqI5j
perms: ["all"]
- username: monitor
password: monitor
perms: ["ready"]
internalClientCredential: default
rqlite:
DataPath: "data"
NodeID: 1
BootstrapExpect: 1
RaftAddr: "127.0.0.1:9008"
JoinAddrs: "127.0.0.1:9008"
FKConstraints: true
AutoVacInterval: 12h
JoinAs: default
-17
View File
@@ -1,17 +0,0 @@
package conf
import (
"github.com/integration-system/isp-lib/database"
"github.com/integration-system/isp-lib/structure"
)
type Configuration struct {
Database database.DBConfiguration `valid:"required~Required"`
GrpcOuterAddress structure.AddressConfiguration `valid:"required~Required" json:"grpcOuterAddress"`
ModuleName string `valid:"required~Required"`
WS struct {
Rest structure.AddressConfiguration `valid:"required~Required"`
Grpc structure.AddressConfiguration `valid:"required~Required"`
}
Metrics structure.MetricConfiguration
}
+1
View File
@@ -0,0 +1 @@
{}
+19
View File
@@ -0,0 +1,19 @@
package conf
import (
"github.com/rqlite/rqlite/v8/auth"
"github.com/txix-open/isp-kit/bootstrap"
)
type Local struct {
ConfigServiceAddress bootstrap.ConfigServiceAddr
MaintenanceMode bool
Credentials []auth.Credential
KeepConfigVersions int `validate:"required"`
InternalClientCredential string `validate:"required"`
Rqlite Rqlite
}
type Rqlite struct {
NodeId string `validate:"required"`
}
+4
View File
@@ -0,0 +1,4 @@
package conf
type Remote struct {
}
+292
View File
@@ -0,0 +1,292 @@
//nolint:lll
package api
import (
"context"
"strconv"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/apierrors"
"google.golang.org/grpc/metadata"
"isp-config-service/domain"
"isp-config-service/entity"
)
type ConfigService interface {
GetActiveConfigByModuleName(ctx context.Context, moduleName string) (*domain.Config, error)
GetConfigsByModuleId(ctx context.Context, moduleId string) ([]domain.Config, error)
CreateUpdateConfig(ctx context.Context, adminId int, req domain.CreateUpdateConfigRequest) (*domain.CreateUpdateConfigResponse, error)
GetConfigById(ctx context.Context, configId string) (*domain.Config, error)
MarkConfigAsActive(ctx context.Context, configId string) error
DeleteConfig(ctx context.Context, id string) error
UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) error
SyncConfig(ctx context.Context, moduleName string) error
}
type Config struct {
service ConfigService
}
func NewConfig(service ConfigService) Config {
return Config{
service: service,
}
}
// GetActiveConfigByModuleName
// @Summary Метод получения объекта конфигурации по названию модуля
// @Description Возвращает активную конфиграцию по названию модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleNameRequest true "название модуля"
// @Success 200 {object} domain.Config
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден<br/>`errorCode: 2002` - конфиг не найден"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_active_config_by_module_name [POST]
func (c Config) GetActiveConfigByModuleName(ctx context.Context, req domain.GetByModuleNameRequest) (*domain.Config, error) {
config, err := c.service.GetActiveConfigByModuleName(ctx, req.ModuleName)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeModuleNotFound,
"module not found",
err,
)
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"active config not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return config, nil
}
}
// GetConfigsByModuleId
// @Summary Метод получения списка конфигураций по ID модуля
// @Description Возвращает список конфиграции по ID модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleIdRequest true "ID модуля"
// @Success 200 {array} domain.Config
// @Failure 400 {object} apierrors.Error "если идентификатор не указан"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_configs_by_module_id [POST]
func (c Config) GetConfigsByModuleId(ctx context.Context, req domain.GetByModuleIdRequest) ([]domain.Config, error) {
configs, err := c.service.GetConfigsByModuleId(ctx, req.ModuleId)
switch {
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return configs, nil
}
}
// CreateUpdateConfig
// @Summary Метод обновления конфигурации
// @Description Если конфиг с таким id существует, то обновляет данные, если нет, то добавляет данные в базу
// @Description В случае обновления рассылает всем подключенным модулям актуальную конфигурацию
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.CreateUpdateConfigRequest true "объект для сохранения"
// @Success 200 {object} domain.CreateUpdateConfigResponse
// @Failure 400 {object} apierrors.Error "`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode: 2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже обновил конфигурацию<br/>`errorCode: 2005` - схема конфигурации не найдена<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/create_update_config [POST]
func (c Config) CreateUpdateConfig(
ctx context.Context,
authData grpc.AuthData,
req domain.CreateUpdateConfigRequest,
) (*domain.CreateUpdateConfigResponse, error) {
adminIdValue, _ := grpc.StringFromMd("x-admin-id", metadata.MD(authData))
var adminId int
if adminIdValue != "" {
adminId, _ = strconv.Atoi(adminIdValue)
}
resp, err := c.service.CreateUpdateConfig(ctx, adminId, req)
var validationError domain.ConfigValidationError
switch {
case errors.As(err, &validationError):
details := map[string]any{}
for key, value := range validationError.Details {
details[key] = value
}
return nil, apierrors.NewBusinessError(
domain.ErrorCodeInvalidConfig,
"invalid config",
err,
).WithDetails(details)
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case errors.Is(err, entity.ErrConfigConflictUpdate):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigVersionConflict,
"someone has updated the config",
err,
)
case errors.Is(err, entity.ErrSchemaNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeSchemaNotFound,
"config schema not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return resp, nil
}
}
// GetConfigById
// @Summary Метод получение конфигурации по id
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id конфигурации"
// @Success 200 {object} domain.Config
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_config_by_id [POST]
func (c Config) GetConfigById(ctx context.Context, req domain.IdRequest) (*domain.Config, error) {
config, err := c.service.GetConfigById(ctx, req.Id)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return config, nil
}
}
// MarkConfigAsActive
// @Summary Метод активации конфигурации для модуля
// @Description Активирует указанную конфигурацию и деактивирует остальные, возвращает активированную конфигурацию
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id конфигурации для изменения"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/mark_config_as_active [POST]
func (c Config) MarkConfigAsActive(ctx context.Context, identity domain.IdRequest) error {
err := c.service.MarkConfigAsActive(ctx, identity.Id)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
// DeleteConfigs
// @Summary Метод удаления объектов конфигурации по идентификаторам
// @Description Возвращает количество удаленных модулей
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body []string true "массив идентификаторов конфигураций"
// @Success 200 {object} domain.DeleteResponse
// @Failure 400 {object} apierrors.Error "если не указан массив идентификаторов"
// @Failure 500 {object} apierrors.Error
// @Router /config/delete_config [POST]
func (c Config) DeleteConfigs(ctx context.Context, identities []string) (*domain.DeleteResponse, error) {
configId, err := getSingleId(identities)
if err != nil {
return nil, err
}
err = c.service.DeleteConfig(ctx, configId)
switch {
case errors.Is(err, entity.ErrConfigNotFoundOrActive):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found or is active",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return &domain.DeleteResponse{
Deleted: 1,
}, nil
}
}
// UpdateConfigName
// @Summary Метод переименования объекта конфигурации
// @Description Изменеяет название конфигурации без повышения версии и без рассылки события
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.UpdateConfigNameRequest true "id конфигурации и новое название"
// @Success 200
// @Failure 400 {object} apierrors.Error "`errorCode: 2002` - конфиг не найден<br/>"
// @Failure 500 {object} apierrors.Error
// @Router /config/update_config_name [POST]
func (c Config) UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) error {
err := c.service.UpdateConfigName(ctx, req)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
// SyncConfig
// @Summary Метод синхронизации актуальной конфигурации пришедешего модуля
// @Description Метод синхронизации актуальной конфигурации пришедешего модуля
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.SyncConfigRequest true "название модуля"
// @Success 200 {object} domain.Config
// @Failure 400 {object} apierrors.Error "`errorCode: 2001` - модуль не найден<br/>`errorCode: 2002` - конфиг не найден"
// @Failure 500 {object} apierrors.Error
// @Router /config/sync_config [POST]
func (c Config) SyncConfig(ctx context.Context, req domain.SyncConfigRequest) error {
err := c.service.SyncConfig(ctx, req.ModuleName)
switch {
case errors.Is(err, entity.ErrModuleNotFound):
return apierrors.NewBusinessError(
domain.ErrorCodeModuleNotFound,
"module not found",
err,
)
case err != nil:
return apierrors.NewInternalServiceError(err)
default:
return nil
}
}
+73
View File
@@ -0,0 +1,73 @@
package api
import (
"context"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/apierrors"
"isp-config-service/domain"
"isp-config-service/entity"
)
type ConfigHistoryService interface {
GetAllVersions(ctx context.Context, configId string) ([]domain.ConfigVersion, error)
Delete(ctx context.Context, id string) error
}
type ConfigHistory struct {
service ConfigHistoryService
}
func NewConfigHistory(service ConfigHistoryService) ConfigHistory {
return ConfigHistory{
service: service,
}
}
// GetAllVersion
// @Summary Метод получение старых версий конфигурации
// @Description Возвращает предыдущие версии конфигураций
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id конфигурации"
// @Success 200 {array} domain.ConfigVersion
// @Failure 400 {object} apierrors.Error "если не указан массив идентификаторов"
// @Failure 500 {object} apierrors.Error
// @Router /config/get_all_version [POST]
func (c ConfigHistory) GetAllVersion(ctx context.Context, req domain.IdRequest) ([]domain.ConfigVersion, error) {
versions, err := c.service.GetAllVersions(ctx, req.Id)
switch {
case errors.Is(err, entity.ErrConfigNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeConfigNotFound,
"config not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return versions, nil
}
}
// DeleteConfigVersion
// @Summary Метод удаления версии конфигурации
// @Description Возвращает количество удаленных версий
// @Tags Конфигурация
// @Accept json
// @Produce json
// @Param body body domain.IdRequest true "id версии конфигурации"
// @Success 200 {object} domain.DeleteResponse
// @Failure 400 {object} apierrors.Error "не указан массив идентификаторов"
// @Failure 500 {object} apierrors.Error
// @Router /config/delete_version [POST]
func (c ConfigHistory) DeleteConfigVersion(ctx context.Context, req domain.IdRequest) (*domain.DeleteResponse, error) {
err := c.service.Delete(ctx, req.Id)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return &domain.DeleteResponse{
Deleted: 1,
}, nil
}
+51
View File
@@ -0,0 +1,51 @@
package api
import (
"context"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/apierrors"
"isp-config-service/domain"
"isp-config-service/entity"
)
type ConfigSchemaService interface {
SchemaByModuleId(ctx context.Context, moduleId string) (*domain.ConfigSchema, error)
}
type ConfigSchema struct {
service ConfigSchemaService
}
func NewConfigSchema(service ConfigSchemaService) ConfigSchema {
return ConfigSchema{
service: service,
}
}
// SchemaByModuleId
// @Summary Метод получения схемы конфигурации модуля
// @Description Возвращает текущую json схему конфигурации модуля
// @Tags Схема
// @Accept json
// @Produce json
// @Param body body domain.GetByModuleIdRequest true "идентификатор модуля"
// @Success 200 {object} domain.ConfigSchema
// @Failure 400 {object} apierrors.Error "`errorCode: 2005` - схема для модуля не найдена"
// @Failure 500 {object} apierrors.Error
// @Router /schema/get_by_module_id [POST]
func (c ConfigSchema) SchemaByModuleId(ctx context.Context, request domain.GetByModuleIdRequest) (*domain.ConfigSchema, error) {
schema, err := c.service.SchemaByModuleId(ctx, request.ModuleId)
switch {
case errors.Is(err, entity.ErrSchemaNotFound):
return nil, apierrors.NewBusinessError(
domain.ErrorCodeSchemaNotFound,
"config schema not found",
err,
)
case err != nil:
return nil, apierrors.NewInternalServiceError(err)
default:
return schema, nil
}
}
+93
View File
@@ -0,0 +1,93 @@
package api
import (
"context"
"github.com/txix-open/isp-kit/grpc/apierrors"
"isp-config-service/domain"
)
type ModuleService interface {
Status(ctx context.Context) ([]domain.ModuleInfo, error)
Delete(ctx context.Context, id string) error
Connections(ctx context.Context) ([]domain.Connection, error)
}
type Module struct {
service ModuleService
}
func NewModule(service ModuleService) Module {
return Module{
service: service,
}
}
// Status
// @Summary Метод полчения полной информации о состоянии модулей
// @Description Возвращает полное состояние всех модулей в кластере (схема конфигурации, подключенные экземпляры)
// @Tags Модули
// @Accept json
// @Produce json
// @Success 200 {array} domain.ModuleInfo
// @Failure 500 {object} apierrors.Error
// @Router /module/get_modules_info [POST]
func (c Module) Status(ctx context.Context) ([]domain.ModuleInfo, error) {
modulesInfo, err := c.service.Status(ctx)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return modulesInfo, nil
}
// DeleteModule
// @Summary Метод удаления объектов модулей по идентификаторам
// @Description Возвращает количество удаленных модулей
// @Tags Модули
// @Accept json
// @Produce json
// @Param body body []string true "массив идентификаторов модулей"
// @Success 200 {object} domain.DeleteResponse
// @Failure 500 {object} apierrors.Error
// @Router /module/delete_module [POST]
func (c Module) DeleteModule(ctx context.Context, identities []string) (*domain.DeleteResponse, error) {
id, err := getSingleId(identities)
if err != nil {
return nil, err
}
err = c.service.Delete(ctx, id)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return &domain.DeleteResponse{
Deleted: len(identities),
}, nil
}
// Connections
// @Summary Метод получения маршрутов
// @Description Возвращает все доступные роуты
// @Tags Модули
// @Accept json
// @Produce json
// @Success 200 {array} domain.Connection
// @Failure 500 {object} apierrors.Error
// @Router /routing/get_routes [POST]
func (c Module) Connections(ctx context.Context) ([]domain.Connection, error) {
connections, err := c.service.Connections(ctx)
if err != nil {
return nil, apierrors.NewInternalServiceError(err)
}
return connections, nil
}
func getSingleId(identities []string) (string, error) {
if len(identities) == 0 {
return "", apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "at least one id is required", nil)
}
if len(identities) > 1 {
return "", apierrors.NewBusinessError(domain.ErrorCodeBadRequest, "accept only single identity", nil)
}
return identities[0], nil
}
+151
View File
@@ -0,0 +1,151 @@
//nolint:lll
package api
import (
"context"
"github.com/pkg/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
}
+143
View File
@@ -0,0 +1,143 @@
package controller
import (
"context"
"github.com/pkg/errors"
"github.com/txix-open/etp/v4"
"github.com/txix-open/etp/v4/msg"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/json"
"github.com/txix-open/isp-kit/log"
"isp-config-service/helpers"
)
var (
ok = []byte("ok") //nolint:gochecknoglobals
)
type ModuleService interface {
OnConnect(ctx context.Context, conn *etp.Conn, moduleName string) error
OnDisconnect(ctx context.Context, conn *etp.Conn, moduleName string, isNormalClose bool, err error) error
OnError(ctx context.Context, conn *etp.Conn, err error)
OnModuleReady(
ctx context.Context,
conn *etp.Conn,
backend cluster.BackendDeclaration,
) error
OnModuleRequirements(
ctx context.Context,
conn *etp.Conn,
requirements cluster.ModuleRequirements,
) error
OnModuleConfigSchema(
ctx context.Context,
conn *etp.Conn,
data cluster.ConfigData,
) error
}
type Module struct {
service ModuleService
logger log.Logger
}
func NewModule(service ModuleService, logger log.Logger) Module {
return Module{
service: service,
logger: logger,
}
}
func (m Module) OnConnect(conn *etp.Conn) {
ctx := conn.HttpRequest().Context()
err := conn.HttpRequest().ParseForm()
if err != nil {
m.handleError(ctx, errors.WithMessage(err, "parse form"))
_ = conn.Close()
return
}
moduleName := helpers.ModuleName(conn)
if moduleName == "" {
m.handleError(ctx, errors.New("module_name is required query param"))
_ = conn.Close()
return
}
err = m.service.OnConnect(ctx, conn, moduleName)
if err != nil {
m.handleError(ctx, errors.WithMessage(err, "handle onConnect"))
}
}
func (m Module) OnDisconnect(conn *etp.Conn, err error) {
ctx := conn.HttpRequest().Context()
handleDisconnectErr := m.service.OnDisconnect(
ctx,
conn,
helpers.ModuleName(conn),
etp.IsNormalClose(err),
err,
)
if handleDisconnectErr != nil {
m.handleError(ctx, errors.WithMessage(handleDisconnectErr, "handle onDisconnect"))
}
}
func (m Module) OnError(conn *etp.Conn, err error) {
m.service.OnError(conn.HttpRequest().Context(), conn, err)
}
func (m Module) OnModuleReady(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
backend := cluster.BackendDeclaration{}
err := json.Unmarshal(event.Data, &backend)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "unmarshal event data"))
}
err = m.service.OnModuleReady(ctx, conn, backend)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "handle onModuleReady"))
}
return ok
}
func (m Module) OnModuleRequirements(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
requirements := cluster.ModuleRequirements{}
err := json.Unmarshal(event.Data, &requirements)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "unmarshal event data"))
}
err = m.service.OnModuleRequirements(ctx, conn, requirements)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "handle onModuleRequirements"))
}
return ok
}
func (m Module) OnModuleConfigSchema(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
configData := cluster.ConfigData{}
err := json.Unmarshal(event.Data, &configData)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "unmarshal event data"))
}
err = m.service.OnModuleConfigSchema(ctx, conn, configData)
if err != nil {
return m.handleError(ctx, errors.WithMessage(err, "handle onModuleConfigSchema"))
}
return ok
}
func (m Module) handleError(
ctx context.Context,
err error,
) []byte {
m.logger.Error(ctx, err)
return []byte(err.Error())
}
-125
View File
@@ -1,125 +0,0 @@
package controllers
import (
"fmt"
st "isp-config-service/entity"
"isp-config-service/model"
"isp-config-service/socket"
"github.com/integration-system/isp-lib/utils"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"isp-config-service/domain"
)
func GetConfigs(identities []int64) ([]st.Config, error) {
configs, err := model.ConfigRep.GetConfigs(identities)
if err != nil {
return nil, createUnknownError(err)
}
return configs, nil
}
func GetConfigByInstanceUUIDAndModuleName(request st.ModuleInstanceIdentity) (*st.Config, error) {
config, err := model.ConfigRep.GetConfigByInstanceUUIDAndModuleName(request.Uuid, request.Name)
if err != nil {
return nil, createUnknownError(err)
}
if config == nil {
return nil, status.Error(codes.NotFound, utils.ValidationError)
}
return config, nil
}
func CreateUpdateConfig(config st.Config) (*st.Config, error) {
var err error
var cfg *st.Config
if config.Id == 0 {
cfg, err = model.ConfigRep.CreateConfig(&config)
if err != nil {
return nil, err
}
} else {
configExists, err := model.ConfigRep.GetConfigById(config.Id)
if err != nil {
return nil, err
}
if configExists == nil {
validationErrors := map[string]string{
"id": fmt.Sprintf("Entity with id: %d not found", config.Id),
}
return nil, utils.CreateValidationErrorDetails(codes.NotFound, utils.ValidationError, validationErrors)
}
cfg, err = model.ConfigRep.UpdateConfig(&config)
if err != nil {
return nil, err
}
}
if cfg.Active {
moduleInstanceIdentity, err := model.ConfigRep.GetModuleNameAndInstanceUUIDByConfigId(cfg.Id)
if err != nil {
return nil, createUnknownError(err)
}
socket.SendNewConfig(moduleInstanceIdentity.Uuid, moduleInstanceIdentity.Name, cfg)
}
return cfg, nil
}
func UpdateActiveConfigByInstanceUUIDAndModuleName(configReq domain.ConfigInstanceModuleName) (*st.Config, error) {
config, err := model.ConfigRep.GetConfigByInstanceUUIDAndModuleName(configReq.InstanceUuid, configReq.ModuleName)
if err != nil || config == nil {
validationErrors := map[string]string{
"id": fmt.Sprintf("Active config for module: %s and instance uuid: %s not found",
configReq.ModuleName, configReq.InstanceUuid),
}
return nil, utils.CreateValidationErrorDetails(codes.NotFound, utils.ValidationError, validationErrors)
}
config.Data = configReq.ConfigData
return CreateUpdateConfig(*config)
}
func MarkConfigAsActive(identity domain.LongIdentitiesRequest) (*st.Config, error) {
configExists, err := model.ConfigRep.GetConfigById(identity.Id)
if err != nil {
return nil, createUnknownError(err)
}
if configExists == nil {
validationErrors := map[string]string{
"id": fmt.Sprintf("Entity with id: %d not found", identity.Id),
}
return nil, utils.CreateValidationErrorDetails(codes.NotFound, utils.ValidationError, validationErrors)
}
configExists.Active = true
configExists, err = model.ConfigRep.UpdateConfig(configExists)
if err != nil {
return nil, err
}
if configExists.Active {
moduleInstanceIdentity, err := model.ConfigRep.GetModuleNameAndInstanceUUIDByConfigId(configExists.Id)
if err != nil {
return nil, createUnknownError(err)
}
socket.SendNewConfig(moduleInstanceIdentity.Uuid, moduleInstanceIdentity.Name, configExists)
}
return configExists, nil
}
func DeleteConfig(identities []int64) (*domain.DeleteResponse, error) {
if len(identities) == 0 {
validationErrors := map[string]string{
"ids": "Required",
}
return nil, utils.CreateValidationErrorDetails(codes.InvalidArgument, utils.ValidationError, validationErrors)
}
count, err := model.ConfigRep.DeleteConfig(identities)
if err != nil {
return nil, createUnknownError(err)
}
return &domain.DeleteResponse{Deleted: count}, err
}
-73
View File
@@ -1,73 +0,0 @@
package controllers
import (
"fmt"
st "isp-config-service/entity"
"isp-config-service/model"
"isp-config-service/domain"
"github.com/integration-system/isp-lib/logger"
"github.com/integration-system/isp-lib/utils"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func GetInstances(identities []int32) ([]st.Instance, error) {
instances, err := model.InstanceRep.GetInstances(identities)
if err != nil {
return nil, createUnknownError(err)
}
return instances, err
}
func CreateUpdateInstance(instance st.Instance) (*st.Instance, error) {
if instance.Id == 0 {
moduleExists, err := model.InstanceRep.GetInstanceByUuid(instance.Uuid)
if err != nil {
return nil, createUnknownError(err)
}
if moduleExists.Id != 0 {
validationErrors := map[string]string{
"name": fmt.Sprintf("Entity with uuid: %s already exists", instance.Name),
}
return nil, utils.CreateValidationErrorDetails(codes.AlreadyExists, utils.ValidationError, validationErrors)
}
instance, err = model.InstanceRep.CreateInstance(instance)
} else {
instanceExists, err := model.InstanceRep.GetInstanceById(instance.Id)
if err != nil {
return nil, createUnknownError(err)
}
if instanceExists.Id == 0 {
validationErrors := map[string]string{
"id": fmt.Sprintf("Entity with id: %d not found", instance.Id),
}
return nil, utils.CreateValidationErrorDetails(codes.NotFound, utils.ValidationError, validationErrors)
}
instance, err = model.InstanceRep.UpdateInstance(instance)
instance.CreatedAt = instanceExists.CreatedAt
}
return &instance, nil
}
func DeleteInstance(identities []int32) (*domain.DeleteResponse, error) {
if len(identities) == 0 {
validationErrors := map[string]string{
"ids": "Required",
}
return nil, utils.CreateValidationErrorDetails(codes.InvalidArgument, utils.ValidationError, validationErrors)
}
count, err := model.InstanceRep.DeleteInstance(identities)
if err != nil {
return nil, createUnknownError(err)
}
return &domain.DeleteResponse{Deleted: count}, err
}
func createUnknownError(err error) error {
logger.Error(err)
return status.Error(codes.Unknown, utils.ServiceError)
}
-16
View File
@@ -1,16 +0,0 @@
package controllers
/*var HandlerSwagger = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
values, err := url.ParseQuery(r.URL.RawQuery)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("Method not received"))
}
method := values.Get("method")
if method == "" {
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("Method not received"))
}
proxyRequestHandle(w, r, method)
})
*/
-113
View File
@@ -1,113 +0,0 @@
package controllers
import (
"encoding/json"
"fmt"
st "isp-config-service/entity"
"isp-config-service/model"
"isp-config-service/module"
"isp-config-service/socket"
"isp-config-service/domain"
"github.com/integration-system/isp-lib/structure"
"github.com/integration-system/isp-lib/utils"
"google.golang.org/grpc/codes"
)
func GetModules(identities []int32) ([]st.Module, error) {
modules, err := model.ModulesRep.GetModules(identities)
if err != nil {
return nil, createUnknownError(err)
}
return modules, nil
}
func GetModulesAggregatedInfo(i structure.Isolation) ([]*domain.ModuleInfo, error) {
instanceId, err := i.GetInstanceId()
if err != nil {
return nil, err
}
return module.GetAggregatedModuleInfo(instanceId)
}
func GetActiveModules() ([]st.Module, error) {
modules, err := model.ModulesRep.GetActiveModules()
if err != nil {
return nil, createUnknownError(err)
}
return modules, nil
}
func GetConnectedModules() (map[string]interface{}, error) {
modules := socket.GetRoomsCount()
bytes, err := json.Marshal(modules)
if err != nil {
return nil, createUnknownError(err)
}
var response map[string]interface{}
err = json.Unmarshal(bytes, &response)
if err != nil {
return nil, createUnknownError(err)
}
return response, nil
}
func CreateUpdateModule(module st.Module) (*st.Module, error) {
if module.Id == 0 {
instanceExists, err := model.InstanceRep.GetInstanceById(module.InstanceId)
if err != nil {
return nil, createUnknownError(err)
}
if instanceExists.Id == 0 {
validationErrors := map[string]string{
"instanceId": fmt.Sprintf("Entity with instanceId: %d not found", module.InstanceId),
}
return nil, utils.CreateValidationErrorDetails(codes.NotFound, utils.ValidationError, validationErrors)
}
moduleExists, err := model.ModulesRep.GetModuleByInstanceIdAndName(module.InstanceId, module.Name)
if err != nil {
return nil, createUnknownError(err)
}
if moduleExists.Id != 0 {
validationErrors := map[string]string{
"name": fmt.Sprintf("Entity with name: %s already exists", module.Name),
}
return nil, utils.CreateValidationErrorDetails(codes.AlreadyExists, utils.ValidationError, validationErrors)
}
module, err = model.ModulesRep.CreateModule(module)
} else {
moduleExists, err := model.ModulesRep.GetModuleById(module.Id)
if err != nil {
return nil, createUnknownError(err)
}
if moduleExists.Id == 0 {
validationErrors := map[string]string{
"id": fmt.Sprintf("Entity with id: %d not found", module.Id),
}
return nil, utils.CreateValidationErrorDetails(codes.NotFound, utils.ValidationError, validationErrors)
}
module, err = model.ModulesRep.UpdateModule(module)
module.CreatedAt = moduleExists.CreatedAt
module.Active = moduleExists.Active
}
return &module, nil
}
func DeleteModule(identities []int32) (*domain.DeleteResponse, error) {
if len(identities) == 0 {
validationErrors := map[string]string{
"ids": "Required",
}
return nil, utils.CreateValidationErrorDetails(codes.InvalidArgument, utils.ValidationError, validationErrors)
}
count, err := model.ModulesRep.DeleteModule(identities)
if err != nil {
return nil, createUnknownError(err)
}
return &domain.DeleteResponse{Deleted: count}, err
}
-20
View File
@@ -1,20 +0,0 @@
package controllers
import (
"encoding/json"
"isp-config-service/socket"
)
func GetRoutes() (map[string]interface{}, error) {
bytes, err := json.Marshal(socket.GetRoutes().Routes)
if err != nil {
return nil, createUnknownError(err)
}
var response map[string]interface{}
err = json.Unmarshal(bytes, &response)
if err != nil {
return nil, createUnknownError(err)
}
return response, nil
}
+40
View File
@@ -0,0 +1,40 @@
services:
isp-config-service-1:
image: "isp-config-service:latest"
container_name: "isp-config-service-1"
hostname: "isp-config-service-1"
restart: unless-stopped
environment:
grpcOuterAddress.ip: isp-config-service-1
rqlite.NodeID: 1
rqlite.BootstrapExpect: 3
rqlite.RaftAddr: "isp-config-service-1:4002"
rqlite.JoinAddrs: "isp-config-service-1:4002,isp-config-service-2:4002,isp-config-service-3:4002"
volumes:
- "./isp-config-service-1/data:/app/data"
isp-config-service-2:
image: "isp-config-service:latest"
container_name: "isp-config-service-2"
hostname: "isp-config-service-2"
restart: unless-stopped
environment:
grpcOuterAddress.ip: isp-config-service-2
rqlite.NodeID: 2
rqlite.BootstrapExpect: 3
rqlite.RaftAddr: "isp-config-service-2:4002"
rqlite.JoinAddrs: "isp-config-service-1:4002,isp-config-service-2:4002,isp-config-service-3:4002"
volumes:
- "./isp-config-service-2/data:/app/data"
isp-config-service-3:
image: "isp-config-service:latest"
container_name: "isp-config-service-3"
hostname: "isp-config-service-3"
restart: unless-stopped
environment:
grpcOuterAddress.ip: isp-config-service-3
rqlite.NodeID: 3
rqlite.BootstrapExpect: 3
rqlite.RaftAddr: "isp-config-service-3:4002"
rqlite.JoinAddrs: "isp-config-service-1:4002,isp-config-service-2:4002,isp-config-service-3:4002"
volumes:
- "./isp-config-service-3/data:/app/data"
+30
View File
@@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
name: isp-config-service-internal
spec:
clusterIP: None
publishNotReadyAddresses: True
selector:
app: isp-config-service
ports:
- protocol: TCP
port: 4001
targetPort: 4001
---
apiVersion: v1
kind: Service
metadata:
name: isp-config-service
spec:
selector:
app: isp-config-service
ports:
- protocol: TCP
name: ws
port: 9001
targetPort: 9001
- protocol: TCP
name: grpc
port: 9002
targetPort: 9002
+87
View File
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: isp-config-service
spec:
selector:
matchLabels:
app: isp-config-service # has to match .spec.template.metadata.labels
serviceName: isp-config-service-internal
replicas: 3
podManagementPolicy: "Parallel"
template:
metadata:
labels:
app: isp-config-service # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
imagePullSecrets:
- name: regcred
containers:
- name: isp-config-service
image: isp-config-service:latest
imagePullPolicy: Always
env:
- name: rqlite.NodeID
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: rqlite.BootstrapExpect
value: "3"
- name: rqlite.HttpAddr
value: "0.0.0.0:4001"
- name: rqlite.HttpAdv
value: "$HOSTNAME:4001"
- name: rqlite.RaftAddr
value: "0.0.0.0:4002"
- name: rqlite.RaftAdv
value: "$HOSTNAME:4002"
- name: rqlite.JoinAddrs
value: ""
- name: rqlite.DiscoMode
value: "dns"
- name: rqlite.DiscoConfig
value: "{\"name\":\"isp-config-service-internal\"}"
- name: rqlite.JoinInterval
value: "1s"
- name: rqlite.JoinAttempts
value: "120"
- name: rqlite.RaftClusterRemoveOnShutdown
value: "true"
ports:
- containerPort: 4001
name: rqlite
readinessProbe:
httpGet:
scheme: HTTP
path: /readyz
port: rqlite
httpHeaders:
- name: Authorization
value: Basic bW9uaXRvcjptb25pdG9y
periodSeconds: 5
timeoutSeconds: 2
initialDelaySeconds: 2
livenessProbe:
httpGet:
scheme: HTTP
path: /readyz?noleader
port: rqlite
httpHeaders:
- name: Authorization
value: Basic bW9uaXRvcjptb25pdG9y
initialDelaySeconds: 5
timeoutSeconds: 2
failureThreshold: 3
volumeMounts:
- name: isp-config-service-data
mountPath: /app/data
volumeClaimTemplates:
- metadata:
name: isp-config-service-data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "local-path"
resources:
requests:
storage: 1Gi
+864
View File
@@ -0,0 +1,864 @@
basePath: /api/config
definitions:
domain.Address:
properties:
ip:
type: string
port:
type: string
type: object
domain.Config:
properties:
active:
type: boolean
createdAt:
type: string
data:
type: object
id:
type: string
moduleId:
type: string
name:
type: string
updatedAt:
type: string
valid:
type: boolean
version:
type: integer
type: object
domain.ConfigSchema:
properties:
createdAt:
type: string
id:
type: string
moduleId:
type: string
schema:
type: object
updatedAt:
type: string
version:
type: string
type: object
domain.ConfigVersion:
properties:
configId:
type: string
configVersion:
type: integer
createdAt:
type: string
data:
type: object
id:
type: string
type: object
domain.Connection:
properties:
address:
$ref: '#/definitions/domain.Address'
endpoints:
items:
$ref: '#/definitions/domain.EndpointDescriptor'
type: array
establishedAt:
type: string
id:
type: string
libVersion:
type: string
moduleName:
type: string
version:
type: string
type: object
domain.CreateUpdateConfigRequest:
properties:
data:
type: object
id:
type: string
moduleId:
type: string
name:
type: string
unsafe:
type: boolean
version:
type: integer
required:
- moduleId
- name
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:
properties:
deleted:
type: integer
type: object
domain.EndpointDescriptor:
properties:
inner:
type: boolean
path:
type: string
type: object
domain.GetByModuleIdRequest:
properties:
moduleId:
type: string
required:
- moduleId
type: object
domain.GetByModuleNameRequest:
properties:
moduleName:
type: string
required:
- moduleName
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:
properties:
active:
type: boolean
configSchema:
type: object
createdAt:
type: string
id:
type: string
lastConnectedAt:
type: string
lastDisconnectedAt:
type: string
name:
type: string
status:
items:
$ref: '#/definitions/domain.Connection'
type: array
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.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:
properties:
details:
additionalProperties: {}
type: object
errorCode:
type: integer
errorMessage:
type: string
type: object
host: localhost:9000
info:
contact: {}
description: Модуль управления конфигурациями
license:
name: GNU GPL v3.0
title: isp-config-service
version: 3.0.0
paths:
/config/create_update_config:
post:
consumes:
- application/json
description: |-
Если конфиг с таким id существует, то обновляет данные, если нет, то добавляет данные в базу
В случае обновления рассылает всем подключенным модулям актуальную конфигурацию
parameters:
- description: объект для сохранения
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.CreateUpdateConfigRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.CreateUpdateConfigResponse'
"400":
description: '`errorCode: 2003` - конфиг не соотвествует текущей схеме<br/>`errorCode:
2002` - указанного id не сущесвует<br/>`errorCode: 2004` - кто-то уже
обновил конфигурацию<br/>`errorCode: 2005` - схема конфигурации не найдена<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:
- Конфигурация
/config/delete_config:
post:
consumes:
- application/json
description: Возвращает количество удаленных модулей
parameters:
- description: массив идентификаторов конфигураций
in: body
name: body
required: true
schema:
items:
type: string
type: array
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.DeleteResponse'
"400":
description: если не указан массив идентификаторов
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/delete_version:
post:
consumes:
- application/json
description: Возвращает количество удаленных версий
parameters:
- description: id версии конфигурации
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.IdRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.DeleteResponse'
"400":
description: не указан массив идентификаторов
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/get_active_config_by_module_name:
post:
consumes:
- application/json
description: Возвращает активную конфиграцию по названию модуля
parameters:
- description: название модуля
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.GetByModuleNameRequest'
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/get_all_version:
post:
consumes:
- application/json
description: Возвращает предыдущие версии конфигураций
parameters:
- description: id конфигурации
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.IdRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.ConfigVersion'
type: array
"400":
description: если не указан массив идентификаторов
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/get_config_by_id:
post:
consumes:
- application/json
parameters:
- description: id конфигурации
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.IdRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Config'
"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: Метод получение конфигурации по id
tags:
- Конфигурация
/config/get_configs_by_module_id:
post:
consumes:
- application/json
description: Возвращает список конфиграции по ID модуля
parameters:
- description: ID модуля
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.GetByModuleIdRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.Config'
type: array
"400":
description: если идентификатор не указан
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: Метод получения списка конфигураций по ID модуля
tags:
- Конфигурация
/config/mark_config_as_active:
post:
consumes:
- application/json
description: Активирует указанную конфигурацию и деактивирует остальные, возвращает
активированную конфигурацию
parameters:
- description: id конфигурации для изменения
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.IdRequest'
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:
- Конфигурация
/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:
- Конфигурация
/module/delete_module:
post:
consumes:
- application/json
description: Возвращает количество удаленных модулей
parameters:
- description: массив идентификаторов модулей
in: body
name: body
required: true
schema:
items:
type: string
type: array
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.DeleteResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
summary: Метод удаления объектов модулей по идентификаторам
tags:
- Модули
/module/get_modules_info:
post:
consumes:
- application/json
description: Возвращает полное состояние всех модулей в кластере (схема конфигурации,
подключенные экземпляры)
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.ModuleInfo'
type: array
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
summary: Метод полчения полной информации о состоянии модулей
tags:
- Модули
/routing/get_routes:
post:
consumes:
- application/json
description: Возвращает все доступные роуты
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/domain.Connection'
type: array
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/github_com_txix-open_isp-kit_grpc_apierrors.Error'
summary: Метод получения маршрутов
tags:
- Модули
/schema/get_by_module_id:
post:
consumes:
- application/json
description: Возвращает текущую json схему конфигурации модуля
parameters:
- description: идентификатор модуля
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.GetByModuleIdRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.ConfigSchema'
"400":
description: '`errorCode: 2005` - схема для модуля не найдена'
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"
+36
View File
@@ -0,0 +1,36 @@
package domain
import (
"fmt"
"strings"
)
const (
ErrorCodeBadRequest = 400
ErrorCodeModuleNotFound = 2001
ErrorCodeConfigNotFound = 2002
ErrorCodeInvalidConfig = 2003
ErrorCodeConfigVersionConflict = 2004
ErrorCodeSchemaNotFound = 2005
ErrorCodeVariableNotFound = 2006
ErrorCodeVariableAlreadyExists = 2007
ErrorCodeVariableUsedInConfigs = 2008
)
type ConfigValidationError struct {
Details map[string]string
}
func NewConfigValidationError(details map[string]string) ConfigValidationError {
return ConfigValidationError{
Details: details,
}
}
func (e ConfigValidationError) Error() string {
descriptions := make([]string, 0, len(e.Details))
for field, err := range e.Details {
descriptions = append(descriptions, fmt.Sprintf("%s -> %s", field, err))
}
return strings.Join(descriptions, "; ")
}
+28 -8
View File
@@ -1,15 +1,35 @@
package domain
type IdentitiesRequest struct {
Ids []int32 `json:"ids" valid:"required~Required"`
import (
"github.com/txix-open/isp-kit/json"
)
type IdRequest struct {
Id string `validate:"required"`
}
type LongIdentitiesRequest struct {
Id int64 `json:"id" valid:"required~Required"`
type GetByModuleIdRequest struct {
ModuleId string `validate:"required"`
}
type ConfigInstanceModuleName struct {
ModuleName string `valid:"required~Required"`
InstanceUuid string `valid:"required~Required"`
ConfigData map[string]interface{} `valid:"required~Required"`
type GetByModuleNameRequest struct {
ModuleName string `validate:"required"`
}
type CreateUpdateConfigRequest struct {
Id string
Name string `validate:"required"`
ModuleId string `validate:"required"`
Version int
Data json.RawMessage `swaggertype:"object"`
Unsafe bool
}
type UpdateConfigNameRequest struct {
Id string `validate:"required"`
NewConfigName string `validate:"required"`
}
type SyncConfigRequest struct {
ModuleName string `validate:"required"`
}
+58 -16
View File
@@ -3,32 +3,74 @@ package domain
import (
"time"
"isp-config-service/entity"
"github.com/integration-system/isp-lib/config/schema"
"github.com/integration-system/isp-lib/structure"
"github.com/txix-open/isp-kit/json"
)
type DeleteResponse struct {
Deleted int
}
type Connection struct {
LibVersion string
Version string
Address structure.AddressConfiguration
Endpoints []structure.EndpointConfig `json:",omitempty"`
EstablishedAt time.Time
type CreateUpdateConfigResponse struct {
IsChanged bool
Config
}
type ModuleInfo struct {
Id int32
Id string
Name string
Active bool
LastConnectedAt *time.Time
LastDisconnectedAt *time.Time
ConfigSchema json.RawMessage `swaggertype:"object"`
Status []Connection
CreatedAt time.Time
LastConnectedAt time.Time
LastDisconnectedAt time.Time
Configs []entity.Config `json:",omitempty"`
ConfigSchema *schema.Schema `json:",omitempty"`
Status []Connection `json:",omitempty"`
}
type Connection struct {
Id string
ModuleName string
LibVersion string
Version string
Address Address
Endpoints []EndpointDescriptor
EstablishedAt time.Time
}
type Address struct {
Ip string
Port string
}
type EndpointDescriptor struct {
Path string
Inner bool
}
type Config struct {
Id string
Name string
ModuleId string
Valid bool
Data json.RawMessage `swaggertype:"object"`
Version int
Active bool
CreatedAt time.Time
UpdatedAt time.Time
}
type ConfigVersion struct {
Id string
ConfigId string
ConfigVersion int
Data json.RawMessage `swaggertype:"object"`
CreatedAt time.Time
}
type ConfigSchema struct {
Id string
Version string
ModuleId string
Schema json.RawMessage `swaggertype:"object"`
CreatedAt time.Time
UpdatedAt time.Time
}
+52
View File
@@ -0,0 +1,52 @@
package domain
import (
"time"
"isp-config-service/entity"
)
type Variable struct {
Name string
Description string
Type string
Value string
CreatedAt time.Time
UpdatedAt time.Time
ContainsInConfigs []LinkedConfig
}
type LinkedConfig struct {
Id string
ModuleId string
Name string
}
type CreateVariableRequest struct {
Name string `validate:"required"`
Description string
Type string `validate:"required,oneof=SECRET TEXT"`
Value string `validate:"required"`
}
type UpdateVariableRequest struct {
Name string `validate:"required"`
Description string
Value string `validate:"required"`
}
type UpsertVariableRequest struct {
Name string `validate:"required"`
Description string
Type string `validate:"required,oneof=SECRET TEXT"`
Value string `validate:"required"`
}
type VariableByNameRequest struct {
Name string `validate:"required"`
}
type VariableExtractionResult struct {
VariableLinks []entity.ConfigHasVariable
AbsentVariables []string
}
+20
View File
@@ -0,0 +1,20 @@
package entity
import (
"github.com/txix-open/isp-kit/cluster"
"isp-config-service/entity/xtypes"
)
// nolint: tagliatelle
type Backend struct {
WsConnectionId string `json:"ws_connection_id"`
ModuleId string `json:"module_id"`
Address string `json:"address"`
Version string `json:"version"`
LibVersion string `json:"lib_version"`
ModuleName string `json:"module_name"`
ConfigServiceNodeId string `json:"config_service_node_id"`
Endpoints xtypes.Json[[]cluster.EndpointDescriptor] `json:"endpoints"`
RequiredModules xtypes.Json[[]cluster.ModuleDependency] `json:"required_modules"`
CreatedAt xtypes.Time `json:"created_at"`
}
+33 -29
View File
@@ -1,40 +1,44 @@
// nolint: tagliatelle
package entity
import (
"encoding/json"
"github.com/integration-system/isp-lib/config/schema"
"github.com/integration-system/isp-lib/logger"
"time"
"isp-config-service/entity/xtypes"
)
type ConfigData map[string]interface{}
func (cd ConfigData) ToJSON() string {
if bytes, err := json.Marshal(cd); err == nil {
return string(bytes)
} else {
logger.Warn("Could not serialize config data to JSON", err)
return "{}"
}
type Config struct {
Id string `json:"id"`
Name string `json:"name"`
ModuleId string `json:"module_id"`
Data []byte `json:"data"`
Version int `json:"version"`
Active xtypes.Bool `json:"active"`
AdminId int `json:"admin_id"`
CreatedAt xtypes.Time `json:"created_at"`
UpdatedAt xtypes.Time `json:"updated_at"`
}
type Config struct {
Id int64 `json:"id"`
Name string `json:"name" valid:"required~Required"`
Description string `json:"description"`
ModuleId int32 `json:"moduleId" valid:"required~Required"`
Version int32 `json:"version" sql:",null"`
Active bool `json:"active" sql:",null"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
UpdatedAt time.Time `json:"updatedAt" sql:",null"`
Data ConfigData `json:"data" sql:",notnull"`
type ConfigMetaWithVariable struct {
Id string `json:"id"`
Name string `json:"name"`
ModuleId string `json:"module_id"`
VariableName string `json:"variable_name"`
Active xtypes.Bool `json:"active"`
}
type ConfigHistory struct {
Id string `json:"id"`
ConfigId string `json:"config_id"`
Data []byte `json:"data"`
Version int `json:"version"`
AdminId int `json:"admin_id"`
CreatedAt xtypes.Time `json:"created_at"`
}
type ConfigSchema struct {
Id int32
Version string
ModuleId int32
Schema schema.Schema
CreatedAt time.Time
UpdatedAt time.Time
Id string `json:"id"`
ModuleId string `json:"module_id"`
Data []byte `json:"data"`
ModuleVersion string `json:"module_version"`
CreatedAt xtypes.Time `json:"created_at"`
UpdatedAt xtypes.Time `json:"updated_at"`
}
+16
View File
@@ -0,0 +1,16 @@
package entity
import (
"github.com/pkg/errors"
)
var (
ErrConfigNotFound = errors.New("no active config")
ErrModuleNotFound = errors.New("module not found")
ErrSchemaNotFound = errors.New("config schema not found")
ErrConfigNotFoundOrActive = errors.New("config not found or markers as active")
ErrConfigConflictUpdate = errors.New("config conflict update")
ErrVariableNotFound = errors.New("variable not found")
ErrVariableAlreadyExists = errors.New("variable already exists")
ErrVariableUsedInConfigs = errors.New("variable used in configs")
)
+52
View File
@@ -0,0 +1,52 @@
package entity
import (
"fmt"
"isp-config-service/entity/xtypes"
)
type Event struct {
Id int `json:"id"`
Payload xtypes.Json[EventPayload] `json:"payload"`
}
func NewEvent(payload EventPayload) Event {
return Event{
Payload: xtypes.Json[EventPayload]{
Value: payload,
},
}
}
func (e Event) Key() string {
switch {
case e.Payload.Value.ConfigUpdated != nil:
return fmt.Sprintf("config_updated_%s", e.Payload.Value.ConfigUpdated.ModuleId)
case e.Payload.Value.ModuleReady != nil:
return fmt.Sprintf("module_lifecycle_%s", e.Payload.Value.ModuleReady.ModuleId)
case e.Payload.Value.ModuleDisconnected != nil:
return fmt.Sprintf("module_lifecycle_%s", e.Payload.Value.ModuleDisconnected.ModuleId)
default:
return ""
}
}
// nolint:tagliatelle
type EventPayload struct {
ConfigUpdated *PayloadConfigUpdated `json:",omitempty"`
ModuleReady *PayloadModuleReady `json:",omitempty"`
ModuleDisconnected *PayloadModuleDisconnected `json:",omitempty"`
}
type PayloadConfigUpdated struct {
ModuleId string
}
type PayloadModuleReady struct {
ModuleId string
}
type PayloadModuleDisconnected struct {
ModuleId string
}
-13
View File
@@ -1,13 +0,0 @@
package entity
import (
"time"
)
type Instance struct {
Id int32 `json:"id"`
Uuid string `json:"uuid" valid:"required~Required,uuid~must be a valid uuid"`
Name string `json:"name" valid:"required~Required"`
// CreatedAtJson utils.JSONTime `json:"createdAt" sql:"-"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
}
+7 -13
View File
@@ -1,20 +1,14 @@
package entity
import (
"time"
"isp-config-service/entity/xtypes"
)
// nolint:tagliatelle
type Module struct {
Id int32 `json:"id"`
InstanceId int32 `json:"instanceId" valid:"required~Required"`
Name string `json:"name" valid:"required~Required"`
Active bool `json:"active" sql:",null"`
CreatedAt time.Time `json:"createdAt" sql:",null"`
LastConnectedAt time.Time `json:"lastConnectedAt"`
LastDisconnectedAt time.Time `json:"lastDisconnectedAt"`
}
type ModuleInstanceIdentity struct {
Name string `valid:"required~Required"`
Uuid string `valid:"required~Required,uuid~must be a valid uuid"`
Id string `json:"id"`
Name string `json:"name"`
LastConnectedAt *xtypes.Time `json:"last_connected_at"`
LastDisconnectedAt *xtypes.Time `json:"last_disconnected_at"`
CreatedAt xtypes.Time `json:"created_at"`
}
+20
View File
@@ -0,0 +1,20 @@
// nolint:tagliatelle
package entity
import (
"isp-config-service/entity/xtypes"
)
type Variable struct {
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
Value string `json:"value"`
CreatedAt xtypes.Time `json:"created_at"`
UpdatedAt xtypes.Time `json:"updated_at"`
}
type ConfigHasVariable struct {
ConfigId string `json:"config_id"`
VariableName string `json:"variable_name"`
}
+23
View File
@@ -0,0 +1,23 @@
package xtypes
type Bool bool
func (l Bool) MarshalJSON() ([]byte, error) {
return l.MarshalText()
}
func (l *Bool) UnmarshalJSON(data []byte) error {
return l.UnmarshalText(data)
}
func (l Bool) MarshalText() ([]byte, error) {
if l {
return []byte("1"), nil
}
return []byte("0"), nil
}
func (l *Bool) UnmarshalText(data []byte) error {
*l = string(data) == "1"
return nil
}
+44
View File
@@ -0,0 +1,44 @@
package xtypes
import (
"strconv"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/json"
)
type Json[T any] struct {
Value T
}
func (l Json[T]) MarshalJSON() ([]byte, error) {
data, err := l.MarshalText()
if err != nil {
return nil, err
}
return []byte(strconv.Quote(string(data))), nil
}
func (l *Json[T]) UnmarshalJSON(data []byte) error {
s, err := strconv.Unquote(string(data))
if err != nil {
return errors.WithMessage(err, "unquote text")
}
return l.UnmarshalText([]byte(s))
}
func (l Json[T]) MarshalText() ([]byte, error) {
data, err := json.Marshal(l.Value)
if err != nil {
return nil, errors.WithMessage(err, "marshal json")
}
return data, nil
}
func (l *Json[T]) UnmarshalText(data []byte) error {
err := json.Unmarshal(data, &l.Value)
if err != nil {
return errors.WithMessage(err, "unmarshal json")
}
return nil
}
+36
View File
@@ -0,0 +1,36 @@
package xtypes
import (
"strconv"
"time"
"github.com/pkg/errors"
)
type Time time.Time
func (l Time) MarshalJSON() ([]byte, error) {
return l.MarshalText()
}
func (l *Time) UnmarshalJSON(data []byte) error {
return l.UnmarshalText(data)
}
func (l Time) MarshalText() ([]byte, error) {
t := time.Time(l)
value := strconv.Itoa(int(t.Unix()))
return []byte(value), nil
}
func (l *Time) UnmarshalText(data []byte) error {
if string(data) == "null" {
return nil
}
value, err := strconv.Atoi(string(data))
if err != nil {
return errors.WithMessagef(err, "parse int: %s", string(data))
}
*l = Time(time.Unix(int64(value), 0))
return nil
}
-257
View File
@@ -1,257 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: proto/backend_service.proto
/*
Package isp is a generated protocol buffer package.
It is generated from these files:
proto/backend_service.proto
It has these top-level messages:
Message
*/
package isp
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "google.golang.org/genproto/googleapis/api/annotations"
import google_protobuf1 "github.com/golang/protobuf/ptypes/struct"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type Message struct {
// Types that are valid to be assigned to Body:
// *Message_StructBody
// *Message_ListBody
Body isMessage_Body `protobuf_oneof:"body"`
}
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
type isMessage_Body interface {
isMessage_Body()
}
type Message_StructBody struct {
StructBody *google_protobuf1.Struct `protobuf:"bytes,1,opt,name=structBody,oneof"`
}
type Message_ListBody struct {
ListBody *google_protobuf1.ListValue `protobuf:"bytes,2,opt,name=listBody,oneof"`
}
func (*Message_StructBody) isMessage_Body() {}
func (*Message_ListBody) isMessage_Body() {}
func (m *Message) GetBody() isMessage_Body {
if m != nil {
return m.Body
}
return nil
}
func (m *Message) GetStructBody() *google_protobuf1.Struct {
if x, ok := m.GetBody().(*Message_StructBody); ok {
return x.StructBody
}
return nil
}
func (m *Message) GetListBody() *google_protobuf1.ListValue {
if x, ok := m.GetBody().(*Message_ListBody); ok {
return x.ListBody
}
return nil
}
// XXX_OneofFuncs is for the internal use of the proto package.
func (*Message) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
return _Message_OneofMarshaler, _Message_OneofUnmarshaler, _Message_OneofSizer, []interface{}{
(*Message_StructBody)(nil),
(*Message_ListBody)(nil),
}
}
func _Message_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*Message)
// body
switch x := m.Body.(type) {
case *Message_StructBody:
b.EncodeVarint(1<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.StructBody); err != nil {
return err
}
case *Message_ListBody:
b.EncodeVarint(2<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.ListBody); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("Message.Body has unexpected type %T", x)
}
return nil
}
func _Message_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Message)
switch tag {
case 1: // body.structBody
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_protobuf1.Struct)
err := b.DecodeMessage(msg)
m.Body = &Message_StructBody{msg}
return true, err
case 2: // body.listBody
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_protobuf1.ListValue)
err := b.DecodeMessage(msg)
m.Body = &Message_ListBody{msg}
return true, err
default:
return false, nil
}
}
func _Message_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Message)
// body
switch x := m.Body.(type) {
case *Message_StructBody:
s := proto.Size(x.StructBody)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Message_ListBody:
s := proto.Size(x.ListBody)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
func init() {
proto.RegisterType((*Message)(nil), "isp.Message")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for BackendService service
type BackendServiceClient interface {
// ===== SYSTEM =====
Request(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error)
}
type backendServiceClient struct {
cc *grpc.ClientConn
}
func NewBackendServiceClient(cc *grpc.ClientConn) BackendServiceClient {
return &backendServiceClient{cc}
}
func (c *backendServiceClient) Request(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error) {
out := new(Message)
err := grpc.Invoke(ctx, "/isp.BackendService/Request", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for BackendService service
type BackendServiceServer interface {
// ===== SYSTEM =====
Request(context.Context, *Message) (*Message, error)
}
func RegisterBackendServiceServer(s *grpc.Server, srv BackendServiceServer) {
s.RegisterService(&_BackendService_serviceDesc, srv)
}
func _BackendService_Request_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Message)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BackendServiceServer).Request(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/isp.BackendService/Request",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BackendServiceServer).Request(ctx, req.(*Message))
}
return interceptor(ctx, in, info, handler)
}
var _BackendService_serviceDesc = grpc.ServiceDesc{
ServiceName: "isp.BackendService",
HandlerType: (*BackendServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Request",
Handler: _BackendService_Request_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "proto/backend_service.proto",
}
func init() { proto.RegisterFile("proto/backend_service.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 264 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0x28, 0xca, 0x2f,
0xc9, 0xd7, 0x4f, 0x4a, 0x4c, 0xce, 0x4e, 0xcd, 0x4b, 0x89, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c,
0x4e, 0xd5, 0x03, 0x8b, 0x0a, 0x31, 0xe7, 0x16, 0x17, 0x48, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7,
0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7,
0x15, 0x43, 0x94, 0xc0, 0x65, 0xc1, 0xbc, 0xa4, 0xd2, 0x34, 0xfd, 0xe2, 0x92, 0xa2, 0xd2, 0xe4,
0x12, 0x88, 0xac, 0x52, 0x1b, 0x23, 0x17, 0xbb, 0x6f, 0x6a, 0x71, 0x71, 0x62, 0x7a, 0xaa, 0x90,
0x25, 0x17, 0x17, 0x44, 0xce, 0x29, 0x3f, 0xa5, 0x52, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48,
0x5c, 0x0f, 0xa2, 0x5d, 0x0f, 0xa6, 0x5d, 0x2f, 0x18, 0xac, 0xc4, 0x83, 0x21, 0x08, 0x49, 0xb1,
0x90, 0x05, 0x17, 0x47, 0x4e, 0x66, 0x31, 0x44, 0x23, 0x13, 0x58, 0xa3, 0x14, 0x86, 0x46, 0x9f,
0xcc, 0xe2, 0x92, 0xb0, 0xc4, 0x9c, 0xd2, 0x54, 0x0f, 0x86, 0x20, 0xb8, 0x6a, 0x27, 0x36, 0x2e,
0x96, 0xa4, 0xfc, 0x94, 0x4a, 0x23, 0x0f, 0x2e, 0x3e, 0x27, 0x88, 0x17, 0x83, 0x21, 0x3e, 0x14,
0x32, 0xe3, 0x62, 0x0f, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0xe2, 0xd1, 0xcb, 0x2d, 0x2e,
0xd0, 0x83, 0xba, 0x53, 0x0a, 0x85, 0xa7, 0xc4, 0xdf, 0x74, 0xf9, 0xc9, 0x64, 0x26, 0x4e, 0x25,
0x16, 0x90, 0xff, 0xad, 0x18, 0xb5, 0x9c, 0xf4, 0xb9, 0xc4, 0x32, 0xf3, 0xf5, 0xd2, 0x8b, 0x0a,
0x92, 0xf5, 0x92, 0xf3, 0xf3, 0xca, 0x52, 0x8b, 0x4a, 0xa0, 0x26, 0x3a, 0x09, 0x3b, 0xa3, 0xf0,
0x03, 0x40, 0x2e, 0x0b, 0x60, 0x4c, 0x62, 0x03, 0x3b, 0xd1, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff,
0x64, 0xa9, 0x7f, 0x65, 0x6a, 0x01, 0x00, 0x00,
}
-122
View File
@@ -1,122 +0,0 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: proto/backend_service.proto
/*
Package isp is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package isp
import (
"io"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
func request_BackendService_Request_0(ctx context.Context, marshaler runtime.Marshaler, client BackendServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq Message
var metadata runtime.ServerMetadata
if req.ContentLength > 0 {
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
}
msg, err := client.Request(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
// RegisterBackendServiceHandlerFromEndpoint is same as RegisterBackendServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterBackendServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterBackendServiceHandler(ctx, mux, conn)
}
// RegisterBackendServiceHandler registers the http handlers for service BackendService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterBackendServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterBackendServiceHandlerClient(ctx, mux, NewBackendServiceClient(conn))
}
// RegisterBackendServiceHandler registers the http handlers for service BackendService to "mux".
// The handlers forward requests to the grpc endpoint over the given implementation of "BackendServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "BackendServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "BackendServiceClient" to call the correct interceptors.
func RegisterBackendServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client BackendServiceClient) error {
mux.Handle("POST", pattern_BackendService_Request_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
if cn, ok := w.(http.CloseNotifier); ok {
go func(done <-chan struct{}, closed <-chan bool) {
select {
case <-done:
case <-closed:
cancel()
}
}(ctx.Done(), cn.CloseNotify())
}
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_BackendService_Request_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_BackendService_Request_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_BackendService_Request_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"api"}, ""))
)
var (
forward_BackendService_Request_0 = runtime.ForwardResponseMessage
)
+103
View File
@@ -0,0 +1,103 @@
module isp-config-service
go 1.24
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
)
require (
github.com/Masterminds/squirrel v1.5.4
github.com/google/uuid v1.6.0
github.com/pkg/errors v0.9.1
github.com/pressly/goose/v3 v3.24.3
github.com/prometheus/client_golang v1.22.0
github.com/rqlite/gorqlite v0.0.0-20250128004930-114c7828b55a
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099
github.com/rqlite/rqlite/v8 v8.37.0
github.com/stretchr/testify v1.10.0
github.com/tidwall/gjson v1.18.0
github.com/txix-open/etp/v4 v4.0.1
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60
github.com/txix-open/isp-kit v1.51.0
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/sync v0.14.0
google.golang.org/grpc v1.72.2
)
require (
github.com/armon/go-metrics v0.5.4 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.13 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/getsentry/sentry-go v0.33.0 // indirect
github.com/go-faker/faker/v4 v4.6.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.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-metrics v0.5.4 // indirect
github.com/hashicorp/go-msgpack v1.1.5 // indirect
github.com/hashicorp/go-msgpack/v2 v2.1.3 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/raft v1.7.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.64.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rqlite/go-sqlite3 v1.38.0 // indirect
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 // indirect
github.com/rqlite/sql v0.0.0-20241111133259-a4122fabb196 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/txix-open/bellows v1.2.0 // indirect
github.com/txix-open/jsonschema v1.3.0 // indirect
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
go.etcd.io/bbolt v1.4.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0 // indirect
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 // indirect
go.opentelemetry.io/otel/metric v1.36.0 // indirect
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.opentelemetry.io/proto/otlp v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/net v0.40.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+421
View File
@@ -0,0 +1,421 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
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/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cenkalti/backoff/v5 v5.0.2 h1:rIfFVxEf1QsI7E1ZHfp/B4DF/6QBAUhmgkxc0H7Zss8=
github.com/cenkalti/backoff/v5 v5.0.2/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/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.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/getsentry/sentry-go v0.33.0 h1:YWyDii0KGVov3xOaamOnF0mjOrqSjBqwv48UEzn7QFg=
github.com/getsentry/sentry-go v0.33.0/go.mod h1:C55omcY9ChRQIUcVcGcs+Zdy4ZpQGvNJ7JYHIoSWOtE=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-faker/faker/v4 v4.6.1 h1:xUyVpAjEtB04l6XFY0V/29oR332rOSPWV4lU8RwDt4k=
github.com/go-faker/faker/v4 v4.6.1/go.mod h1:arSdxNCSt7mOhdk8tEolvHeIJ7eX4OX80wXjKKvkKBY=
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/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
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.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
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.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/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.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
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/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
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.0/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.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
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 v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-metrics v0.5.4 h1:8mmPiIJkTPPEbAiV97IxdAGNdRdaWwVap1BU6elejKY=
github.com/hashicorp/go-metrics v0.5.4/go.mod h1:CG5yz4NZ/AI/aQt9Ucm/vdBnbh7fvmv4lxZ350i+QQI=
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/go.mod h1:gWVc3sv/wbDmR3rQsj1CAktEZzoz1YNK9NfGLXJ69/4=
github.com/hashicorp/go-msgpack/v2 v2.1.3 h1:cB1w4Zrk0O3jQBTcFMKqYQWRFfsSQ/TYKNyUUVyCP2c=
github.com/hashicorp/go-msgpack/v2 v2.1.3/go.mod h1:SjlwKKFnwBXvxD/I1bEcfJIBbEJ+MCUn39TxymNR5ZU=
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/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/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM=
github.com/hashicorp/raft v1.7.3 h1:DxpEqZJysHN0wK+fviai5mFcSYsCkNpFUl1xpAW8Rbo=
github.com/hashicorp/raft v1.7.3/go.mod h1:DfvCGFxpAUPE0L4Uc8JLlTPtc3GzSbdH0MTJCLgnmJQ=
github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea/go.mod h1:qRd6nFJYYS6Iqnc/8HcUmko2/2Gw8qTFEmxDLii6W5I=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
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.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
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.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
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/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
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/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pressly/goose/v3 v3.24.3 h1:DSWWNwwggVUsYZ0X2VitiAa9sKuqtBfe+Jr9zFGwWlM=
github.com/pressly/goose/v3 v3.24.3/go.mod h1:v9zYL4xdViLHCUUJh/mhjnm6JrK7Eul8AS93IxiZM4E=
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.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
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.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
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.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.64.0 h1:pdZeA+g617P7oGv1CzdTzyeShxAGrTBsolKNOLQPGO4=
github.com/prometheus/common v0.64.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
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.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rqlite/go-sqlite3 v1.38.0 h1:o3qTaVEHRzPsvTabUpPGPyNqnCyxEW3ccxHuPeUW/YI=
github.com/rqlite/go-sqlite3 v1.38.0/go.mod h1:R9H7CatgYBt3c+fSV/5yo2vLh4ZjCB0aMHdkv69fP4A=
github.com/rqlite/gorqlite v0.0.0-20250128004930-114c7828b55a h1:9O8zgGrMBuTsnA3yyFd+JWhFSflQwzSUEB4AMnFHKhU=
github.com/rqlite/gorqlite v0.0.0-20250128004930-114c7828b55a/go.mod h1:xF/KoXmrRyahPfo5L7Szb5cAAUl53dMWBh9cMruGEZg=
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48 h1:NZ62M+kT0JqhyFUMc8I4SMmfmD4NGJxhb2ePJQXjryc=
github.com/rqlite/raft-boltdb/v2 v2.0.0-20230523104317-c08e70f4de48/go.mod h1:CRnsxgy5G8fAf5J+AM0yrsSdxXHKkIYOaq2sm+Q4DYc=
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099 h1:5cqkVLdl6sGJSY3kiF2dqaA3bD+8OS5FUdZqO0BxXLU=
github.com/rqlite/rqlite-disco-clients v0.0.0-20250205044118-8ada2b350099/go.mod h1:6SVI8KegsW9Fyu2UQ+uvw0JI5CAILRYRyiQ/OFSJPrs=
github.com/rqlite/rqlite/v8 v8.37.0 h1:Y5SWqRY3+bPHXjGBnoXiN4jvYBpmINP8b4crwqBaOBY=
github.com/rqlite/rqlite/v8 v8.37.0/go.mod h1:QsjEVLiJILXS6B41KdHl80bfkRlHpsfoZQAZqaXJYhk=
github.com/rqlite/sql v0.0.0-20241111133259-a4122fabb196 h1:SjRKMwKLTEE3STO6unJlz4VlMjMv5NZgIdI9HikBeAc=
github.com/rqlite/sql v0.0.0-20241111133259-a4122fabb196/go.mod h1:ib9zVtNgRKiGuoMyUqqL5aNpk+r+++YlyiVIkclVqPg=
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
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.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60 h1:7SZ72lNU69g8eiT5rcRh1ubATZPs/J05NEIN7E47TYM=
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60/go.mod h1:jzpq0uwcdGq0OSNXZ6vv6UJkCOU/fLPgeoz+KkGDYgo=
github.com/txix-open/grmq v1.8.1 h1:bcPLuYZXJ+1h9D3w7JYzUTypnQsw9XAT0Ftl/Fu+cZA=
github.com/txix-open/grmq v1.8.1/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
github.com/txix-open/isp-kit v1.51.0 h1:sSDs/M5EaAiIJGbefRprbZH2GgCfdjwgpUV94NWd73A=
github.com/txix-open/isp-kit v1.51.0/go.mod h1:OkscabRkpFGjUOFrbPM7yTKD/Br2/iv5/PWr/T2Jtd4=
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/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.4.0 h1:TU77id3TnN/zKr7CO/uk+fBCwF2jGcMuw2B/FMAzYIk=
go.etcd.io/bbolt v1.4.0/go.mod h1:AsD+OCi/qPN1giOX1aiLAha3o1U8rAz65bvN4j0sRuk=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0 h1:lREC4C0ilyP4WibDhQ7Gg2ygAQFP8oR07Fst/5cafwI=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0/go.mod h1:HfvuU0kW9HewH14VCOLImqKvUgONodURG7Alj/IrnGI=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 h1:F7Jx+6hwnZ41NSFTO5q4LYDtJRXBf2PD0rNBkeB/lus=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0/go.mod h1:UHB22Z8QsdRDrnAtX4PntOl36ajSxcdUMt1sF7Y6E7Q=
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 h1:dNzwXjZKpMpE2JhmO+9HsPl42NIXFIFSUSSs0fiqra0=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0/go.mod h1:90PoxvaEB5n6AOdZvi+yWJQoE95U8Dhhw2bSyRqnTD0=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0 h1:nRVXXvf78e00EwY6Wp0YII8ww2JVWshZ20HfTlE11AM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.36.0/go.mod h1:r49hO7CgrxY9Voaj3Xe8pANWtr0Oq916d0XAmOoCZAQ=
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
go.opentelemetry.io/proto/otlp v1.6.0 h1:jQjP+AQyTf+Fe7OKj/MfkDrmK4MNVtw2NpXsf9fefDI=
go.opentelemetry.io/proto/otlp v1.6.0/go.mod h1:cicgGehlFuNdgZkcALOCh3VE6K/u2tAjzlRhDwmVpZc=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
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-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/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-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-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.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/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.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
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-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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
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-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=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0=
google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8=
google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/libc v1.65.0 h1:e183gLDnAp9VJh6gWKdTy0CThL9Pt7MfcR/0bgb7Y1Y=
modernc.org/libc v1.65.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.10.0 h1:fzumd51yQ1DxcOxSO+S6X7+QTuVU+n8/Aj7swYjFfC4=
modernc.org/memory v1.10.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI=
modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM=
-58
View File
@@ -1,58 +0,0 @@
package helper
import (
"github.com/integration-system/isp-lib/structure"
"isp-config-service/controllers"
"isp-config-service/domain"
"isp-config-service/entity"
)
type Handlers struct {
// ===== INSTANCE =====
GetInstances func(identities []int32) ([]entity.Instance, error) `method:"get_instances" group:"instance" inner:"true"`
CreateUpdateInstance func(instance entity.Instance) (*entity.Instance, error) `method:"create_update_instance" group:"instance" inner:"true"`
DeleteInstance func(identities []int32) (*domain.DeleteResponse, error) `method:"delete_instance" group:"instance" inner:"true"`
// ===== MODULE =====
GetModules func(identities []int32) ([]entity.Module, error) `method:"get_modules" group:"module" inner:"true"`
GetActiveModules func() ([]entity.Module, error) `method:"get_active_modules" group:"module" inner:"true"`
GetConnectedModules func() (map[string]interface{}, error) `method:"get_connected_modules" group:"module" inner:"true"`
CreateUpdateModule func(module entity.Module) (*entity.Module, error) `method:"create_update_module" group:"module" inner:"true"`
DeleteModule func(identities []int32) (*domain.DeleteResponse, error) `method:"delete_module" group:"module" inner:"true"`
GetModulesInfo func(i structure.Isolation) ([]*domain.ModuleInfo, error) `method:"get_modules_info" group:"module" inner:"true"`
// ===== CONFIG =====
GetConfigs func(identities []int64) ([]entity.Config, error) `method:"get_configs" group:"config" inner:"true"`
GetConfigByInstanceUUIDAndModuleName func(request entity.ModuleInstanceIdentity) (*entity.Config, error) `method:"get_config_by_instance_uuid_and_module_name" group:"config" inner:"true"`
CreateUpdateConfig func(config entity.Config) (*entity.Config, error) `method:"create_update_config" group:"config" inner:"true"`
UpdateActiveConfigByInstanceUUIDAndModuleName func(config domain.ConfigInstanceModuleName) (*entity.Config, error) `method:"update_active_config_by_instance_uuid_and_module_name" group:"config" inner:"true"`
MarkConfigAsActive func(identity domain.LongIdentitiesRequest) (*entity.Config, error) `method:"mark_config_as_active" group:"config" inner:"true"`
DeleteConfig func(identities []int64) (*domain.DeleteResponse, error) `method:"delete_config" group:"config" inner:"true"`
// ===== ROUTING =====
GetRoutes func() (map[string]interface{}, error) `method:"get_routes" group:"routing" inner:"true"`
}
func GetHandlers() *Handlers {
return &Handlers{
GetInstances: controllers.GetInstances,
CreateUpdateInstance: controllers.CreateUpdateInstance,
DeleteInstance: controllers.DeleteInstance,
GetModules: controllers.GetModules,
GetActiveModules: controllers.GetActiveModules,
GetConnectedModules: controllers.GetConnectedModules,
CreateUpdateModule: controllers.CreateUpdateModule,
DeleteModule: controllers.DeleteModule,
GetModulesInfo: controllers.GetModulesAggregatedInfo,
GetConfigs: controllers.GetConfigs,
GetConfigByInstanceUUIDAndModuleName: controllers.GetConfigByInstanceUUIDAndModuleName,
CreateUpdateConfig: controllers.CreateUpdateConfig,
UpdateActiveConfigByInstanceUUIDAndModuleName: controllers.UpdateActiveConfigByInstanceUUIDAndModuleName,
MarkConfigAsActive: controllers.MarkConfigAsActive,
DeleteConfig: controllers.DeleteConfig,
GetRoutes: controllers.GetRoutes,
}
}
+33
View File
@@ -0,0 +1,33 @@
package helpers
import (
"net"
"github.com/pkg/errors"
"github.com/txix-open/etp/v4"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/log"
"isp-config-service/entity"
)
func ModuleName(conn *etp.Conn) string {
return conn.HttpRequest().Form.Get("module_name")
}
func SplitAddress(backend entity.Backend) (cluster.AddressConfiguration, error) {
host, port, err := net.SplitHostPort(backend.Address)
if err != nil {
return cluster.AddressConfiguration{}, errors.WithMessagef(err, "split backend %s address: %s", backend.ModuleId, backend.Address)
}
return cluster.AddressConfiguration{
IP: host,
Port: port,
}, nil
}
func LogFields(conn *etp.Conn) []log.Field {
return []log.Field{
log.String("moduleName", ModuleName(conn)),
log.String("connId", conn.Id()),
}
}
+29 -228
View File
@@ -1,247 +1,48 @@
package main
import (
"flag"
"github.com/integration-system/isp-lib/bootstrap"
"github.com/valyala/fasthttp"
"isp-config-service/domain"
"isp-config-service/module"
"net/http"
"os"
"os/signal"
"path"
rn "runtime"
"time"
"github.com/txix-open/isp-kit/bootstrap"
"github.com/txix-open/isp-kit/shutdown"
"isp-config-service/conf"
"isp-config-service/generated"
"isp-config-service/helper"
"isp-config-service/model"
"isp-config-service/socket"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/integration-system/isp-lib/backend"
"github.com/integration-system/isp-lib/config"
"github.com/integration-system/isp-lib/controller"
"github.com/integration-system/isp-lib/database"
"github.com/integration-system/isp-lib/logger"
"github.com/integration-system/isp-lib/metric"
"github.com/integration-system/isp-lib/structure"
"github.com/integration-system/isp-lib/utils"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
const (
routerModule = "router"
converterModule = "converter"
"isp-config-service/routes"
"isp-config-service/service/startup"
)
var (
configData *conf.Configuration
echoEndpoint *string
executableFileDir string
version = "0.1.0"
date = "undefined"
version = "1.0.0"
)
func init() {
configData = config.InitConfig(&conf.Configuration{}).(*conf.Configuration)
database.InitDbWithSchema(configData.Database, configData.Database.Schema)
db := database.GetDBManager()
model.InitDbManager(db.Db)
model.SetSchema(configData.Database.Schema)
echoEndpoint = flag.String("echo_endpoint", configData.WS.Grpc.GetAddress(), "endpoint of YourService")
module.Version = version
}
// @title isp-config-service
// @version 3.0.0
// @description Модуль управления конфигурациями
// @license.name GNU GPL v3.0
// @host localhost:9000
// @BasePath /api/config
//go:generate swag init --parseDependency
//go:generate rm -f docs/swagger.json docs/docs.go
func main() {
ex, err := os.Executable()
executableFileDir = path.Dir(ex)
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors())
app := boot.App
logger := app.Logger()
startup, err := startup.New(boot)
if err != nil {
logger.Fatal(err)
boot.Fatal(err)
}
if utils.DEV {
_, filename, _, _ := rn.Caller(0)
executableFileDir = path.Dir(filename)
}
metric.InitCollectors(configData.Metrics, structure.MetricConfiguration{})
metric.InitStatusChecker("routers", checkRouters)
metric.InitStatusChecker("converters", checkConverters)
metric.InitHttpServer(configData.Metrics)
metric.GerHttpRouter().GET("/modules", handleModulesRequest)
app.AddRunners(startup)
app.AddClosers(startup.Closers()...)
createGrpcServer()
createRestServer(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONPb{OrigName: true, EmitDefaults: true}))
}
func checkRouters() interface{} {
result := make([]string, 0)
instances, err := model.InstanceRep.GetInstances(nil)
if err != nil {
logger.Warn(err)
}
for _, v := range instances {
list := socket.GetModuleAddressList(v.Uuid, routerModule)
for _, v := range list {
result = append(result, v.GetAddress())
}
}
return result
}
func checkConverters() interface{} {
result := make([]string, 0)
instances, err := model.InstanceRep.GetInstances(nil)
if err != nil {
logger.Warn(err)
}
for _, v := range instances {
list := socket.GetModuleAddressList(v.Uuid, converterModule)
for _, v := range list {
result = append(result, v.GetAddress())
}
}
return result
}
// newGateway returns a new gateway server which translates HTTP into gRPC.
func newGateway(ctx context.Context, opts ...runtime.ServeMuxOption) (http.Handler, error) {
mux := runtime.NewServeMux(opts...)
dialOpts := []grpc.DialOption{grpc.WithInsecure()}
err := isp.RegisterBackendServiceHandlerFromEndpoint(ctx, mux, *echoEndpoint, dialOpts)
if err != nil {
logger.Fatalf("failed to serve rest proxy: %v", err)
}
return mux, nil
}
// Start a GRPC server.
func createGrpcServer() {
// Run our server in a goroutine so that it doesn't block.
handlers := helper.GetHandlers()
addr := structure.AddressConfiguration{IP: configData.WS.Grpc.IP, Port: configData.WS.Grpc.Port}
addrOuter := structure.AddressConfiguration{IP: configData.GrpcOuterAddress.IP, Port: configData.GrpcOuterAddress.Port}
backend.StartBackendGrpcServer(addr, backend.GetDefaultService(configData.ModuleName, handlers))
enndpoints := backend.GetEndpoints(configData.ModuleName, handlers)
socket.SetBackendMethods(&structure.BackendDeclaration{
ModuleName: configData.ModuleName,
Version: version,
LibVersion: bootstrap.LibraryVersion,
Endpoints: enndpoints,
Address: addrOuter,
shutdown.On(func() {
logger.Info(app.Context(), "starting shutdown")
app.Shutdown()
logger.Info(app.Context(), "shutdown completed")
})
logger.Infof("EXPORTED MODULE METHODS: %v, module_name: %s, version: %s",
enndpoints, configData.ModuleName, version)
}
// Start a HTTP server.
func createRestServer(opts ...runtime.ServeMuxOption) {
mux := http.NewServeMux()
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
// === Socket.IO ===
mux.Handle("/socket.io/", socket.Get())
// === REST ===
mux.Handle("/swagger/", controller.StaticHandler(
http.StripPrefix(
"/swagger/", http.FileServer(
http.Dir(path.Join(executableFileDir, "static", "swagger-ui"))))))
gw, err := newGateway(ctx, opts...)
err = app.Run()
if err != nil {
logger.Fatalf("failed to serve: %v", err)
}
mux.Handle("/", gw)
/*r.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
})*/
var wait time.Duration
flag.DurationVar(&wait, "graceful-timeout", time.Second*15,
"the duration for which the server gracefully wait for existing connections to finish - e.g. 15s or 1m")
flag.Parse()
restAddress := configData.WS.Rest.GetAddress()
logger.Infof("Serving at %s ...", restAddress)
srv := &http.Server{
Addr: restAddress,
// Good practice to set timeouts to avoid Slowloris attacks.
WriteTimeout: time.Second * 15,
ReadTimeout: time.Second * 15,
IdleTimeout: time.Second * 60,
Handler: mux, // Pass our instance of gorilla/mux in.
}
go func() {
if err := srv.ListenAndServe(); err != nil {
logger.Fatal(err)
}
}()
c := make(chan os.Signal, 1)
// We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C)
// SIGKILL, SIGQUIT or SIGTERM (Ctrl+/) will not be caught.
signal.Notify(c, os.Interrupt)
// Block until we receive our signal.
<-c
// Create a deadline to wait for.
ctx, cancel = context.WithTimeout(context.Background(), wait)
defer cancel()
// Doesn't block if no connections, but will otherwise wait
// until the timeout deadline.
_ = srv.Shutdown(ctx)
// Optionally, you could run srv.Shutdown in a goroutine and block on
// <-ctx.Done() if your application should wait for other services
// to finalize based on context cancellation.
logger.Info("shutting down")
os.Exit(0)
}
func handleModulesRequest(ctx *fasthttp.RequestCtx) {
instances, err := model.InstanceRep.GetInstances(nil)
if err != nil {
logger.Warn(err)
ctx.Error("internal server error", http.StatusInternalServerError)
return
}
result := make(map[string][]*domain.ModuleInfo, len(instances))
for _, i := range instances {
info, err := module.GetAggregatedModuleInfo(i.Uuid)
if err != nil {
logger.Warn(err)
continue
}
for _, inf := range info {
inf.ConfigSchema = nil
inf.Configs = nil
for i := range inf.Status {
s := &inf.Status[i]
s.Endpoints = nil
}
}
result[i.Uuid] = info
}
if bytes, err := utils.ConvertInterfaceToBytes(result, nil); err != nil {
logger.Warn(err)
ctx.Error("internal server error", http.StatusInternalServerError)
} else {
ctx.SetStatusCode(http.StatusOK)
ctx.SetContentType("application/json; charset=utf-8")
ctx.SetBody(bytes)
boot.Fatal(err)
}
}
+33
View File
@@ -0,0 +1,33 @@
package middlewares
import (
"context"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/txix-open/isp-kit/http/httpcli"
"github.com/txix-open/isp-kit/metrics"
"isp-config-service/middlewares/sql_metrics"
)
func SqlOperationMiddleware() httpcli.Middleware {
//nolint:promlinter
sqlQueryDuration := metrics.GetOrRegister(metrics.DefaultRegistry, prometheus.NewSummaryVec(prometheus.SummaryOpts{
Subsystem: "sql",
Name: "query_duration_ms",
Help: "The latencies of sql query",
Objectives: metrics.DefaultObjectives,
}, []string{"operation"}))
return func(next httpcli.RoundTripper) httpcli.RoundTripper {
return httpcli.RoundTripperFunc(func(ctx context.Context, request *httpcli.Request) (*httpcli.Response, error) {
label := sql_metrics.OperationLabelFromContext(ctx)
now := time.Now()
resp, err := next.RoundTrip(ctx, request)
if label != "" {
duration := time.Since(now)
sqlQueryDuration.WithLabelValues(label).Observe(metrics.Milliseconds(duration))
}
return resp, err //nolint:wrapcheck
})
}
}
+20
View File
@@ -0,0 +1,20 @@
package sql_metrics
import (
"context"
)
type tracerContextKey int
const (
labelContextKey = tracerContextKey(2)
)
func OperationLabelToContext(ctx context.Context, label string) context.Context {
return context.WithValue(ctx, labelContextKey, label)
}
func OperationLabelFromContext(ctx context.Context) string {
value, _ := ctx.Value(labelContextKey).(string)
return value
}
+34
View File
@@ -0,0 +1,34 @@
package middlewares
import (
"context"
"github.com/txix-open/etp/v4"
"github.com/txix-open/etp/v4/msg"
"github.com/txix-open/isp-kit/log"
"isp-config-service/helpers"
)
type EtpMiddleware func(next etp.Handler) etp.Handler
func EtpLogger(logger log.Logger) EtpMiddleware {
return func(next etp.Handler) etp.Handler {
return etp.HandlerFunc(func(ctx context.Context, conn *etp.Conn, event msg.Event) []byte {
fields := append(
helpers.LogFields(conn),
log.String("event", event.Name),
)
logger.Debug(ctx, "event received", fields...)
return next.Handle(ctx, conn, event)
})
}
}
//nolint:ireturn
func EtpChain(root etp.Handler, middlewares ...EtpMiddleware) etp.Handler {
for i := len(middlewares) - 1; i >= 0; i-- {
root = middlewares[i](root)
}
return root
}
@@ -1,5 +0,0 @@
-- +goose Up
CREATE schema if NOT EXISTS "config_service";
-- +goose Down
DROP schema if EXISTS config_service CASCADE;
+81
View File
@@ -0,0 +1,81 @@
-- +goose Up
-- +goose NO TRANSACTION
create table isp_config_service__module
(
id text not null primary key,
name text not null unique,
last_connected_at integer,
last_disconnected_at integer,
created_at integer not null default (unixepoch())
);
create table isp_config_service__config
(
id text not null primary key,
name text not null,
module_id text not null,
data blob not null,
version int not null default 1,
active int not null default 0,
admin_id int not null default 0,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch()),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create index IX_isp_config_service__config__module_id on isp_config_service__config (module_id);
create table isp_config_service__config_history
(
id text not null primary key,
config_id text not null,
data blob not null,
version int not null default 1,
admin_id int not null default 0,
created_at integer not null default (unixepoch()),
foreign key (config_id) references isp_config_service__config (id) on delete cascade on update cascade
);
create index IX_isp_config_service__config_history__config_id on isp_config_service__config_history (config_id);
create table isp_config_service__config_schema
(
id text not null primary key,
module_id text not null unique,
data blob not null,
module_version text not null default 1,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch()),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create table isp_config_service__backend
(
module_id text not null,
address text not null,
version text not null,
lib_version text not null,
module_name text not null,
endpoints blob not null,
required_modules blob not null,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch()),
primary key (module_id, address),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create table isp_config_service__event
(
id integer,
payload blob not null,
created_at integer not null default (unixepoch()),
primary key (id)
);
-- +goose Down
drop table isp_config_service__module;
drop table isp_config_service__config;
drop table isp_config_service__config_history;
drop table isp_config_service__config_schema;
drop table isp_config_service__backend;
drop table isp_config_service__event;
@@ -0,0 +1,17 @@
-- +goose Up
-- +goose NO TRANSACTION
CREATE TABLE isp_config_service__event_autoincrement (
id integer primary key autoincrement,
payload blob not null,
created_at integer not null default (unixepoch())
);
INSERT INTO
isp_config_service__event_autoincrement (id, payload, created_at)
SELECT id, payload, created_at
FROM isp_config_service__event;
DROP TABLE isp_config_service__event;
ALTER TABLE isp_config_service__event_autoincrement RENAME TO isp_config_service__event;
-- +goose Down
@@ -0,0 +1,24 @@
-- +goose Up
-- +goose NO TRANSACTION
drop table isp_config_service__backend;
create table isp_config_service__backend
(
ws_connection_id text not null,
module_id text not null,
address text not null,
version text not null,
lib_version text not null,
module_name text not null,
config_service_node_id text not null,
endpoints blob not null,
required_modules blob not null,
created_at integer not null default (unixepoch()),
primary key (ws_connection_id),
foreign key (module_id) references isp_config_service__module (id) on delete cascade on update cascade
);
create index IX_isp_config_service__backend__module_id on isp_config_service__backend (module_id);
create index IX_isp_config_service__backend__node_id on isp_config_service__backend(config_service_node_id);
-- +goose Down
@@ -0,0 +1,26 @@
-- +goose Up
-- +goose NO TRANSACTION
create table isp_config_service__variable
(
name text primary key,
description text not null,
type text not null,
value text not null,
created_at integer not null default (unixepoch()),
updated_at integer not null default (unixepoch())
);
create table isp_config_service__config_has_variable
(
config_id text not null,
variable_name text not null,
primary key (config_id, variable_name),
foreign key (config_id) references isp_config_service__config (id) on delete cascade on update cascade,
foreign key (variable_name) references isp_config_service__variable (name)
);
create index IX_isp_config_service__config_has_variable__variable_name on isp_config_service__config_has_variable (variable_name);
-- +goose Down
drop table isp_config_service__config_has_variable;
drop table isp_config_service__variable;
+10
View File
@@ -0,0 +1,10 @@
package migrations
import (
"embed"
)
var (
//go:embed *
Migrations embed.FS
)
@@ -1,5 +0,0 @@
-- +goose Up
CREATE schema if NOT EXISTS "config_service";
-- +goose Down
DROP schema if EXISTS config_service CASCADE;
@@ -1,47 +0,0 @@
-- +goose Up
CREATE TABLE instances (
id serial4 NOT NULL PRIMARY KEY,
uuid UUID NOT NULL,
"name" varchar(255) NOT NULL,
created_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL
);
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION update_created_modified_column_date()
RETURNS TRIGGER AS
$body$
BEGIN
IF TG_OP = 'UPDATE' THEN
NEW.created_at = OLD.created_at;
NEW.updated_at = (now() at time zone 'utc');
ELSIF TG_OP = 'INSERT' THEN
NEW.updated_at = (now() at time zone 'utc');
END IF;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql;
-- +goose StatementEnd
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION update_created_column_date()
RETURNS TRIGGER AS
$body$
BEGIN
IF TG_OP = 'UPDATE' THEN
NEW.created_at = OLD.created_at;
ELSIF TG_OP = 'INSERT' THEN
NEW.created_at = (now() at time zone 'utc');
END IF;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql;
-- +goose StatementEnd
CREATE TRIGGER update_customer_modtime BEFORE INSERT OR UPDATE ON instances
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
ALTER TABLE instances ADD CONSTRAINT "UQ_instances_uuid" UNIQUE ("uuid");
-- +goose Down
DROP TABLE instances;
@@ -1,24 +0,0 @@
-- +goose Up
CREATE TABLE modules (
id serial4 NOT NULL PRIMARY KEY,
instance_id int4 NOT NULL,
"name" varchar(255) NOT NULL,
"active" bool DEFAULT true,
created_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL,
last_connected_at timestamp,
last_disconnected_at timestamp
);
ALTER TABLE modules
ADD CONSTRAINT "FK_modules_instanceId_instances_id"
FOREIGN KEY ("instance_id") REFERENCES instances ("id")
ON DELETE CASCADE ON UPDATE CASCADE;
CREATE INDEX IX_modules_instanceId ON modules USING hash (instance_id);
CREATE TRIGGER update_customer_modtime BEFORE INSERT OR UPDATE ON modules
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
ALTER TABLE modules ADD CONSTRAINT "UQ_modules_instanceId_name" UNIQUE ("instance_id", "name");
-- +goose Down
DROP TABLE modules;
@@ -1,70 +0,0 @@
-- +goose Up
CREATE TABLE configs (
id serial8 NOT NULL PRIMARY KEY,
module_id int4 NOT NULL,
"version" int4 NOT NULL,
"active" bool DEFAULT false,
created_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL,
updated_at timestamp DEFAULT (now() at time zone 'utc') NOT NULL,
"data" jsonb NOT NULL DEFAULT '{}'
);
ALTER TABLE configs
ADD CONSTRAINT "FK_configs_moduleId_modules_id"
FOREIGN KEY ("module_id") REFERENCES modules ("id")
ON DELETE CASCADE ON UPDATE CASCADE;
CREATE INDEX IX_configs_moduleId ON configs USING hash (module_id);
-- +goose StatementBegin
CREATE OR REPLACE FUNCTION deactivate_config()
RETURNS TRIGGER AS
$body$
DECLARE
last_version integer;
BEGIN
NEW.updated_at = (now() at time zone 'utc');
IF TG_OP = 'INSERT'
THEN
EXECUTE format('
SELECT version
FROM %I.configs
WHERE module_id = ' || NEW.module_id || '
ORDER BY created_at DESC
LIMIT 1;
', TG_TABLE_SCHEMA) INTO last_version;
IF last_version IS NOT NULL
THEN
NEW.version = last_version + 1;
ELSE
NEW.version = 1;
END IF;
ELSE
NEW.version = OLD.version;
NEW.created_at = OLD.created_at;
END IF;
IF NEW.active = TRUE
THEN
EXECUTE format('
UPDATE %I.configs
SET active = FALSE,
updated_at = (now() at time zone ''utc'')
WHERE active = TRUE AND ' || NEW.id || ' != id AND module_id = ' || NEW.module_id || ';
', TG_TABLE_SCHEMA);
END IF;
RETURN NEW;
END;
$body$ LANGUAGE plpgsql;
-- +goose StatementEnd
CREATE TRIGGER "deactivate_config"
BEFORE INSERT OR UPDATE ON configs
FOR EACH ROW EXECUTE PROCEDURE deactivate_config();
CREATE TRIGGER update_config_create_time BEFORE INSERT OR UPDATE ON configs
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
-- +goose Down
DROP TABLE configs;
DROP FUNCTION deactivate_config;
@@ -1,6 +0,0 @@
-- +goose Up
INSERT INTO instances VALUES (1, 'bf482806-0c3d-4e0d-b9d4-12c037b12d70', 'main', NULL);
SELECT setval(pg_get_serial_sequence('instances', 'id'), 2, FALSE);
-- +goose Down
DELETE FROM instances WHERE id=1
@@ -1,10 +0,0 @@
-- +goose Up
INSERT INTO modules VALUES (1, 1, 'auth', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (2, 1, 'converter', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (3, 1, 'router', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (4, 1, 'system', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (5, 1, 'admin', 't', NULL, NULL, NULL);
SELECT setval(pg_get_serial_sequence('modules', 'id'), 6, FALSE);
-- +goose Down
DELETE FROM modules WHERE id IN (1,2,3,4,5);
@@ -1,11 +0,0 @@
-- +goose Up
INSERT INTO modules VALUES (6, 1, 'user', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (7, 1, 'mobile', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (8, 1, 'awip', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (9, 1, 'mongo-backend', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (10, 1, 'sql-backend', 't', NULL, NULL, NULL);
INSERT INTO modules VALUES (11, 1, 'events', 't', NULL, NULL, NULL);
SELECT setval(pg_get_serial_sequence('modules', 'id'), 12, FALSE);
-- +goose Down
DELETE FROM modules WHERE id IN (6,7,8,9,10,11);
@@ -1,58 +0,0 @@
-- +goose Up
set migration.db_host = 'msk-pgsql.isp.mobi';
set migration.db_port = '5432';
set migration.db_dbname = 'isp-alpha';
set migration.db_user = 'isp-alpha';
set migration.db_pass = 'JxY96xLF8zfh3g8EWvSDtLUBw';
set migration.redis_host = '10.250.9.117';
set migration.redis_port = '6379';
-- auth
INSERT INTO configs VALUES (1, 1, NULL, 't', NULL, NULL, ('{"redis": {' ||
'"ip": "' || current_setting('migration.redis_host') || '", ' ||
'"port": ' || current_setting('migration.redis_port') ||
'}, "header": {"token": {"user": "X-USER-TOKEN", "device": "X-DEVICE-TOKEN", "application": "X-APPLICATION-TOKEN"}, "identity": {"user": "X-USER-IDENTITY", "device": "X-DEVICE-IDENTITY", "domain": "X-DOMAIN-IDENTITY", "system": "X-SYSTEM-IDENTITY", "service": "X-SERVICE-IDENTITY", "application": "X-APPLICATION-IDENTITY"}}, "unauthorized.html": "<HTML><BODY><H1>401 Unauthorized BAD CREDENTIALS</H1></BODY></HTML>"}')::jsonb);
-- converter
INSERT INTO configs VALUES (2, 2, NULL, 't', NULL, NULL, ('{"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9553"}}}')::jsonb);
-- router
INSERT INTO configs VALUES (3, 3, NULL, 't', NULL, NULL, ('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "admin_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9554"}}' ||
'}')::jsonb);
-- system
INSERT INTO configs VALUES (4, 4, NULL, 't', NULL, NULL, ('{"db": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "system_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, "RedisAddress": {' ||
'"ip": "' || current_setting('migration.redis_host') || '", ' ||
'"port": "' || current_setting('migration.redis_port') || '"' ||
'}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9555"}}' ||
'}')::jsonb);
-- admin
INSERT INTO configs VALUES (5, 5, NULL, 't', NULL, NULL, ('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "admin_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9557"}}' ||
'}')::jsonb);
SELECT setval(pg_get_serial_sequence('configs', 'id'), 6, FALSE);
-- +goose Down
DELETE FROM configs WHERE id IN (1,2,3,4,5)
@@ -1,127 +0,0 @@
-- +goose Up
set migration.db_host = 'msk-pgsql.isp.mobi';
set migration.db_port = '5432';
set migration.db_dbname = 'isp-alpha';
set migration.db_user = 'isp-alpha';
set migration.db_pass = 'JxY96xLF8zfh3g8EWvSDtLUBw';
set migration.redis_host = '10.250.9.117';
set migration.redis_port = '6379';
-- user
INSERT INTO configs VALUES (6, 6, NULL, 't', NULL, NULL, (format('{
"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9556"}},
"database": {
"username": "%s",
"createSchema": true,
"port": "%s",
"schema": "user_service",
"address": "%s",
"database": "%s",
"password": "%s"
},
"redisAddress": {
"ip": "%s",
"port": "%s"
},
"userTokenExpireMs": -1,
"authSmsSystemSender": "",
"authSmsTextTemplate": "Your code {{code}}",
"deviceTokenExpireMs": -1,
"authSmsShortCodeLength": 4,
"authSmsShortCodeExpireMs": 300000
}', current_setting('migration.db_user'),
current_setting('migration.db_port'),
current_setting('migration.db_host'),
current_setting('migration.db_dbname'),
current_setting('migration.db_pass'),
current_setting('migration.redis_host'),
current_setting('migration.redis_port')
)) :: jsonb);
-- mobile
INSERT INTO configs VALUES (7, 7, NULL, 't', NULL, NULL, ('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "mobile_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9562"}}' ||
'}')::jsonb);
-- awip
INSERT INTO configs VALUES (8, 8, NULL, 't', NULL, NULL, '{
"backends": [
{
"id": "450e754f-aafb-4a9c-8d87-23c6a2da9833",
"url": "http://{{ cname }}-nginx.isp.mobi:18888/ru.isp.starter.awip.backend.ws/backend?wsdl",
"name": "citymatica_user_new",
"wrapList": true,
"createDate": "2018-09-07T09:41:03.853Z",
"clientPoolSize": 0,
"requestTimeout": 30000,
"systemIdentity": "1"
},
{
"id": "74d76314-b28b-11e8-96f8-529269fb1459",
"url": "http://{{ cname }}-nginx.isp.mobi:18880/ru.mp.storage.backend.ws/backend?wsdl",
"name": "citymatica_user_old",
"wrapList": true,
"createDate": "2018-09-07T09:41:03.853Z",
"clientPoolSize": 0,
"requestTimeout": 30000,
"systemIdentity": "1"
},
{
"id": "74d7659e-b28b-11e8-96f8-529269fb1459",
"url": "http://{{ cname }}-nginx.isp.mobi:18890/ru.isp.starter.awip.backend.ws/backend?wsdl",
"name": "citymatica_user_object_storage",
"wrapList": true,
"createDate": "2018-09-07T09:41:03.853Z",
"clientPoolSize": 0,
"requestTimeout": 30000,
"systemIdentity": "1"
},
{
"id": "74d75cc0-b28b-11e8-96f8-529269fb1459",
"url": "http://{{ cname }}-nginx.isp.mobi:18891/ru.isp.starter.awip.backend.ws/backend?wsdl",
"name": "citymatica_user_events",
"wrapList": true,
"createDate": "2018-09-07T09:41:03.853Z",
"clientPoolSize": 0,
"requestTimeout": 30000,
"systemIdentity": "1"
},
{
"id": "d5575047-6588-46d9-be58-b487d42d217c",
"url": "http://{{ cname }}-nginx.isp.mobi:18889/ru.isp.starter.awip.backend.ws/backend?wsdl",
"name": "citymatica_operator",
"wrapList": true,
"createDate": "2018-09-07T09:41:03.853Z",
"clientPoolSize": 0,
"requestTimeout": 30000,
"systemIdentity": "1"
},
{
"id": "74d76094-b28b-11e8-96f8-529269fb1459",
"url": "http://{{ cname }}-nginx.isp.mobi:18895/ru.isp.starter.awip.backend.ws/backend?wsdl",
"name": "citymatica_operator_metrics",
"wrapList": true,
"createDate": "2018-09-07T09:41:03.853Z",
"clientPoolSize": 0,
"requestTimeout": 30000,
"systemIdentity": "1"
}
]
}');
-- mongo-backend
INSERT INTO configs VALUES (9, 9, NULL, 't', NULL, NULL, '{"connections": [],"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9563"}}}');
-- sql-backend
INSERT INTO configs VALUES (10, 10, NULL, 't', NULL, NULL, '{"connections": [], "metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9566"}}}');
-- events
INSERT INTO configs VALUES (11, 11, NULL, 't', NULL, NULL, '{"eventRoutes": [{"handlers": {}, "applicationGroupId": 1}, {"handlers": {}, "applicationGroupId": 5}], "queueEndpoints": []}');
SELECT setval(pg_get_serial_sequence('configs', 'id'), 12, FALSE);
-- +goose Down
DELETE FROM configs WHERE id IN (6,7,8,9,10,11)
@@ -1,9 +0,0 @@
-- +goose Up
ALTER TABLE configs
ADD COLUMN name VARCHAR(255) NOT NULL DEFAULT 'unnamed',
ADD COLUMN description TEXT;
-- +goose Down
ALTER TABLE configs
DROP COLUMN name,
DROP COLUMN description;
@@ -1,23 +0,0 @@
-- +goose Up
CREATE TABLE config_schemas (
id SERIAL4 PRIMARY KEY,
module_id INTEGER NOT NULL,
version VARCHAR(255) NOT NULL,
schema JSONB NOT NULL DEFAULT '{}',
created_at TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
updated_at TIMESTAMP NOT NULL DEFAULT (now() at time zone 'utc'),
CONSTRAINT FK_module_id__module_id FOREIGN KEY (module_id)
REFERENCES modules (id) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TRIGGER update_schema_create_time
BEFORE INSERT OR UPDATE
ON config_schemas
FOR EACH ROW EXECUTE PROCEDURE update_created_column_date();
CREATE INDEX IX_schemes_moduleId
ON config_schemas
USING hash (module_id);
-- +goose Down
DROP TABLE config_schemas;
@@ -1,43 +0,0 @@
-- +goose Up
set migration.db_host = 'msk-pgsql.isp.mobi';
set migration.db_port = '5432';
set migration.db_dbname = 'isp-alpha';
set migration.db_user = 'isp-alpha';
set migration.db_pass = 'JxY96xLF8zfh3g8EWvSDtLUBw';
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'template', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "template_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, "defaultLanguage": "en", ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9567"}}' ||
'}')::jsonb);
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'message-bundle', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{"database": {' ||
'"port": "' || current_setting('migration.db_port') || '", ' ||
'"schema": "message_bundle_service", ' ||
'"address": "' || current_setting('migration.db_host') || '", ' ||
'"database": "' || current_setting('migration.db_dbname') || '", ' ||
'"password": "' || current_setting('migration.db_pass') || '", ' ||
'"username": "' || current_setting('migration.db_user') || '", ' ||
'"createSchema": true}, "defaultLanguage": "en", ' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9560"}}' ||
'}')::jsonb);
-- +goose Down
@@ -1,88 +0,0 @@
-- +goose Up
set migration.nats_host = '10.250.9.117';
set migration.nats_port = '4223';
set migration.nats_cluster_id = 'test-cluster';
WITH moduleVar AS (INSERT INTO modules (instance_id, name, active) VALUES (1, 'mobile-push', 't') RETURNING id)
INSERT INTO configs (module_id, active, data)
VALUES ((SELECT id FROM moduleVar), 't', (
format('{
"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9561"}},
"firebaseConfig": {
"token_uri": "https://accounts.google.com/o/oauth2/token",
"client_id": "115553569331708875508",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"client_email": "firebase-adminsdk-f70qo@test-ccdab.iam.gserviceaccount.com",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCM7Rl7AmGQSOxx\nUdQs+yY7cwaUmqi2khmsre0/kfJU2zCJxotbYNeyfWJZk3D8hngxnmI6hrYqWEq3\nyy/J8rhI7AmcY3eXC1yyL/sKTClFjyZVEoDcBWTn0HOuM8YAQAqRAx2vznKDquoj\nLgUHl09qTxsVRmPdfc7fKE45OZBdetA/kdIEd4S5J+CKeYB7tpuT+0eL4QUNOzE1\n6SGqYnhA97QD7K3ylhWxKC8U0Ozyqub/OTg7WRLEYV36Z+6Ok0BZkYiCXbUNukST\nXaKc8DGAFrzcu7jW8rJIRZ/uc/Im5judjuMRznzu1SMPVT6pL8HfduGFc23FIAL/\nGjmcDwWbAgMBAAECggEAETe6oDvHPcCbGrE7sg8xOZwxFqDasguhlWZekSC8sb9h\n68NVLWHkmIsXJAiOilvHfZBzQeFJilzlLBVoDk1YVJh6CCBi8RJTTfXsvvJVLIlz\nznsHQVprXKMsLwFmVIt+fv8ZdmxLs2iDWK77sFS9QCjQD0ZdVydSyhL7k6RDzhfP\nw6It0H3JyyqD8W7DOvYSUfi/oZKZvufBAkEauhuiVVyite97cJtV8YNmiVCznOtK\nOw0OpuzemKez0rh673VtEEvUgrvOy5WNtjunoRkNKZkW1JiAWYpf6FpOOFub/lG3\nQPFwjLZeEUa8xc/E2JJP6HQMON0qF5zvtKr4QH/9uQKBgQDByXfLh+56Cu+6E0CL\nigH0GmagwZQnw7/+zhi1AhC2DjxAmXq9Y0kFrmpwr6FXqtRJm5AANOipASsRknaq\n5kAlDCGdqHnw1LDlNbrxywDvTYADo13ebx2cXfxESDfx0gofXehGhfFfOyXJ0lwp\ngXbgxIQFNjv2QWjSdb637ZaOrQKBgQC6KzmZcMAWo7j+eGo0WoAVTCVu/SDcV/sG\nF4+NxhLjMYSuMbBF7BdMy1rJ6g3SrdULGzw0KDeEqo1XzneOyzHOnEiZFKTkgIPQ\n347fWOYTBKMNEJd37jAIHKrrFiyD/pvL2ZLu1mSnCHsi/v5u02gqpf8Vkvwo/5ME\n4BuhB/PWZwKBgQC7V0adl+rfR0VcURJcE+4xi3hdvua4zpAFCD9wde+r4PU0ymuT\nPbGxcV1rVQ8YTojuJBrBaGToRb3aPgrEytWGO0UgQmiofyYIYLo62LMtpXG1krDD\nwg4RRfcEGAEloZWxnzpXO1QOaYLtqpT4dzVys+ihlT3AoplwpO3cqC6d/QKBgEGu\nkmnSX9Mc/F27eizyaRIahXJ9GCTlXYkustUgNvW1OMyEd16UBzxu2p82Vp4n+mwq\ntbjpH31M9wUtsPzOL8pnVS29HNgJh3ggB7ZBFRtMnYI0glwrywJxqtO6RQZkw+7N\n2ostVOGhmmAkevv61luFqVOhQhns4Z/suZK8zYitAoGAHwLWUQViCy0HFkhED5GV\nWrZZFRH2ucpK+ljOp7dbbUPA+dTD2qu/hho3QCaT5odJWap42TbSL6YhZg/7jN7h\nOSQW8DiDPzjUtL1gfqOxJdQavrgR2a2AW054loM0R508699Vx6Hir/ayD4nZ9IUo\nm2meeJVZcknz/L9LXOOIUBk=\n-----END PRIVATE KEY-----\n",
"private_key_id": "88d1af761304de758388747d72931c3457df54ef",
"project_id": "test-ccdab",
"type": "service_account",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-f70qo%%40test-ccdab.iam.gserviceaccount.com"
},
"concurrentSendersCount": 6,
"natsConfig": {
"address": {
"port": "%s",
"ip": "%s"
},
"clusterId": "%s"
}
}', current_setting('migration.nats_port'),
current_setting('migration.nats_host'),
current_setting('migration.nats_cluster_id')
)) :: jsonb);
WITH moduleVar AS (INSERT INTO modules (instance_id, name, active) VALUES (1, 'sms', 't') RETURNING id)
INSERT INTO configs (module_id, active, data)
VALUES ((SELECT id FROM moduleVar), 't', (format('{
"natsConfig": {
"clusterId": "%s",
"address": {
"ip": "%s",
"port": "%s"
}
},
"smppClients": [
{
"default": true,
"poolSize": 1,
"connection": {
"password": "1q2w3e!",
"user": "isp",
"address": {
"ip": "5.187.0.65",
"port": "9931"
}
},
"ResponseTimeoutMs": 5000,
"concurrentSendersCount": 2,
"name": "smsc"
}
],
"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9565"}}
}', current_setting('migration.nats_cluster_id'),
current_setting('migration.nats_host'),
current_setting('migration.nats_port')
)) :: jsonb);
WITH moduleVar AS (INSERT INTO modules (instance_id, name, active) VALUES (1, 'email', 't') RETURNING id)
INSERT INTO configs (module_id, active, data)
VALUES ((SELECT id FROM moduleVar), 't', (format('{
"natsConfig": {
"clusterId": "%s",
"address": {
"ip": "%s",
"port": "%s"
}
},
"smtpClients": [
],
"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9558"}}
}', current_setting('migration.nats_cluster_id'),
current_setting('migration.nats_host'),
current_setting('migration.nats_port')
)) :: jsonb);
-- +goose Down
@@ -1,27 +0,0 @@
-- +goose Up
WITH moduleVar AS (INSERT INTO modules (instance_id, name, active) VALUES (1, 'file-storage', 't')
RETURNING id)
INSERT INTO configs (module_id, active, data)
VALUES ((SELECT id FROM moduleVar), 't', '{
"imageSizeList": [
75,
130,
200,
320,
510,
604,
807
],
"rootDirectory": "./files/",
"maxRequestBodySizeInBytes": 1073741824,
"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9559"}}
}' :: jsonb);
WITH moduleVar AS (INSERT INTO modules (instance_id, name, active) VALUES (1, 'rest-backend', 't')
RETURNING id)
INSERT INTO configs (module_id, active, data)
VALUES ((SELECT id FROM moduleVar), 't', '{
"backends": [], "metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9564"}}
}' :: jsonb);
-- +goose Down
@@ -1,54 +0,0 @@
-- +goose Up
set migrationRead.db_host = 'msk-pgsql.isp.mobi';
set migrationRead.db_port = '5432';
set migrationRead.db_dbname = 'isp-alpha';
set migrationRead.db_user = 'isp-alpha';
set migrationRead.db_pass = 'JxY96xLF8zfh3g8EWvSDtLUBw';
set migrationWrite.db_host = 'msk-pgsql.isp.mobi';
set migrationWrite.db_port = '5432';
set migrationWrite.db_dbname = 'isp-alpha';
set migrationWrite.db_user = 'isp-alpha';
set migrationWrite.db_pass = 'JxY96xLF8zfh3g8EWvSDtLUBw';
set migrationNotification.db_host = 'msk-pgsql.isp.mobi';
set migrationNotification.db_port = '5432';
set migrationNotification.db_dbname = 'isp-alpha';
set migrationNotification.db_user = 'isp-alpha';
set migrationNotification.db_pass = 'JxY96xLF8zfh3g8EWvSDtLUBw';
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'mdm', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{"databaseRead": {' ||
'"port": "' || current_setting('migrationRead.db_port') || '", ' ||
'"schema": "mdm_service", ' ||
'"address": "' || current_setting('migrationRead.db_host') || '", ' ||
'"database": "' || current_setting('migrationRead.db_dbname') || '", ' ||
'"password": "' || current_setting('migrationRead.db_pass') || '", ' ||
'"username": "' || current_setting('migrationRead.db_user') || '", ' ||
'"createSchema": true},' ||
'"metrics": {"gc": true, "memory": true, "address": {"ip": "0.0.0.0", "path": "/metrics", "port": "9568"}},' ||
'"databaseWrite": {' ||
'"port": "' || current_setting('migrationWrite.db_port') || '", ' ||
'"schema": "mdm_service", ' ||
'"address": "' || current_setting('migrationWrite.db_host') || '", ' ||
'"database": "' || current_setting('migrationWrite.db_dbname') || '", ' ||
'"password": "' || current_setting('migrationWrite.db_pass') || '", ' ||
'"username": "' || current_setting('migrationWrite.db_user') || '", ' ||
'"createSchema": true},' ||
'"databaseNotifications": {' ||
'"port": "' || current_setting('migrationNotification.db_port') || '", ' ||
'"schema": "mdm_service", ' ||
'"address": "' || current_setting('migrationNotification.db_host') || '", ' ||
'"database": "' || current_setting('migrationNotification.db_dbname') || '", ' ||
'"password": "' || current_setting('migrationNotification.db_pass') || '", ' ||
'"username": "' || current_setting('migrationNotification.db_user') || '", ' ||
'"createSchema": true}}')::jsonb);
-- +goose Down
@@ -1,90 +0,0 @@
-- +goose Up
set migration.nats_host = '10.250.9.117';
set migration.nats_port = '4223';
set migration.nats_cluster_id = 'test-cluster';
set migration.rabbit_host = '10.250.9.117';
set migration.rabbit_port = '5672';
set migration.rabbit_user = 'guest';
set migration.rabbit_password = 'guest';
set migration.rabbit_system_queue_prefix = 'test';
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'mdm-notify', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{
"notifyConfigurations":[],
"logger": {
"sendAddRequestSudirV1IsOn": true,
"sendFindRequestSudirV1IsOn": true,
"sendUpdateRequestSudirV1IsOn": true,
"sendUpdateRequestSudirV2IsOn": true,
"creatingSystemNotificationsIsOn": true,
"sendErlRequestQueueIsOn": true,
"sendJsonRequestQueueIsOn": true,
"syncLogger": {
"enable": false,
"filename": "/opt/isp/isp-mdm-notify-service/events_logs/events.log.gz"
},
"asyncLogger": {
"enable": false,
"nats": {
"address": {
"ip": "mdm-taxcom-test-nats.isp.mobi",
"port": "4222"
},
"clusterId": "work-cluster"
}
},
"sendAddRequestSudirV1IsOn": true
},
"metrics":{
"gc": true,
"memory": true,
"address": {
"port": "9572",
"ip": "0.0.0.0",
"path": "/metrics"
}
},
"rabbit": {
"routingKey": "notification",
"exchangeName": "notifications",
"systemQueuesPrefix": "' || current_setting('migration.rabbit_system_queue_prefix') || '",
"declareQueueAndExchange": true,
"password": "' || current_setting('migration.rabbit_password') || '",
"user": "' || current_setting('migration.rabbit_user') || '",
"address": {
"ip": "' || current_setting('migration.rabbit_host') || '",
"port": "' || current_setting('migration.rabbit_port') || '"
}
"queue": {
"name": "notifier.queue",
"prefetchCount": 1000
},
},
"logRabbitEnabled": true,
"logRabbit": {
"address": {
"ip": "10.250.9.50",
"port": "5672"
},
"password": "ohk7athXehev3aiGfic2ZeiD",
"routingKey": "mdm-taxcom-test.notify.log",
"exchangeName": "mdm-taxcom-test.notify.log",
"systemQueuesPrefix": "mdm-taxcom-test",
"declareQueueAndExchange": true,
"user": "isp",
"queue": {
"name": "mdm-taxcom-test.notify.log.queue",
"prefetchCount": 300
}
}
}')::jsonb);
-- +goose Down
@@ -1,105 +0,0 @@
-- +goose Up
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'mdm-notify', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{
"rules": {
"1": [
"etalon_id",
"last_name",
"$$documents.#passport",
"vehicles",
"addresses"
]
},
"mappingSchema": {
"$$documents.1000019.ref_num": "DRIVER_LICENSE.DriverLicense",
"gkupays.mesmeter": "[]HOUSE.MesMeterNumber",
"$$documents.1000016.start_dt": "PASSPORT_RF.PassportIssueDate",
"$$addresses.1000009.moscow_district_id": "[]REG_ADDRESS.RegAddressDistrictId",
"$$addresses.7.unom": "[]ADDRESS.RealAddressUnom",
"$$addresses.1000009.unom": "[]REG_ADDRESS.RegAddressUnom",
"$$addresses.1000009.moscow_area_ext_id": "[]REG_ADDRESS.RegAddressAreaId",
"$$addresses.7.moscow_area_ext_id": "[]ADDRESS.RealAddressAreaId",
"$$escredentials.1000004.etalon_id": "[]OLYMPIAD.OlympiadId",
"last_name": "FIO.LastName",
"vehicles.reg_number": "[]VEHICLE.VehicleRegistrationNumber",
"$$contacts.1.ref_num": "REG_DATA.Phone",
"$$addresses.7.corpus_no": "[]ADDRESS.RealAddressCorpus",
"$$users.NOT_SSO.id_value": "USER.LoginName",
"$$addresses.7.residence_num": "[]ADDRESS.RealAddressFlat",
"$$users.SSO.id_value": "USER.LoginName",
"birth_place_line_one": "PASSPORT_RF.PassportBirthPlace",
"$$addresses.7.house_no": "[]ADDRESS.RealAddressHouse",
"$$addresses.1000009.street_name_ex": "[]REG_ADDRESS.RegAddressStreet",
"gkupays.mesaccount": "[]HOUSE.MesAccountNumber",
"vehicles.etalon_id": "[]VEHICLE.VehicleId",
"$$addresses.7.street_id": "[]ADDRESS.RealAddressStreetId",
"$$documents.1000014.ref_num": "COMPLEX_OMS.oms",
"$$addresses.1000009.stroenie_no": "[]REG_ADDRESS.RegAddressBuilding",
"$$addresses.7.moscow_district_id": "[]ADDRESS.RealAddressDistrictId",
"$$addresses.7.unad": "[]ADDRESS.RealAddressUnad",
"vehicles.pts_number": "[]VEHICLE.VehiclePTSNumber",
"$$documents.1000016.identification_issuer": "PASSPORT_RF.PassportIssuer",
"etalon_id": "USER.LoginName",
"$$addresses.1000009.street_id": "[]REG_ADDRESS.RegAddressStreetId",
"$$escredentials.1000003.etalon_id": "[]GIA.GIAId",
"$$addresses.1000009.moscow_district_name": "[]REG_ADDRESS.RegAddressDistrict",
"given_name_one": "FIO.FirstName",
"vehicles.vin_number": "[]VEHICLE.VehicleVin",
"$$escredentials.1000004.login": "[]OLYMPIAD.OlympiadLogin",
"$$escredentials.1000003.doc_number": "[]GIA.GIADocNumber",
"$$addresses.1000009.moscow_area_name": "[]REG_ADDRESS.RegAddressArea",
"gkupays.gkupay_address_rel": "[]HOUSE.EpdAddressId",
"$$addresses.7.building_name": "[]ADDRESS.RealAddressHouseId",
"$$addresses.7.moscow_area_name": "[]ADDRESS.RealAddressArea",
"$$addresses.7.moscow_district_name": "[]ADDRESS.RealAddressDistrict",
"gender_tp_code": "PERSON.Gender",
"$$addresses.7.stroenie_no": "[]ADDRESS.RealAddressBuilding",
"$$documents.1000013.ref_num": "TAX_INFO.INN",
"$$addresses.1000009.building_name": "[]REG_ADDRESS.RegAddressHouseId",
"$$escredentials.1000004.description": "[]OLYMPIAD.OlympiadComment",
"birth_dt": "PERSON.Birthday",
"gkupays.epd": "[]HOUSE.EpdAddressNumber",
"$$addresses.1000009.house_no": "[]REG_ADDRESS.RegAddressHouse",
"$$addresses.1000009.street_omk": "[]REG_ADDRESS.RegAddressStreetOMK",
"$$citizen_relatives.OTHERS.etalon_id": "[]RELATIVES.RltvId",
"vehicles.stsnumber": "[]VEHICLE.VehicleSTSNumber",
"vehicles.description": "[]VEHICLE.VehicleDescription",
"$$addresses.1000009.unad": "[]REG_ADDRESS.RegAddressUnad",
"$$escredentials.1000004.password": "[]OLYMPIAD.OlympiadPassword",
"gkupays.phone": "[]HOUSE.EpdAddressCityPhone",
"$$addresses.7.street_omk": "[]ADDRESS.RealAddressStreetOMK",
"$$documents.1000019.start_dt": "DRIVER_LICENSE.DriverLicenseIssueDate",
"$$addresses.1000009.corpus_no": "[]REG_ADDRESS.RegAddressCorpus",
"$$citizen_relatives.1000004.etalon_id": "[]CHILDREN.ChildId",
"$$documents.1000016.identification_issuer_code": "PASSPORT_RF.PassportIssuerCode",
"$$escredentials.1000003.login": "[]GIA.GIARegCode",
"$$addresses.1000009.residence_num": "[]REG_ADDRESS.RegAddressFlat",
"given_name_two": "FIO.MiddleName",
"$$contacts.2.ref_num": "REG_DATA.Email",
"$$documents.1000015.ref_num": "SNILS.snils",
"$$documents.1000016.ref_num": "PASSPORT_RF.PassportNumber",
"$$addresses.7.street_name_ex": "[]ADDRESS.RealAddressStreet",
"$$documents.1000014.etalon_id": "COMPLEX_OMS.OmsId",
"$$escredentials.1000003.description": "[]GIA.GIAComment",
"$$citizen_relatives.1000003.etalon_id": "[]CHILDREN.ChildId",
"$$documents.1000016.identification_passport_birth_place": "PASSPORT_RF.PassportBirthPlace"
},
"metrics": {
"memory": true,
"address": {
"path": "/metrics",
"port": "9571",
"ip": "0.0.0.0"
},
"gc": true
}
}')::jsonb);
-- +goose Down
@@ -1,66 +0,0 @@
-- +goose Up
set migration.nats_host = '10.250.9.117';
set migration.nats_port = '4223';
set migration.nats_cluster_id = 'test-cluster';
set migration.rabbit_host = '10.250.9.117';
set migration.rabbit_port = '5672';
set migration.rabbit_user = 'guest';
set migration.rabbit_password = 'guest';
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'mdm-notify', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{
"isNatsLoggerEnabled": false,
"nats": {
"address": {
"port": "' || current_setting('migration.nats_port') || '",
"ip": "' || current_setting('migration.nats_host') || '"
},
"clusterId": "' || current_setting('migration.nats_cluster_id') || '"
},
"queue": {
"init": {
"concurrentConsumers": 8,
"name": "init",
"prefetchCount": 10
},
"tempQueue": {
"name": "tempt",
"prefetchCount": 10,
"concurrentConsumers": 128
},
"defaultQueue": {
"concurrentConsumers": 128,
"name": "events",
"prefetchCount": 10
}
},
"rabbit": {
"password": "' || current_setting('migration.rabbit_password') || '",
"reconnectionTimeoutMs": 0,
"user": "' || current_setting('migration.rabbit_user') || '",
"address": {
"ip": "' || current_setting('migration.rabbit_host') || '",
"port": "' || current_setting('migration.rabbit_port') || '"
}
},
"metrics": {
"memory": true,
"address": {
"path": "/metrics",
"port": "9569",
"ip": "0.0.0.0"
},
"gc": true
}
}')::jsonb);
-- +goose Down
@@ -1,14 +0,0 @@
-- +goose Up
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'mdm-api', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
('{' ||
'"pKAttributeName": "id"' ||
'}')::jsonb);
-- +goose Down
@@ -1,61 +0,0 @@
-- +goose Up
set rabbit.host = '10.250.9.117';
set rabbit.port = '5672';
set rabbit.user = 'guest';
set rabbit.password = 'guest';
set elastic.url = 'http://10.250.9.48:9200';
WITH moduleVar AS (
INSERT INTO modules (instance_id, name, active) VALUES (1, 'mdm-search', 't') RETURNING id
)
INSERT INTO configs (module_id, active, data) VALUES (
(SELECT id FROM moduleVar),
't',
((format('{
"queue": {
"prefetchSize": 1000,
"searcherQueue": "searcher.queue",
"concurrentConsumers": 4
},
"rabbit": {
"user": "%s",
"address": {
"ip": "%s",
"port": "%s"
},
"password": "%s"
},
"elastic": {
"uRL": "%s",
"shards": 1
},
"metrics": {
"address": {
"ip": "0.0.0.0",
"path": "/metrics",
"port": "9573"
},
"gc": true,
"memory": true
},
"isFieldsListWhite": false,
"fieldsList": [
"documents",
"citizen_relatives",
"contacts",
"addresses",
"escredentials",
"users"
]
}', current_setting('rabbit.user'),
current_setting('rabbit.host'),
current_setting('rabbit.port'),
current_setting('rabbit.password'),
current_setting('elastic.url')
)) :: jsonb));
-- +goose Down
-96
View File
@@ -1,96 +0,0 @@
package model
import (
"isp-config-service/entity"
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
)
type ConfigRepository struct {
DB orm.DB
}
func (r *ConfigRepository) GetConfigs(identities []int64) ([]entity.Config, error) {
var configs []entity.Config
var err error
if len(identities) > 0 {
err = r.DB.Model(&configs).
Where("id IN (?)", pg.In(identities)).
Order("created_at DESC").
Limit(500).
Select()
} else {
err = r.DB.Model(&configs).
Order("created_at DESC").
Limit(500).
Select()
}
return configs, err
}
func (r *ConfigRepository) GetConfigsByModulesId(modulesId []int32) ([]entity.Config, error) {
var res []entity.Config
err := r.DB.Model(&res).Where("module_id IN (?)", pg.In(modulesId)).Order("created_at DESC").Select()
if err != nil {
return nil, err
}
return res, nil
}
func (r *ConfigRepository) CreateConfig(config *entity.Config) (*entity.Config, error) {
_, err := r.DB.Model(config).
Returning("*").
Insert()
return config, err
}
func (r *ConfigRepository) UpdateConfig(config *entity.Config) (*entity.Config, error) {
_, err := r.DB.Model(config).WherePK().
Returning("*").
Update()
return config, err
}
func (r *ConfigRepository) DeleteConfig(identities []int64) (int, error) {
result, err := r.DB.Exec("DELETE FROM "+schema+".configs WHERE id IN (?)", pg.In(identities))
return result.RowsAffected(), err
}
func (r *ConfigRepository) GetConfigById(identity int64) (*entity.Config, error) {
cfg := new(entity.Config)
err := r.DB.Model(cfg).
Where("id = ?", identity).
First()
if err == pg.ErrNoRows {
return nil, nil
}
return cfg, err
}
func (r *ConfigRepository) GetConfigByInstanceUUIDAndModuleName(instanceUUID string, moduleName string) (*entity.Config, error) {
cfg := new(entity.Config)
err := r.DB.Model(cfg).
Where(`module_id = (SELECT id FROM `+schema+`.modules WHERE name = ?
AND instance_id = (SELECT id FROM `+schema+`.instances WHERE uuid = ?))`, moduleName, instanceUUID).
Where("active = true").
Order("updated_at DESC").
First()
if err == pg.ErrNoRows {
return nil, nil
}
return cfg, err
}
func (r *ConfigRepository) GetModuleNameAndInstanceUUIDByConfigId(configId int64) (entity.ModuleInstanceIdentity, error) {
var cfg entity.ModuleInstanceIdentity
_, err := r.DB.Query(&cfg, `SELECT temp.name, uuid
FROM (SELECT name, instance_id FROM `+schema+`.modules WHERE id =
(SELECT module_id FROM `+schema+`.configs WHERE id = ? AND active = true)) temp
LEFT JOIN `+schema+`.instances s ON s.id = temp.instance_id`, configId)
if err != nil && err == pg.ErrNoRows {
return cfg, nil
}
return cfg, err
}
-73
View File
@@ -1,73 +0,0 @@
package model
import (
"isp-config-service/entity"
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
)
type InstanceRepository struct {
DB orm.DB
}
func (r *InstanceRepository) GetInstances(identities []int32) ([]entity.Instance, error) {
var instances []entity.Instance
var err error
if len(identities) > 0 {
err = r.DB.Model(&instances).
Where("id IN (?)", pg.In(identities)).
Order("created_at DESC").
Limit(500).
Select()
} else {
err = r.DB.Model(&instances).
Order("created_at DESC").
Limit(500).
Select()
}
return instances, err
}
func (r *InstanceRepository) CreateInstance(instance entity.Instance) (entity.Instance, error) {
_, err := r.DB.Model(&instance).
Returning("id").
Returning("created_at").
Insert()
return instance, err
}
func (r *InstanceRepository) UpdateInstance(instance entity.Instance) (entity.Instance, error) {
_, err := r.DB.Model(&instance).WherePK().
Returning("id").
Returning("created_at").
Update()
return instance, err
}
func (r *InstanceRepository) DeleteInstance(identities []int32) (int, error) {
result, err := r.DB.Exec("DELETE FROM "+schema+".instances WHERE id IN (?)", pg.In(identities))
return result.RowsAffected(), err
}
func (r *InstanceRepository) GetInstanceById(identity int32) (entity.Instance, error) {
var module entity.Instance
err := r.DB.Model(&module).
Where("id = ?", identity).
First()
if err != nil && err == pg.ErrNoRows {
return module, nil
}
return module, err
}
func (r *InstanceRepository) GetInstanceByUuid(instanceUuid string) (entity.Instance, error) {
var instance entity.Instance
err := r.DB.Model(&instance).
Where("uuid = ?", instanceUuid).
First()
if err != nil && err == pg.ErrNoRows {
return instance, nil
}
return instance, err
}
-135
View File
@@ -1,135 +0,0 @@
package model
import (
"isp-config-service/entity"
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
"time"
)
type ModulesRepository struct {
DB orm.DB
}
func (r *ModulesRepository) GetModules(identities []int32) ([]entity.Module, error) {
var modules []entity.Module
var err error
if len(identities) > 0 {
err = r.DB.Model(&modules).
Where("id IN (?)", pg.In(identities)).
Order("created_at DESC").
Limit(500).
Select()
} else {
err = r.DB.Model(&modules).
Order("created_at DESC").
Limit(500).
Select()
}
return modules, err
}
func (r *ModulesRepository) GetActiveModules() ([]entity.Module, error) {
var modules []entity.Module
err := r.DB.Model(&modules).
Order("created_at DESC").
Where("active = true").
Limit(500).
Select()
return modules, err
}
func (r *ModulesRepository) CreateModule(module entity.Module) (entity.Module, error) {
_, err := r.DB.Model(&module).
Returning("id").
Returning("active").
Returning("created_at").
Insert()
return module, err
}
func (r *ModulesRepository) UpdateModule(module entity.Module) (entity.Module, error) {
_, err := r.DB.Model(&module).WherePK().
Returning("id").
Returning("active").
Returning("created_at").
Update()
return module, err
}
func (r *ModulesRepository) DeleteModule(identities []int32) (int, error) {
result, err := r.DB.Exec("DELETE FROM "+schema+".modules WHERE id IN (?)", pg.In(identities))
return result.RowsAffected(), err
}
func (r *ModulesRepository) GetModuleById(identity int32) (entity.Module, error) {
var module entity.Module
err := r.DB.Model(&module).
Where("id = ?", identity).
First()
if err != nil && err == pg.ErrNoRows {
return module, nil
}
return module, err
}
func (r *ModulesRepository) GetModuleByInstanceIdAndName(instanceId int32, moduleName string) (entity.Module, error) {
var module entity.Module
err := r.DB.Model(&module).
Where("name = ?", moduleName).
Where("instance_id = ?", instanceId).
First()
if err == pg.ErrNoRows {
return module, nil
}
return module, err
}
func (r *ModulesRepository) UpdateModuleDisconnect(instanceUuid string, moduleName string) error {
var module entity.Module
err := r.DB.Model(&module).
Where("name = ?", moduleName).
Where("instance_id = (SELECT id FROM "+schema+".instances WHERE uuid = ?)", instanceUuid).
First()
if err != nil {
return err
}
if module.Id != 0 {
module.LastDisconnectedAt = time.Now()
_, err := r.DB.Model(&module).WherePK().Update()
if err != nil {
return err
}
}
return err
}
func (r *ModulesRepository) GetModulesByInstanceUuid(instanceUuid string) ([]entity.Module, error) {
var res []entity.Module
err := r.DB.Model(&res).
Where("instance_id = (SELECT id FROM "+schema+".instances WHERE uuid = ?)", instanceUuid).
Select()
if err != nil {
return nil, err
}
return res, nil
}
func (r *ModulesRepository) GetModulesByInstanceUuidAndName(instanceUuid string, name string) (*entity.Module, error) {
res := new(entity.Module)
err := r.DB.Model(res).
Where("instance_id = (SELECT id FROM "+schema+".instances WHERE uuid = ?)", instanceUuid).
Where("name = ?", name).
First()
if err == pg.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, err
}
return res, nil
}
-24
View File
@@ -1,24 +0,0 @@
package model
import (
"github.com/go-pg/pg"
)
var (
schema = ""
ConfigRep ConfigRepository
ModulesRep ModulesRepository
InstanceRep InstanceRepository
SchemaRep SchemaRepository
)
func SetSchema(s string) {
schema = s
}
func InitDbManager(db *pg.DB) {
ConfigRep = ConfigRepository{db}
ModulesRep = ModulesRepository{db}
InstanceRep = InstanceRepository{db}
SchemaRep = SchemaRepository{db}
}
-30
View File
@@ -1,30 +0,0 @@
package model
import (
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
"isp-config-service/entity"
)
type SchemaRepository struct {
DB orm.DB
}
func (r *SchemaRepository) InsertConfigSchema(s *entity.ConfigSchema) (*entity.ConfigSchema, error) {
_, err := r.DB.Model(s).Returning("*").Insert()
return s, err
}
func (r *SchemaRepository) UpdateConfigSchema(s *entity.ConfigSchema) (*entity.ConfigSchema, error) {
_, err := r.DB.Model(s).Returning("*").WherePK().Update()
return s, err
}
func (r *SchemaRepository) GetSchemasByModulesId(modulesId []int32) ([]entity.ConfigSchema, error) {
var res []entity.ConfigSchema
err := r.DB.Model(&res).Where("module_id IN (?)", pg.In(modulesId)).Select()
if err != nil {
return nil, err
}
return res, nil
}
-134
View File
@@ -1,134 +0,0 @@
package module
import (
"github.com/integration-system/isp-lib/config"
"isp-config-service/conf"
"isp-config-service/domain"
st "isp-config-service/entity"
"isp-config-service/model"
"isp-config-service/socket"
"sort"
"time"
)
var (
startAt = time.Now()
Version = "0.1.0"
)
func GetAggregatedModuleInfo(instanceUuid string) ([]*domain.ModuleInfo, error) {
modules, err := model.ModulesRep.GetModulesByInstanceUuid(instanceUuid)
if err != nil {
return nil, err
}
config := config.Get().(*conf.Configuration)
modules = append(modules, st.Module{
Id: -1,
Name: config.ModuleName,
Active: true,
CreatedAt: startAt,
InstanceId: -1,
})
l := len(modules)
res := make([]*domain.ModuleInfo, l)
m := make(map[int32]*domain.ModuleInfo, l)
idList := make([]int32, l)
for i, module := range modules {
idList[i] = module.Id
info := &domain.ModuleInfo{
Id: module.Id,
Name: module.Name,
Active: module.Active,
CreatedAt: module.CreatedAt,
LastConnectedAt: module.LastConnectedAt,
LastDisconnectedAt: module.LastDisconnectedAt,
}
m[module.Id] = info
res[i] = info
}
configs, err := model.ConfigRep.GetConfigsByModulesId(idList)
if err != nil {
return nil, err
}
for _, cfg := range configs {
info := m[cfg.ModuleId]
info.Configs = append(info.Configs, cfg)
}
schemas, err := model.SchemaRep.GetSchemasByModulesId(idList)
if err != nil {
return nil, err
}
for _, s := range schemas {
info := m[s.ModuleId]
schema := s.Schema
info.ConfigSchema = &schema
}
connMap := socket.GetModuleConnectionIdMapByInstanceId(instanceUuid)
routes := socket.GetRoutes().Routes
//converters := socket.GetConverters()
//routers := socket.GetRouters()
roomsStat := socket.GetRoomsCount()
for _, info := range res {
if info.Id == -1 {
info.Status = append(info.Status, domain.Connection{
Address: config.GrpcOuterAddress,
Version: Version,
Endpoints: socket.ConfigServiceBackendDeclaration.Endpoints,
LibVersion: socket.ConfigServiceBackendDeclaration.LibVersion,
EstablishedAt: startAt,
})
} else if conns, connected := connMap[info.Name]; connected {
for _, conId := range conns {
hasRoutes := false
var data *domain.Connection
if backend, ok := routes[conId]; ok {
data = &domain.Connection{
Version: backend.Version,
LibVersion: backend.LibVersion,
Address: backend.Address,
Endpoints: backend.Endpoints,
}
hasRoutes = true
} else if roomsStat[instanceUuid][info.Name] <= 0 {
continue
}
if c, ok := socket.GetConnectionById(instanceUuid, conId); ok {
if !hasRoutes {
data = &domain.Connection{
Version: "unknown",
}
/*if router, ok := routers[conId]; ok {
data.Address = router
} else if converter, ok := converters[conId]; ok {
data.Address = converter
}*/
}
data.EstablishedAt = c.EstablishedAt
}
info.Status = append(info.Status, *data)
}
}
}
for _, s := range res {
sort.Slice(s.Status, func(i, j int) bool {
return s.Status[i].EstablishedAt.Before(s.Status[j].EstablishedAt)
})
for _, con := range s.Status {
sort.Slice(con.Endpoints, func(i, j int) bool {
return con.Endpoints[i].Path < con.Endpoints[j].Path
})
}
}
sort.Slice(res, func(i, j int) bool {
return res[i].Name < res[j].Name
})
return res, nil
}
-28
View File
@@ -1,28 +0,0 @@
syntax = "proto3";
// /home/andrey/Applications/protoc/bin/protoc -I ./ proto/system.proto --go_out=plugins=grpc:./
option java_multiple_files = true;
option java_package = "io.grpc.convertService";
option java_outer_classname = "ConvertServiceProto";
package isp;
import "google/api/annotations.proto";
import "google/protobuf/struct.proto";
message Message {
oneof body {
google.protobuf.Struct structBody = 1;
google.protobuf.ListValue listBody = 2;
google.protobuf.NullValue NullBody = 3;
}
}
service BackendService {
// ===== SYSTEM =====
rpc Request (Message) returns (Message) {
option (google.api.http) = {
post: "/api"
body: "*"
};
}
}
-134
View File
@@ -1,134 +0,0 @@
{
"swagger": "2.0",
"info": {
"title": "proto/backend_service.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/api": {
"post": {
"summary": "===== SYSTEM =====",
"operationId": "Request",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/ispMessage"
}
}
},
"parameters": [
{
"name": "Grpc-Metadata-proxy_method_name",
"in": "header",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ispMessage"
}
}
],
"tags": [
"BackendService"
]
}
}
},
"definitions": {
"ispMessage": {
"type": "object",
"properties": {
"structBody": {
"$ref": "#/definitions/protobufStruct"
},
"listBody": {
"$ref": "#/definitions/protobufListValue"
},
"NullBody": {
"$ref": "#/definitions/protobufNullValue"
}
}
},
"protobufListValue": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufValue"
},
"description": "Repeated field of dynamically typed values."
}
},
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
},
"protobufNullValue": {
"type": "string",
"enum": [
"NULL_VALUE"
],
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"protobufStruct": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/protobufValue"
},
"description": "Unordered map of dynamically typed values."
}
},
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
},
"protobufValue": {
"type": "object",
"properties": {
"null_value": {
"$ref": "#/definitions/protobufNullValue",
"description": "Represents a null value."
},
"number_value": {
"type": "number",
"format": "double",
"description": "Represents a double value."
},
"string_value": {
"type": "string",
"description": "Represents a string value."
},
"bool_value": {
"type": "boolean",
"format": "boolean",
"description": "Represents a boolean value."
},
"struct_value": {
"$ref": "#/definitions/protobufStruct",
"description": "Represents a structured value."
},
"list_value": {
"$ref": "#/definitions/protobufListValue",
"description": "Represents a repeated `Value`."
}
},
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
}
}
}
-164
View File
@@ -1,164 +0,0 @@
syntax = "proto3";
// /home/andrey/Applications/protoc/bin/protoc -I ./ proto/system.proto --go_out=plugins=grpc:./
option java_multiple_files = true;
option java_package = "io.grpc.configService";
option java_outer_classname = "ConfigServiceProto";
package config.service;
import "google/api/annotations.proto";
import "google/protobuf/struct.proto";
service ConfigService {
// ===== INSTANCE =====
rpc GetInstances (RequestByIdentities) returns (InstancesResponse) {
option (google.api.http) = {
post: "/api/instances"
body: "*"
};
}
rpc CreateUpdateInstance (Instance) returns (Instance) {
option (google.api.http) = {
post: "/api/instances/save"
body: "*"
};
}
rpc DeleteInstance (RequestByIdentities) returns (DeleteResponse) {
option (google.api.http) = {
post: "/api/instances/delete"
body: "*"
};
}
// ===== INSTANCE END =====
// ===== MODULE =====
rpc GetModules (RequestByIdentities) returns (ModulesResponse) {
option (google.api.http) = {
post: "/api/modules"
body: "*"
};
}
rpc GetActiveModules (Empty) returns (ModulesResponse) {
option (google.api.http).get = "/api/modules/actives";
}
rpc CreateUpdateModule (Module) returns (Module) {
option (google.api.http) = {
post: "/api/modules/save"
body: "*"
};
}
rpc DeleteModule (RequestByIdentities) returns (DeleteResponse) {
option (google.api.http) = {
post: "/api/modules/delete"
body: "*"
};
}
rpc GetConnectedModules (Empty) returns (ConnectedModules) {
option (google.api.http).get = "/api/modules/connected";
}
// ===== MODULE END =====
// ===== CONFIG =====
rpc GetConfigs (RequestByIdentities) returns (ConfigsResponse) {
option (google.api.http) = {
post: "/api/configs"
body: "*"
};
}
rpc GetConfigByInstanceUUIDAndModuleName (RequestConfig) returns (Config) {
option (google.api.http).get = "/api/configs_by_module_names/{name}";
}
rpc CreateUpdateConfig (Config) returns (Config) {
option (google.api.http) = {
post: "/api/configs/save"
body: "*"
};
}
rpc DeleteConfig (RequestByIdentities) returns (DeleteResponse) {
option (google.api.http) = {
post: "/api/configs/delete"
body: "*"
};
}
rpc MarkConfigAsActive (RequestByLongIdentity) returns (Config) {
option (google.api.http) = {
post: "/api/configs/active"
body: "*"
};
}
// ===== CONFIG END =====
}
message RequestByLongIdentity {
int64 id = 1;
}
message RequestByIdentities {
repeated int32 ids = 1;
}
message RequestConfig {
string instanceUuid = 1;
string name = 2;
}
message ConnectedModules {
google.protobuf.Struct items = 1;
}
message Instance {
int32 id = 1;
string uuid = 2;
string name = 3;
string createdAt = 4;
}
message Module {
int32 id = 1;
int32 instanceId = 2;
string name = 3;
bool active = 4;
string createdAt = 5;
string lastConnectedAt = 6;
string lastDisconnectedAt = 7;
}
message Config {
int64 id = 1;
int32 moduleId = 2;
int32 version = 3;
bool active = 4;
string createdAt = 5;
string updatedAt = 6;
google.protobuf.Struct data = 7;
}
message InstancesResponse {
repeated Instance items = 1;
}
message ModulesResponse {
repeated Module items = 1;
}
message ConfigsResponse {
repeated Config items = 1;
}
message DeleteResponse {
int32 deleted = 1;
}
message Empty {
}
+145
View File
@@ -0,0 +1,145 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type Backend struct {
db db.DB
}
func NewBackend(db db.DB) Backend {
return Backend{
db: db,
}
}
func (r Backend) Insert(ctx context.Context, backend entity.Backend) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.Insert")
query, args, err := squirrel.Insert(Table("backend")).
Columns("ws_connection_id", "module_id", "address",
"version", "lib_version", "module_name", "config_service_node_id",
"endpoints", "required_modules").
Values(backend.WsConnectionId, backend.ModuleId, backend.Address,
backend.Version, backend.LibVersion, backend.ModuleName, backend.ConfigServiceNodeId,
backend.Endpoints, backend.RequiredModules,
).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Backend) DeleteByWsConnectionIds(ctx context.Context, wsConnectionIds []string) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.DeleteByWsConnectionIds")
query, args, err := squirrel.Delete(Table("backend")).
Where(squirrel.Eq{
"ws_connection_id": wsConnectionIds,
}).ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Backend) DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.DeleteByConfigServiceNodeId")
query, args, err := squirrel.Delete(Table("backend")).
Where(squirrel.Eq{
"config_service_node_id": configServiceNodeId,
}).ToSql()
if err != nil {
return 0, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return 0, errors.WithMessagef(err, "exec: %s", query)
}
deleted, err := result.RowsAffected()
if err != nil {
return 0, errors.WithMessage(err, "rows affected")
}
return int(deleted), nil
}
func (r Backend) GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByConfigServiceNodeId")
query, args, err := squirrel.Select("*").
From(Table("backend")).
Where(squirrel.Eq{
"config_service_node_id": configServiceNodeId,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Backend, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Backend) All(ctx context.Context) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.All")
result := make([]entity.Backend, 0)
query := fmt.Sprintf("SELECT * FROM %s order by 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
}
func (r Backend) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Backend, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.GetByModuleId")
query, args, err := squirrel.Select("*").
From(Table("backend")).
Where(squirrel.Eq{
"module_id": moduleId,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Backend, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
+227
View File
@@ -0,0 +1,227 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
"isp-config-service/domain"
"isp-config-service/entity"
"isp-config-service/entity/xtypes"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type Config struct {
db db.DB
}
func NewConfig(db db.DB) Config {
return Config{
db: db,
}
}
func (r Config) Insert(ctx context.Context, cfg entity.Config) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.Insert")
query, args, err := squirrel.Insert(Table("config")).
Columns("id", "name", "module_id", "data", "version", "active", "admin_id").
Values(cfg.Id, cfg.Name, cfg.ModuleId, cfg.Data, cfg.Version, cfg.Active, cfg.AdminId).
Suffix("on conflict (id) do nothing").
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Config) GetActive(ctx context.Context, moduleId string) (*entity.Config, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetActive")
query, args, err := squirrel.Select("*").
From(Table("config")).
Where(squirrel.Eq{
"module_id": moduleId,
"active": xtypes.Bool(true),
}).OrderBy("version DESC").
Limit(1).
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
return selectRow[entity.Config](ctx, r.db, query, args...)
}
func (r Config) GetByModuleId(ctx context.Context, moduleId string) ([]entity.Config, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetByModuleId")
query, args, err := squirrel.Select("*").
From(Table("config")).
Where(squirrel.Eq{
"module_id": moduleId,
}).OrderBy("created_at desc").
ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
result := make([]entity.Config, 0)
err = r.db.Select(ctx, &result, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r Config) GetById(ctx context.Context, id string) (*entity.Config, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetById")
query, args, err := squirrel.Select("*").
From(Table("config")).
Where(squirrel.Eq{
"id": id,
}).ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
return selectRow[entity.Config](ctx, r.db, query, args...)
}
func (r Config) DeleteNonActiveById(ctx context.Context, id string) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.DeleteNonActiveById")
query, args, err := squirrel.Delete(Table("config")).
Where(squirrel.Eq{
"id": id,
"active": xtypes.Bool(false),
}).ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
func (r Config) UpdateByVersion(ctx context.Context, cfg entity.Config) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.UpdateByVersion")
query, args, err := squirrel.Update(Table("config")).
SetMap(map[string]any{
"name": cfg.Name,
"data": cfg.Data,
"version": squirrel.Expr("version + 1"),
"updated_at": squirrel.Expr("unixepoch()"),
"admin_id": cfg.AdminId,
}).Where(squirrel.Eq{
"id": cfg.Id,
"version": cfg.Version,
}).ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
func (r Config) SetActive(ctx context.Context, configId string, active xtypes.Bool) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.SetActive")
query, args, err := squirrel.Update(Table("config")).
Set("active", active).
Set("updated_at", squirrel.Expr("unixepoch()")).
Where(squirrel.Eq{
"id": configId,
}).ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r Config) GetMetaByVariables(ctx context.Context, variables []string) (map[string][]entity.ConfigMetaWithVariable, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.GetMetaByVariables")
query, args, err := squirrel.Select("c.id", "c.name", "c.module_id", "c.active", "l.variable_name").
From(Table("config c")).
Join(fmt.Sprintf("%s l on c.id = l.config_id", Table("config_has_variable"))).
Where(squirrel.Eq{
"l.variable_name": variables,
}).ToSql()
if err != nil {
return nil, errors.WithMessage(err, "build query")
}
list := make([]entity.ConfigMetaWithVariable, 0)
err = r.db.Select(ctx, &list, query, args...)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
result := make(map[string][]entity.ConfigMetaWithVariable)
for _, variable := range list {
result[variable.VariableName] = append(result[variable.VariableName], variable)
}
return result, nil
}
func (r Config) UpdateConfigName(ctx context.Context, req domain.UpdateConfigNameRequest) (bool, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "Config.UpdateConfigName")
query, args, err := squirrel.Update(Table("config")).
Set("name", req.NewConfigName).
Where(squirrel.Eq{
"id": req.Id,
}).
ToSql()
if err != nil {
return false, errors.WithMessage(err, "build query")
}
result, err := r.db.Exec(ctx, query, args...)
if err != nil {
return false, errors.WithMessagef(err, "exec: %s", query)
}
affected, err := result.RowsAffected()
if err != nil {
return false, errors.WithMessage(err, "get rows affected")
}
return affected > 0, nil
}
+83
View File
@@ -0,0 +1,83 @@
package repository
import (
"context"
"fmt"
"github.com/Masterminds/squirrel"
"github.com/pkg/errors"
"isp-config-service/entity"
"isp-config-service/middlewares/sql_metrics"
"isp-config-service/service/rqlite/db"
)
type ConfigHistory struct {
db db.DB
}
func NewConfigHistory(db db.DB) ConfigHistory {
return ConfigHistory{
db: db,
}
}
func (r ConfigHistory) GetByConfigId(ctx context.Context, configId string) ([]entity.ConfigHistory, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.GetByConfigId")
query := fmt.Sprintf(`select * from %s where config_id = ? order by version desc`, Table("config_history"))
result := make([]entity.ConfigHistory, 0)
err := r.db.Select(ctx, &result, query, configId)
if err != nil {
return nil, errors.WithMessagef(err, "select: %s", query)
}
return result, nil
}
func (r ConfigHistory) Delete(ctx context.Context, id string) error {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Delete")
query := fmt.Sprintf(`delete from %s where id = ?`, Table("config_history"))
_, err := r.db.Exec(ctx, query, id)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r ConfigHistory) 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").
Values(history.Id, history.ConfigId, history.Data, history.Version, history.AdminId).
ToSql()
if err != nil {
return errors.WithMessage(err, "build query")
}
_, err = r.db.Exec(ctx, query, args...)
if err != nil {
return errors.WithMessagef(err, "exec: %s", query)
}
return nil
}
func (r ConfigHistory) DeleteOld(ctx context.Context, configId string, keepVersions int) (int, error) {
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.DeleteOld")
query := fmt.Sprintf(`delete from %s where config_id = ? and id not in (
select id from %s where config_id = ? order by version desc limit ?
)`, Table("config_history"), Table("config_history"))
result, err := r.db.Exec(ctx, query, configId, configId, keepVersions)
if err != nil {
return 0, errors.WithMessagef(err, "exec: %s", query)
}
rowsAffected, err := result.RowsAffected()
if err != nil {
return 0, errors.WithMessage(err, "get rows affected")
}
return int(rowsAffected), nil
}
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff. Show more