Compare commits
113
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8d346a617 | ||
|
|
cdbd9d0e17 | ||
|
|
b1f09c630b | ||
|
|
13a47337a2 | ||
|
|
fcc57459ef | ||
|
|
c46003d882 | ||
|
|
2f09c32d88 | ||
|
|
0a223f3e94 | ||
|
|
aa3bed6ff8 | ||
|
|
447d719a16 | ||
|
|
e6bdec3f1e | ||
|
|
2d45f210db | ||
|
|
2aff6210b5 | ||
|
|
8d8369b4cc | ||
|
|
b1c16e4901 | ||
|
|
48cbb5c25d | ||
|
|
037c5f3fcd | ||
|
|
8c732a15e2 | ||
|
|
896dd36025 | ||
|
|
f0b8407479 | ||
|
|
c31c6aaf81 | ||
|
|
478b1ce5d7 | ||
|
|
453aa44148 | ||
|
|
9cd697a40d | ||
|
|
97d971fe14 | ||
|
|
68259fa369 | ||
|
|
1794041802 | ||
|
|
72e6bbe6d7 | ||
|
|
665641c88b | ||
|
|
b8d0c8e6d0 | ||
|
|
9a9e941580 | ||
|
|
675a917c0c | ||
|
|
7e10fb5217 | ||
|
|
6d67d3a331 | ||
|
|
e2d45ecdd2 | ||
|
|
61ca62db75 | ||
|
|
e0ab3236d4 | ||
|
|
910fb81a0e | ||
|
|
f1c597bde9 | ||
|
|
f25ded3015 | ||
|
|
3f8e03eda4 | ||
|
|
50a7e32b48 | ||
|
|
df31719324 | ||
|
|
cc5da31e59 | ||
|
|
2d936e543c | ||
|
|
91a14f9f23 | ||
|
|
08c4fb9bee | ||
|
|
dbaa347162 | ||
|
|
78f1fe43b9 | ||
|
|
ab95347767 | ||
|
|
7dd989bac2 | ||
|
|
b9dc101141 | ||
|
|
b3452ef5f6 | ||
|
|
41357efef0 | ||
|
|
b0cac278d2 | ||
|
|
75abb294c0 | ||
|
|
3d02fa550d | ||
|
|
8a9accbdeb | ||
|
|
88bff98d25 | ||
|
|
bdb0c50a22 | ||
|
|
0cf2b61ce3 | ||
|
|
6ec99e8d1f | ||
|
|
a6c1fcb972 | ||
|
|
ed91071557 | ||
|
|
6e1770273e | ||
|
|
5a462ef158 | ||
|
|
a3415470f7 | ||
|
|
909a26eace | ||
|
|
1ffe9e4a62 | ||
|
|
909ff91b2b | ||
|
|
4c7e96813c | ||
|
|
244d8fbdc2 | ||
|
|
745a4ae1e2 | ||
|
|
38806190e7 | ||
|
|
3e593f759d | ||
|
|
0672da8e9c | ||
|
|
bc53089fce | ||
|
|
7a22e3558e | ||
|
|
3c801a4c09 | ||
|
|
b4541f6c1b | ||
|
|
7acc4ebbd6 | ||
|
|
1665cc78cf | ||
|
|
8dcb8eef68 | ||
|
|
37c08f4500 | ||
|
|
8af97e56d7 | ||
|
|
f9138cbbfe | ||
|
|
4d81fe7a26 | ||
|
|
3d2cee1ae8 | ||
|
|
9eb5a3030b | ||
|
|
bad913e339 | ||
|
|
0e3c14d099 | ||
|
|
23ede62f24 | ||
|
|
fc80638b76 | ||
|
|
8f57203d96 | ||
|
|
422bdb9831 | ||
|
|
8c68ffea8c | ||
|
|
f802b2000d | ||
|
|
1a46b678ef | ||
|
|
3d97f3789a | ||
|
|
2a81e83b2e | ||
|
|
1a8ed4e8ea | ||
|
|
e3c3b86b04 | ||
|
|
a9e03750ab | ||
|
|
0edf80ffed | ||
|
|
5b115440f1 | ||
|
|
4fdf7c0ca2 | ||
|
|
f3934e038e | ||
|
|
3461f20510 | ||
|
|
b6baa9e5e7 | ||
|
|
3a4931ca8c | ||
|
|
70f5ebeb4b | ||
|
|
b29f3c6dcd | ||
|
|
fe6f1f5e5a |
No files matched your search
@@ -1,60 +0,0 @@
|
|||||||
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
|
|
||||||
+1
-3
@@ -71,6 +71,4 @@ fabric.properties
|
|||||||
/vendor/
|
/vendor/
|
||||||
google/
|
google/
|
||||||
package.json
|
package.json
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
|
||||||
conf/config_dev.yml
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
include:
|
|
||||||
- project: '$CI_PROJECT_PATH'
|
|
||||||
file: '/ci-isp-go-service.yml'
|
|
||||||
+36
-77
@@ -1,79 +1,38 @@
|
|||||||
version: "2"
|
|
||||||
run:
|
|
||||||
allow-parallel-runners: true
|
|
||||||
linters:
|
linters:
|
||||||
default: all
|
enable-all: true
|
||||||
disable:
|
disable:
|
||||||
- contextcheck # не имеет смысла
|
- goimports
|
||||||
- depguard # не всегда имеет смысл
|
- depguard # не используется
|
||||||
- dupword # не имеет смысла
|
- gochecknoinits
|
||||||
- exhaustruct # не имеет смысла
|
- gochecknoglobals
|
||||||
- godot # не актуально для swagger
|
- wsl
|
||||||
- godox # не позволяет оставлять todo
|
- gocognit
|
||||||
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
|
- godox # находит тудушки, не нужно
|
||||||
- nlreturn # не всегда имеет смысл
|
- golint # подумать, может вернуть
|
||||||
- nolintlint # Goland все равно форматирует с отступом
|
- stylecheck # подумать, может вернуть
|
||||||
- perfsprint # мнимая производительность в угоду читаемости
|
- goerr113
|
||||||
- tagalign # не всегда имеет смысл
|
|
||||||
- testpackage
|
linters-settings:
|
||||||
- varnamelen # очень индивидуально (db)
|
maligned:
|
||||||
- wsl # расставление пробелов очень индивидуально
|
suggest-new: true
|
||||||
settings:
|
lll:
|
||||||
cyclop:
|
line-length: 140
|
||||||
max-complexity: 15 # по умолчанию 10 мало
|
tab-width: 1
|
||||||
funlen:
|
funlen:
|
||||||
lines: 80
|
lines: 80
|
||||||
lll:
|
statements: 40
|
||||||
line-length: 150
|
prealloc:
|
||||||
revive:
|
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||||
rules:
|
# True by default.
|
||||||
- name: var-naming # отключаем Id -> ID
|
simple: true
|
||||||
disabled: true
|
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||||
staticcheck:
|
for-loops: true # Report preallocation suggestions on for loops, false by default
|
||||||
checks: # отключаем Id -> ID
|
gocritic:
|
||||||
- -ST1000
|
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
|
||||||
- -ST1016
|
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
|
||||||
- -ST1020
|
enabled-tags:
|
||||||
- -ST1021
|
- diagnostic
|
||||||
- -ST1022
|
- performance
|
||||||
testifylint:
|
settings:
|
||||||
disable:
|
hugeParam:
|
||||||
- compares
|
sizeThreshold: 90
|
||||||
- equal-values
|
|
||||||
exclusions:
|
|
||||||
generated: lax
|
|
||||||
presets:
|
|
||||||
- comments
|
|
||||||
- common-false-positives
|
|
||||||
- legacy
|
|
||||||
- std-error-handling
|
|
||||||
rules:
|
|
||||||
- linters:
|
|
||||||
- wrapcheck
|
|
||||||
path: controller # достаточное кол-во контекста на уровне контроллеров
|
|
||||||
- linters:
|
|
||||||
- wrapcheck
|
|
||||||
path: transaction # транзакции прозрачны
|
|
||||||
- linters:
|
|
||||||
- wrapcheck
|
|
||||||
path: middleware #отсутствует необходимость оборачивать ошибки
|
|
||||||
- linters:
|
|
||||||
- gochecknoglobals
|
|
||||||
- mnd
|
|
||||||
path: proxy
|
|
||||||
- linters:
|
|
||||||
- wrapcheck
|
|
||||||
path: httperrors #отсутствует необходимость оборачивать ошибки
|
|
||||||
paths:
|
|
||||||
- third_party$
|
|
||||||
- builtin$
|
|
||||||
- examples$
|
|
||||||
formatters:
|
|
||||||
enable:
|
|
||||||
- gofmt
|
|
||||||
exclusions:
|
|
||||||
generated: lax
|
|
||||||
paths:
|
|
||||||
- third_party$
|
|
||||||
- builtin$
|
|
||||||
- examples$
|
|
||||||
@@ -1,79 +1,3 @@
|
|||||||
### v5.2.7
|
|
||||||
* добавлен `Dockerfile` и скрипт для сборки и публикации образа в `GitHub Contaier Registry`
|
|
||||||
* обновлены зависимости
|
|
||||||
### v5.2.6
|
|
||||||
* исправлен баг с отсутствием проверки разрешенных действий
|
|
||||||
### v5.2.5
|
|
||||||
* добавлено новое поле `enableForceUnescapingUnicode` в конфигурации для очистки тела запроса от экранирования unicode символов при логирование
|
|
||||||
* реализована поддержка очистки тела запроса от экранирования unicode символов для корректного логирования
|
|
||||||
* обновлены зависимости
|
|
||||||
### v5.2.4
|
|
||||||
* обновлены зависимости
|
|
||||||
### v5.2.3
|
|
||||||
* добавлен заголовок `X-Request-Id` в ответ при проксировании grpc
|
|
||||||
* обновлены зависимости
|
|
||||||
* обновлена версия go до 1.24
|
|
||||||
### v5.2.1
|
|
||||||
* добавлен параметр для настройки проброса `requestId` из заголовка запроса
|
|
||||||
* добавлено логирование содержимого заголовка `requestId` из заголовка запроса (поле `clientRequestId`)
|
|
||||||
* обновлены зависимости
|
|
||||||
* обновлена версия go до 1.23
|
|
||||||
### v5.2.0
|
|
||||||
* изменён формат логов с `snake_case` на `camelCase`
|
|
||||||
### v5.1.1
|
|
||||||
* добавлен параметр `withPrefix` в локальном конфиге для `location`, чтобы не обрезать путь при проксировании запроса
|
|
||||||
### v5.1.0
|
|
||||||
* обновлены зависимости (увеличены лимиты по семплированию логов, добавлена возможность конфигурировать семплирование)
|
|
||||||
### v5.0.0
|
|
||||||
* добавлена авторизация ендпоинтов администратора
|
|
||||||
### v4.3.0
|
|
||||||
* обновлены зависимости
|
|
||||||
### v4.2.1
|
|
||||||
* исправлено поведение `skipBodyLoggingEndpointPrefixes`
|
|
||||||
### v4.2.0
|
|
||||||
* новый параметр в remote_config: `skipBodyLoggingEndpointPrefixes`. Массив re. Если они есть в пути, то запрос не будет логироваться
|
|
||||||
### v4.1.2
|
|
||||||
* исправлена опция логирования тела запроса (при настройке ws могла отключаться)
|
|
||||||
### v4.1.1
|
|
||||||
* исправлена маршрутизация запросов
|
|
||||||
### v4.1.0
|
|
||||||
* обновлены зависимости
|
|
||||||
* добавлена поддержка проксирования WebSocket `ws`
|
|
||||||
### v4.0.0
|
|
||||||
* реализована аутентификация токена администратора через msp-admin-service
|
|
||||||
### v3.0.3
|
|
||||||
* исправлено тело ответа grpc ошибок валидации
|
|
||||||
* обновлены зависимости
|
|
||||||
### v3.0.2
|
|
||||||
* добавлен charset=utf-8 в заголовок ответа для grpc
|
|
||||||
### v3.0.1
|
|
||||||
* исправлено проксирование http с GET параметрами
|
|
||||||
* исправлено логирование пути при проксировании HTTP
|
|
||||||
### v3.0.0
|
|
||||||
* реализация новой схемы аутентификации/авторизации
|
|
||||||
### v2.8.3
|
|
||||||
* use isp-kit logger instead local logger
|
|
||||||
* use log string instead log any (common log type)
|
|
||||||
* add replace grpc (isp-lib and isp-kit conflict)
|
|
||||||
### v2.8.2
|
|
||||||
* add file rotation
|
|
||||||
### v2.8.1
|
|
||||||
* add xml format support for new logger
|
|
||||||
### v2.8.0
|
|
||||||
* add new logger
|
|
||||||
* remove journal
|
|
||||||
* add identities to requests log
|
|
||||||
### v2.7.6
|
|
||||||
* updated dependencies
|
|
||||||
* migrated to common local config
|
|
||||||
### v2.7.5
|
|
||||||
* updated dependencies
|
|
||||||
### v2.7.4
|
|
||||||
* updated isp-lib
|
|
||||||
* updated isp-lib-test
|
|
||||||
### v2.7.3
|
|
||||||
* updated isp-lib
|
|
||||||
* updated isp-event-lib
|
|
||||||
## 2.7.2
|
## 2.7.2
|
||||||
* fix accounting
|
* fix accounting
|
||||||
## 2.7.1
|
## 2.7.1
|
||||||
|
|||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
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 --mount=type=cache,target=/go/pkg/mod/ \
|
|
||||||
--mount=type=bind,source=go.sum,target=go.sum \
|
|
||||||
--mount=type=bind,source=go.mod,target=go.mod \
|
|
||||||
go mod download -x
|
|
||||||
RUN --mount=type=cache,target=/go/pkg/mod/ \
|
|
||||||
--mount=type=bind,target=. \
|
|
||||||
go build -ldflags="-X 'main.version=$version_env'" -o /main .
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
ARG UID=10001
|
|
||||||
RUN adduser \
|
|
||||||
--disabled-password \
|
|
||||||
--gecos "" \
|
|
||||||
--home "/nonexistent" \
|
|
||||||
--shell "/sbin/nologin" \
|
|
||||||
--no-create-home \
|
|
||||||
--uid "${UID}" \
|
|
||||||
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
|
|
||||||
|
|
||||||
ENTRYPOINT /app/$app_name_env
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package accounting
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/accounting/state"
|
||||||
|
"isp-gate-service/service/matcher"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type accountant struct {
|
||||||
|
mx sync.Mutex
|
||||||
|
matcher matcher.Matcher
|
||||||
|
limitStates map[string]state.LimitState
|
||||||
|
version int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *accountant) Accept(method string) bool {
|
||||||
|
patternArray := app.matcher.Match(method)
|
||||||
|
stateStorage := make([]state.LimitState, len(patternArray))
|
||||||
|
for i, pattern := range patternArray {
|
||||||
|
stateStorage[i] = app.limitStates[pattern]
|
||||||
|
}
|
||||||
|
|
||||||
|
app.mx.Lock()
|
||||||
|
resp := state.Update(stateStorage)
|
||||||
|
if resp {
|
||||||
|
app.version++
|
||||||
|
}
|
||||||
|
app.mx.Unlock()
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *accountant) Snapshot() (map[string]state.Snapshot, int64) {
|
||||||
|
app.mx.Lock()
|
||||||
|
version := app.version
|
||||||
|
snapshotLimitState := make(map[string]state.Snapshot, len(app.limitStates))
|
||||||
|
for method, limitState := range app.limitStates {
|
||||||
|
snapshotLimitState[method] = limitState.Export()
|
||||||
|
}
|
||||||
|
app.mx.Unlock()
|
||||||
|
return snapshotLimitState, version
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
package accounting
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"isp-gate-service/accounting/state"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/model"
|
||||||
|
"isp-gate-service/service/matcher"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var worker = &accountingWorker{
|
||||||
|
accountingStorage: make(map[int32]Accounting),
|
||||||
|
requestsStoring: make(map[int32]bool),
|
||||||
|
}
|
||||||
|
|
||||||
|
type (
|
||||||
|
Accounting interface {
|
||||||
|
Accept(string) bool
|
||||||
|
Snapshot() (map[string]state.Snapshot, int64)
|
||||||
|
}
|
||||||
|
|
||||||
|
accountingWorker struct {
|
||||||
|
accountingStorage map[int32]Accounting
|
||||||
|
requestsStoring map[int32]bool
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewConnectionConsumer(list []structure.AddressConfiguration) bool {
|
||||||
|
accountingSetting := config.GetRemote().(*conf.RemoteConfig).AccountingSetting
|
||||||
|
worker.init(accountingSetting)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReceiveConfiguration(accountingSetting conf.Accounting) {
|
||||||
|
worker.init(accountingSetting)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AcceptRequest(appId int32, path string) bool {
|
||||||
|
if accouter, ok := worker.accountingStorage[appId]; ok {
|
||||||
|
ok := accouter.Accept(path)
|
||||||
|
if ok && worker.requestsStoring[appId] {
|
||||||
|
storage.TakeRequest(appId, path, time.Now())
|
||||||
|
}
|
||||||
|
return ok
|
||||||
|
} else {
|
||||||
|
if worker.requestsStoring[appId] {
|
||||||
|
storage.TakeRequest(appId, path, time.Now())
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Close() {
|
||||||
|
if snapshot != nil {
|
||||||
|
snapshot.Stop()
|
||||||
|
}
|
||||||
|
if storage != nil {
|
||||||
|
storage.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *accountingWorker) init(accountingSetting conf.Accounting) {
|
||||||
|
Close()
|
||||||
|
|
||||||
|
newAccountingStorage := make(map[int32]Accounting)
|
||||||
|
newRequestsStoringStorage := make(map[int32]bool)
|
||||||
|
|
||||||
|
if accountingSetting.Enable {
|
||||||
|
for _, s := range accountingSetting.Setting {
|
||||||
|
limitStates, patternArray := state.InitLimitState(s.Limits)
|
||||||
|
accounting := w.recoveryAccounting(s.ApplicationId, limitStates, patternArray)
|
||||||
|
|
||||||
|
newAccountingStorage[s.ApplicationId] = accounting
|
||||||
|
newRequestsStoringStorage[s.ApplicationId] = s.EnableStoring
|
||||||
|
}
|
||||||
|
w.requestsStoring = newRequestsStoringStorage
|
||||||
|
w.accountingStorage = newAccountingStorage
|
||||||
|
InitStoringTask(accountingSetting.Storing)
|
||||||
|
InitSnapshotTask(accountingSetting.SnapshotTimeout)
|
||||||
|
} else {
|
||||||
|
w.requestsStoring = newRequestsStoringStorage
|
||||||
|
w.accountingStorage = newAccountingStorage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *accountingWorker) takeSnapshot() []entity.Snapshot {
|
||||||
|
lastStorage := w.accountingStorage
|
||||||
|
|
||||||
|
response := make([]entity.Snapshot, 0, len(lastStorage))
|
||||||
|
for appId, account := range lastStorage {
|
||||||
|
limitState, version := account.Snapshot()
|
||||||
|
response = append(response, entity.Snapshot{
|
||||||
|
AppId: appId,
|
||||||
|
LimitState: limitState,
|
||||||
|
Version: version,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *accountingWorker) recoveryAccounting(appId int32, limitStates map[string]state.LimitState, patternArray []string) *accountant {
|
||||||
|
var (
|
||||||
|
version = int64(0)
|
||||||
|
importNotComplete = true
|
||||||
|
)
|
||||||
|
|
||||||
|
dbSnapshot, err := model.SnapshotRep.GetByApplication(appId)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(log_code.ErrorSnapshotAccounting, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if cache, ok := w.accountingStorage[appId]; ok {
|
||||||
|
cashLimitState, cashVersion := cache.Snapshot()
|
||||||
|
|
||||||
|
if dbSnapshot == nil || dbSnapshot.Version < cashVersion {
|
||||||
|
version = cashVersion
|
||||||
|
w.importLimitState(limitStates, cashLimitState)
|
||||||
|
importNotComplete = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if dbSnapshot != nil && importNotComplete {
|
||||||
|
version = dbSnapshot.Version
|
||||||
|
w.importLimitState(limitStates, dbSnapshot.LimitState)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &accountant{
|
||||||
|
mx: sync.Mutex{},
|
||||||
|
matcher: matcher.NewCacheableMatcher(patternArray),
|
||||||
|
limitStates: limitStates,
|
||||||
|
version: version,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *accountingWorker) importLimitState(limitStates map[string]state.LimitState, snapshot map[string]state.Snapshot) {
|
||||||
|
for method, limitState := range limitStates {
|
||||||
|
if oldState, ok := snapshot[method]; ok {
|
||||||
|
limitState.Import(oldState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
//nolint
|
||||||
|
package accounting
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
"isp-gate-service/model"
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
accountingSetting = conf.Accounting{
|
||||||
|
Enable: true,
|
||||||
|
SnapshotTimeout: "290ms",
|
||||||
|
Setting: []conf.AccountingSetting{
|
||||||
|
{ApplicationId: 1, Limits: []conf.LimitSetting{
|
||||||
|
{Pattern: "mdm-master/group/method", MaxCount: 1, Timeout: "90ms"},
|
||||||
|
{Pattern: "mdm-master/group3/method", MaxCount: 10, Timeout: "10s"},
|
||||||
|
{Pattern: "mdm-master/group3/*", MaxCount: 5, Timeout: "10s"},
|
||||||
|
{Pattern: "mdm-master/group4/method", MaxCount: 2, Timeout: "0s"},
|
||||||
|
{Pattern: "mdm-master/group5/method", MaxCount: 3, Timeout: "10s"},
|
||||||
|
{Pattern: "mdm-master/group6/method", MaxCount: 5, Timeout: "10s"},
|
||||||
|
}},
|
||||||
|
{ApplicationId: 2, Limits: []conf.LimitSetting{
|
||||||
|
{Pattern: "mdm-master/group/method", MaxCount: 0, Timeout: "10s"},
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
Storing: conf.StoringSetting{
|
||||||
|
Size: 100,
|
||||||
|
Timeout: "1h",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
reqExample = []struct {
|
||||||
|
appId int32
|
||||||
|
path []string
|
||||||
|
}{
|
||||||
|
0: {appId: 1, path: []string{
|
||||||
|
"mdm-master/group/method", "mdm-master/group/method", "mdm-master/group/method",
|
||||||
|
"mdm-master/group/method", "mdm-master/group/method", "mdm-master/group/method",
|
||||||
|
}},
|
||||||
|
|
||||||
|
1: {appId: 2, path: []string{
|
||||||
|
"mdm-master/group3/method", "mdm-master/group/method", "mdm-master/group3/method",
|
||||||
|
"mdm-master/group/method", "mdm-master/group3/method", "mdm-master/group/method",
|
||||||
|
}},
|
||||||
|
|
||||||
|
2: {appId: 1, path: []string{
|
||||||
|
"mdm-master/group3/method", "mdm-master/group3/method", "mdm-master/group3/method",
|
||||||
|
"mdm-master/group3/method", "mdm-master/group3/method", "mdm-master/group3/method",
|
||||||
|
}},
|
||||||
|
3: {appId: 1, path: []string{
|
||||||
|
"mdm-master/group4/method", "mdm-master/group4/method", "mdm-master/group4/method",
|
||||||
|
"mdm-master/group4/method", "mdm-master/group4/method", "mdm-master/group4/method",
|
||||||
|
}},
|
||||||
|
4: {appId: 1, path: []string{
|
||||||
|
"mdm-master/group5/method", "mdm-master/group5/method", "mdm-master/group5/method",
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestAccounting(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
snapshotRep := newSnapshotRepository(false)
|
||||||
|
model.SnapshotRep = snapshotRep
|
||||||
|
worker = &accountingWorker{
|
||||||
|
accountingStorage: make(map[int32]Accounting),
|
||||||
|
requestsStoring: make(map[int32]bool),
|
||||||
|
}
|
||||||
|
worker.init(accountingSetting)
|
||||||
|
|
||||||
|
req := reqExample[4]
|
||||||
|
for _, path := range req.path {
|
||||||
|
a.True(AcceptRequest(req.appId, path))
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := true
|
||||||
|
req = reqExample[0]
|
||||||
|
for _, path := range req.path {
|
||||||
|
a.Equal(expected, AcceptRequest(req.appId, path))
|
||||||
|
expected = !expected
|
||||||
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
//expected == true
|
||||||
|
req = reqExample[1]
|
||||||
|
for _, path := range req.path {
|
||||||
|
a.Equal(expected, AcceptRequest(req.appId, path))
|
||||||
|
expected = !expected
|
||||||
|
}
|
||||||
|
|
||||||
|
req = reqExample[2]
|
||||||
|
expectedArray := []bool{true, true, true, true, true, false}
|
||||||
|
for key, path := range req.path {
|
||||||
|
a.Equal(expectedArray[key], AcceptRequest(req.appId, path))
|
||||||
|
}
|
||||||
|
|
||||||
|
//expected == true
|
||||||
|
req = reqExample[3]
|
||||||
|
for _, path := range req.path {
|
||||||
|
a.Equal(expected, AcceptRequest(req.appId, path))
|
||||||
|
}
|
||||||
|
|
||||||
|
worker.init(accountingSetting)
|
||||||
|
|
||||||
|
req = reqExample[4]
|
||||||
|
for _, path := range req.path {
|
||||||
|
a.False(AcceptRequest(req.appId, path))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWorker_recoveryAccounting(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
snapshotRep := newSnapshotRepository(true)
|
||||||
|
model.SnapshotRep = snapshotRep
|
||||||
|
|
||||||
|
worker = &accountingWorker{
|
||||||
|
accountingStorage: make(map[int32]Accounting),
|
||||||
|
requestsStoring: make(map[int32]bool),
|
||||||
|
}
|
||||||
|
secondWorker := &accountingWorker{
|
||||||
|
accountingStorage: make(map[int32]Accounting),
|
||||||
|
requestsStoring: make(map[int32]bool),
|
||||||
|
}
|
||||||
|
|
||||||
|
worker.init(accountingSetting)
|
||||||
|
secondWorker.init(accountingSetting)
|
||||||
|
|
||||||
|
appId := int32(1)
|
||||||
|
request := "1_3_5"
|
||||||
|
for range request {
|
||||||
|
a.True(AcceptRequest(appId, "mdm-master/group6/method"))
|
||||||
|
}
|
||||||
|
a.False(AcceptRequest(appId, "mdm-master/group6/method"))
|
||||||
|
|
||||||
|
time.Sleep(time.Millisecond * 300)
|
||||||
|
a.True(snapshotRep.Wait())
|
||||||
|
snapshot, err := model.SnapshotRep.GetByApplication(appId)
|
||||||
|
a.NoError(err)
|
||||||
|
a.NotNil(snapshot)
|
||||||
|
a.Equal(len(request), int(snapshot.Version))
|
||||||
|
|
||||||
|
Close()
|
||||||
|
worker = secondWorker
|
||||||
|
worker.init(accountingSetting)
|
||||||
|
a.False(AcceptRequest(appId, "mdm-master/group6/method"))
|
||||||
|
}
|
||||||
|
|
||||||
|
type snapshotRepository struct {
|
||||||
|
enableWaitGroup bool
|
||||||
|
wg sync.WaitGroup
|
||||||
|
mx sync.Mutex
|
||||||
|
cache map[int32]entity.Snapshot
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSnapshotRepository(enableWaitGroup bool) *snapshotRepository {
|
||||||
|
return &snapshotRepository{
|
||||||
|
enableWaitGroup: enableWaitGroup,
|
||||||
|
wg: sync.WaitGroup{},
|
||||||
|
cache: make(map[int32]entity.Snapshot),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *snapshotRepository) Wait() bool {
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
r.wg.Wait()
|
||||||
|
close(done)
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return true
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *snapshotRepository) GetByApplication(appId int32) (*entity.Snapshot, error) {
|
||||||
|
r.mx.Lock()
|
||||||
|
defer r.mx.Unlock()
|
||||||
|
|
||||||
|
if snapshot, ok := r.cache[appId]; ok {
|
||||||
|
return &snapshot, nil
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *snapshotRepository) Update(list []entity.Snapshot) error {
|
||||||
|
r.mx.Lock()
|
||||||
|
defer r.mx.Unlock()
|
||||||
|
|
||||||
|
if r.enableWaitGroup {
|
||||||
|
r.wg.Add(1)
|
||||||
|
defer r.wg.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, s := range list {
|
||||||
|
r.cache[s.AppId] = s
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package accounting
|
||||||
|
|
||||||
|
import (
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/integration-system/isp-log/stdcodes"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/model"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var snapshot *snapshotTask
|
||||||
|
|
||||||
|
type snapshotTask struct {
|
||||||
|
mx sync.Mutex
|
||||||
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
process bool
|
||||||
|
timeout <-chan time.Time
|
||||||
|
close chan bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitSnapshotTask(snapshotTimeout string) {
|
||||||
|
timeout, err := time.ParseDuration(snapshotTimeout)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(stdcodes.ModuleInvalidRemoteConfig, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot = newSnapshotTask(timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *snapshotTask) Stop() {
|
||||||
|
t.mx.Lock()
|
||||||
|
if t.process {
|
||||||
|
snapshotList := worker.takeSnapshot()
|
||||||
|
if len(snapshotList) != 0 {
|
||||||
|
defer func() {
|
||||||
|
t.wg.Add(1)
|
||||||
|
t.unload(snapshotList)
|
||||||
|
t.wg.Wait()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
t.process = false
|
||||||
|
t.close <- true
|
||||||
|
}
|
||||||
|
t.mx.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *snapshotTask) run(timeout time.Duration) {
|
||||||
|
defer t.wg.Done()
|
||||||
|
t.timeout = time.After(timeout)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-t.close:
|
||||||
|
return
|
||||||
|
case <-t.timeout:
|
||||||
|
list := worker.takeSnapshot()
|
||||||
|
if len(list) > 0 {
|
||||||
|
t.wg.Add(1)
|
||||||
|
go t.unload(list)
|
||||||
|
}
|
||||||
|
t.timeout = time.After(timeout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *snapshotTask) unload(list []entity.Snapshot) {
|
||||||
|
if err := model.SnapshotRep.Update(list); err != nil {
|
||||||
|
log.Error(log_code.ErrorSnapshotAccounting, err)
|
||||||
|
}
|
||||||
|
t.wg.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func newSnapshotTask(timeout time.Duration) *snapshotTask {
|
||||||
|
task := &snapshotTask{
|
||||||
|
process: true,
|
||||||
|
timeout: make(chan time.Time),
|
||||||
|
close: make(chan bool),
|
||||||
|
}
|
||||||
|
task.wg.Add(1)
|
||||||
|
go task.run(timeout)
|
||||||
|
return task
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package state
|
||||||
|
|
||||||
|
import (
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/integration-system/isp-log/stdcodes"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
LimitState interface {
|
||||||
|
Import(Snapshot)
|
||||||
|
Export() Snapshot
|
||||||
|
check() (bool, int, time.Time)
|
||||||
|
update(int, time.Time)
|
||||||
|
}
|
||||||
|
|
||||||
|
Snapshot struct {
|
||||||
|
Timeout time.Duration
|
||||||
|
Datetime []time.Time
|
||||||
|
Pattern string
|
||||||
|
Pointer int
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRequest struct {
|
||||||
|
pointer int
|
||||||
|
requestTime time.Time
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitLimitState(limits []conf.LimitSetting) (map[string]LimitState, []string) {
|
||||||
|
limitStates := make(map[string]LimitState)
|
||||||
|
patternArray := make([]string, len(limits))
|
||||||
|
|
||||||
|
for i, limit := range limits {
|
||||||
|
timeout, err := time.ParseDuration(limit.Timeout)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(stdcodes.ModuleInvalidRemoteConfig, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if timeout == 0 && limit.MaxCount != 0 {
|
||||||
|
limit.MaxCount = 1
|
||||||
|
}
|
||||||
|
patternArray[i] = limit.Pattern
|
||||||
|
limitStates[limit.Pattern] = &limiter{
|
||||||
|
timeout: timeout,
|
||||||
|
datetime: make([]time.Time, limit.MaxCount),
|
||||||
|
pattern: limit.Pattern,
|
||||||
|
pointer: -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return limitStates, patternArray
|
||||||
|
}
|
||||||
|
|
||||||
|
func Update(states []LimitState) bool {
|
||||||
|
update := make([]updateRequest, len(states))
|
||||||
|
for i, st := range states {
|
||||||
|
if ok, point, requestTime := st.check(); ok {
|
||||||
|
update[i] = updateRequest{pointer: point, requestTime: requestTime}
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i, st := range states {
|
||||||
|
u := update[i]
|
||||||
|
st.update(u.pointer, u.requestTime)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package state
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type limiter struct {
|
||||||
|
timeout time.Duration
|
||||||
|
datetime []time.Time
|
||||||
|
pattern string
|
||||||
|
pointer int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lim *limiter) Export() Snapshot {
|
||||||
|
ls := *lim
|
||||||
|
return Snapshot{
|
||||||
|
Timeout: ls.timeout,
|
||||||
|
Datetime: ls.datetime,
|
||||||
|
Pattern: ls.pattern,
|
||||||
|
Pointer: ls.pointer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lim *limiter) Import(oldState Snapshot) {
|
||||||
|
oldLim := limiter{
|
||||||
|
timeout: oldState.Timeout,
|
||||||
|
datetime: oldState.Datetime,
|
||||||
|
pattern: oldState.Pattern,
|
||||||
|
pointer: oldState.Pointer,
|
||||||
|
}
|
||||||
|
|
||||||
|
lenOldDatetime := len(oldLim.datetime)
|
||||||
|
lenNewDatetime := len(lim.datetime)
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case lenOldDatetime == lenNewDatetime:
|
||||||
|
lim.datetime = oldLim.datetime
|
||||||
|
lim.pointer = oldLim.pointer
|
||||||
|
|
||||||
|
case lenOldDatetime < lenNewDatetime:
|
||||||
|
oldPointer := oldLim.pointer
|
||||||
|
for i := range lim.datetime {
|
||||||
|
oldLim.pointer++
|
||||||
|
if oldLim.pointer >= len(oldLim.datetime) {
|
||||||
|
oldLim.pointer = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
lim.datetime[i] = oldLim.datetime[oldLim.pointer]
|
||||||
|
|
||||||
|
if oldPointer == oldLim.pointer {
|
||||||
|
lim.pointer = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case lenOldDatetime > lenNewDatetime:
|
||||||
|
for i := range lim.datetime {
|
||||||
|
oldLim.pointer++
|
||||||
|
if oldLim.pointer >= len(oldLim.datetime) {
|
||||||
|
oldLim.pointer = 0
|
||||||
|
}
|
||||||
|
lim.datetime[i] = oldLim.datetime[oldLim.pointer]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lim *limiter) check() (bool, int, time.Time) {
|
||||||
|
if len(lim.datetime) == 0 {
|
||||||
|
return false, 0, time.Time{}
|
||||||
|
}
|
||||||
|
if lim.timeout == 0 {
|
||||||
|
return true, 0, time.Now()
|
||||||
|
}
|
||||||
|
|
||||||
|
pointer := lim.pointer + 1
|
||||||
|
if pointer >= len(lim.datetime) {
|
||||||
|
pointer = 0
|
||||||
|
}
|
||||||
|
date := lim.datetime[pointer]
|
||||||
|
requestTime := time.Now()
|
||||||
|
account := requestTime.Sub(date) > lim.timeout
|
||||||
|
|
||||||
|
return account, pointer, requestTime
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lim *limiter) update(point int, requestTime time.Time) {
|
||||||
|
lim.pointer = point
|
||||||
|
lim.datetime[point] = requestTime
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
//nolint
|
||||||
|
package state
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLimiter(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
newLimiter := func(count int) *limiter {
|
||||||
|
return &limiter{timeout: 5 * time.Second, pattern: "example", pointer: -1, datetime: make([]time.Time, count)}
|
||||||
|
}
|
||||||
|
|
||||||
|
store12 := newLimiter(12)
|
||||||
|
store10 := newLimiter(10)
|
||||||
|
store7 := newLimiter(7)
|
||||||
|
store5 := newLimiter(5)
|
||||||
|
|
||||||
|
for i := 0; i < 7; i++ {
|
||||||
|
expectedTrue, pointer, reqTime := store10.check()
|
||||||
|
a.True(expectedTrue)
|
||||||
|
store10.update(pointer, reqTime)
|
||||||
|
|
||||||
|
expectedTrue, pointer, reqTime = store7.check()
|
||||||
|
a.True(expectedTrue)
|
||||||
|
store7.update(pointer, reqTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedFalse, _, _ := store7.check()
|
||||||
|
a.False(expectedFalse)
|
||||||
|
|
||||||
|
store12.Import(store7.Export())
|
||||||
|
store5.Import(store10.Export())
|
||||||
|
|
||||||
|
a.Equal(store5.datetime[0], store10.datetime[store10.pointer+1])
|
||||||
|
a.Equal(store12.datetime[0], store7.datetime[0])
|
||||||
|
a.Equal(store12.datetime[store7.pointer], store7.datetime[store7.pointer])
|
||||||
|
a.Equal(store12.datetime[store7.pointer+1], time.Time{})
|
||||||
|
|
||||||
|
expectedTrue, _, _ := store12.check()
|
||||||
|
a.True(expectedTrue)
|
||||||
|
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
expectedTrue, pointer, reqTime := store5.check()
|
||||||
|
a.True(expectedTrue)
|
||||||
|
store5.update(pointer, reqTime)
|
||||||
|
}
|
||||||
|
expectedFalse, _, _ = store5.check()
|
||||||
|
a.False(expectedFalse)
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package accounting
|
||||||
|
|
||||||
|
import (
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/integration-system/isp-log/stdcodes"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/model"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var storage *storingTask
|
||||||
|
|
||||||
|
type storingTask struct {
|
||||||
|
buffer []entity.Request
|
||||||
|
counter int
|
||||||
|
|
||||||
|
chanTimeout <-chan time.Time
|
||||||
|
chanCounter chan []entity.Request
|
||||||
|
chanClose chan bool
|
||||||
|
|
||||||
|
mx sync.Mutex
|
||||||
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
process bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitStoringTask(setting conf.StoringSetting) {
|
||||||
|
timeout, err := time.ParseDuration(setting.Timeout)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(stdcodes.ModuleInvalidRemoteConfig, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
storage = newStoringTask(timeout, setting.Size)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *storingTask) TakeRequest(appId int32, method string, date time.Time) {
|
||||||
|
t.mx.Lock()
|
||||||
|
if !t.process {
|
||||||
|
t.mx.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t.buffer[t.counter] = entity.Request{
|
||||||
|
AppId: appId,
|
||||||
|
Method: method,
|
||||||
|
CreatedAt: date,
|
||||||
|
}
|
||||||
|
|
||||||
|
t.counter++
|
||||||
|
if t.counter == len(t.buffer) {
|
||||||
|
t.chanCounter <- t.buffer
|
||||||
|
t.clearBuffer()
|
||||||
|
}
|
||||||
|
|
||||||
|
t.mx.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *storingTask) Stop() {
|
||||||
|
t.mx.Lock()
|
||||||
|
if t.process {
|
||||||
|
if t.counter != 0 {
|
||||||
|
buffer := t.clearBuffer()
|
||||||
|
defer func() {
|
||||||
|
t.wg.Add(1)
|
||||||
|
t.unload(buffer)
|
||||||
|
t.wg.Wait()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
t.chanClose <- true
|
||||||
|
t.process = false
|
||||||
|
}
|
||||||
|
t.mx.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *storingTask) run(timeout time.Duration) {
|
||||||
|
defer t.wg.Done()
|
||||||
|
t.chanTimeout = time.After(timeout)
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-t.chanClose:
|
||||||
|
return
|
||||||
|
case cache := <-t.chanCounter:
|
||||||
|
t.wg.Add(1)
|
||||||
|
go t.unload(cache)
|
||||||
|
t.chanTimeout = time.After(timeout)
|
||||||
|
case <-t.chanTimeout:
|
||||||
|
t.mx.Lock()
|
||||||
|
if t.counter != 0 {
|
||||||
|
buffer := t.clearBuffer()
|
||||||
|
t.wg.Add(1)
|
||||||
|
go t.unload(buffer)
|
||||||
|
}
|
||||||
|
t.mx.Unlock()
|
||||||
|
t.chanTimeout = time.After(timeout)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *storingTask) unload(cache []entity.Request) {
|
||||||
|
if err := model.RequestsRep.Insert(cache); err != nil {
|
||||||
|
log.Error(log_code.ErrorUnloadAccounting, err)
|
||||||
|
}
|
||||||
|
t.wg.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *storingTask) clearBuffer() []entity.Request {
|
||||||
|
oldBuffer := t.buffer[:t.counter]
|
||||||
|
oldLen := len(t.buffer)
|
||||||
|
t.counter = 0
|
||||||
|
t.buffer = make([]entity.Request, oldLen)
|
||||||
|
return oldBuffer
|
||||||
|
}
|
||||||
|
|
||||||
|
func newStoringTask(timeout time.Duration, bufSize int) *storingTask {
|
||||||
|
task := &storingTask{
|
||||||
|
mx: sync.Mutex{},
|
||||||
|
counter: 0,
|
||||||
|
buffer: make([]entity.Request, bufSize),
|
||||||
|
process: true,
|
||||||
|
chanTimeout: make(chan time.Time),
|
||||||
|
chanCounter: make(chan []entity.Request),
|
||||||
|
chanClose: make(chan bool),
|
||||||
|
}
|
||||||
|
task.wg.Add(1)
|
||||||
|
go task.run(timeout)
|
||||||
|
|
||||||
|
return task
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
//nolint
|
||||||
|
package accounting
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
"isp-gate-service/model"
|
||||||
|
"sync"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
timeoutSetting = conf.StoringSetting{
|
||||||
|
Size: 3,
|
||||||
|
Timeout: "30ms",
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferSetting = conf.StoringSetting{
|
||||||
|
Size: 3,
|
||||||
|
Timeout: "2s",
|
||||||
|
}
|
||||||
|
|
||||||
|
unloadSetting = conf.StoringSetting{
|
||||||
|
Size: 3,
|
||||||
|
Timeout: "100ms",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func initStoring(setting conf.StoringSetting) *requestsRepository {
|
||||||
|
repository := &requestsRepository{cache: make([]entity.Request, 0), wg: &sync.WaitGroup{}}
|
||||||
|
model.RequestsRep = repository
|
||||||
|
InitStoringTask(setting)
|
||||||
|
return repository
|
||||||
|
}
|
||||||
|
|
||||||
|
func wait(wg *sync.WaitGroup) bool {
|
||||||
|
done := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
wg.Wait()
|
||||||
|
close(done)
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return true
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStoringTask_Stop(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
rep := initStoring(bufferSetting)
|
||||||
|
|
||||||
|
rep.wg.Add(2)
|
||||||
|
for i, j := range []string{"Stop_1", "Stop_2", "Stop_3", "Stop_4", "Stop_5"} {
|
||||||
|
storage.TakeRequest(int32(i), j, time.Now())
|
||||||
|
}
|
||||||
|
storage.Stop()
|
||||||
|
a.Len(rep.cache, 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStoringTask_Buffer(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
rep := initStoring(bufferSetting)
|
||||||
|
|
||||||
|
rep.wg.Add(1)
|
||||||
|
for i, j := range []string{"Buffer_1", "Buffer_2", "Buffer_3", "Buffer_4", "Buffer_5"} {
|
||||||
|
storage.TakeRequest(int32(i), j, time.Now())
|
||||||
|
}
|
||||||
|
a.True(wait(rep.wg))
|
||||||
|
a.Len(rep.cache, 3)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStoringTask_Timeout(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
rep := initStoring(timeoutSetting)
|
||||||
|
|
||||||
|
rep.wg.Add(1)
|
||||||
|
for i, j := range []string{"Timeout_1", "Timeout_2"} {
|
||||||
|
storage.TakeRequest(int32(i), j, time.Now())
|
||||||
|
}
|
||||||
|
a.True(wait(rep.wg))
|
||||||
|
a.Len(rep.cache, 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStoringTask_Unload(t *testing.T) {
|
||||||
|
a := assert.New(t)
|
||||||
|
rep := initStoring(unloadSetting)
|
||||||
|
|
||||||
|
rep.wg.Add(2)
|
||||||
|
for i, j := range []string{"Unload_1", "Unload_2", "Unload_3", "Unload_4", "Unload_5"} {
|
||||||
|
storage.TakeRequest(int32(i), j, time.Now())
|
||||||
|
}
|
||||||
|
a.True(wait(rep.wg))
|
||||||
|
a.Len(rep.cache, 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
type requestsRepository struct {
|
||||||
|
cache []entity.Request
|
||||||
|
mx sync.Mutex
|
||||||
|
wg *sync.WaitGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *requestsRepository) Insert(model []entity.Request) error {
|
||||||
|
r.mx.Lock()
|
||||||
|
r.cache = append(r.cache, model...)
|
||||||
|
r.mx.Unlock()
|
||||||
|
r.wg.Done()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
package assembly
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"isp-gate-service/conf"
|
|
||||||
"isp-gate-service/routes"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/app"
|
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
|
||||||
"github.com/txix-open/isp-kit/http"
|
|
||||||
"github.com/txix-open/isp-kit/lb"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Assembly struct {
|
|
||||||
boot *bootstrap.Bootstrap
|
|
||||||
server *http.Server
|
|
||||||
logger *log.Adapter
|
|
||||||
routes *routes.Routes
|
|
||||||
redisCli redis.UniversalClient
|
|
||||||
systemCli *client.Client
|
|
||||||
adminCli *client.Client
|
|
||||||
|
|
||||||
locations []conf.Location
|
|
||||||
grpcClientByModuleName map[string]*client.Client
|
|
||||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
|
||||||
server := http.NewServer(boot.App.Logger())
|
|
||||||
|
|
||||||
localConfig := conf.Local{}
|
|
||||||
err := boot.App.Config().Read(&localConfig)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "read local config")
|
|
||||||
}
|
|
||||||
|
|
||||||
grpcClientByModuleName := make(map[string]*client.Client)
|
|
||||||
httpHostManagerByModuleName := make(map[string]*lb.RoundRobin)
|
|
||||||
for _, location := range localConfig.Locations {
|
|
||||||
switch location.Protocol {
|
|
||||||
case conf.GrpcProtocol:
|
|
||||||
cli, err := client.Default()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "new grpc client")
|
|
||||||
}
|
|
||||||
grpcClientByModuleName[location.TargetModule] = cli
|
|
||||||
case conf.HttpProtocol, conf.WsProtocol:
|
|
||||||
rb := lb.NewRoundRobin(nil)
|
|
||||||
httpHostManagerByModuleName[location.TargetModule] = rb
|
|
||||||
default:
|
|
||||||
return nil, errors.Errorf("unexpected location protocol: %s", location.Protocol)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
systemCli, err := client.Default()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "create system cli")
|
|
||||||
}
|
|
||||||
|
|
||||||
adminCli, err := client.Default()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "create admin cli")
|
|
||||||
}
|
|
||||||
|
|
||||||
return &Assembly{
|
|
||||||
boot: boot,
|
|
||||||
server: server,
|
|
||||||
logger: boot.App.Logger(),
|
|
||||||
routes: routes.NewRoutes(),
|
|
||||||
locations: localConfig.Locations,
|
|
||||||
grpcClientByModuleName: grpcClientByModuleName,
|
|
||||||
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
|
||||||
systemCli: systemCli,
|
|
||||||
adminCli: adminCli,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error {
|
|
||||||
var (
|
|
||||||
newCfg conf.Remote
|
|
||||||
prevCfg conf.Remote
|
|
||||||
)
|
|
||||||
err := a.boot.RemoteConfig.Upgrade(remoteConfig, &newCfg, &prevCfg)
|
|
||||||
if err != nil {
|
|
||||||
a.logger.Fatal(ctx, errors.WithMessage(err, "upgrade remote config"))
|
|
||||||
}
|
|
||||||
err = newCfg.Validate()
|
|
||||||
if err != nil {
|
|
||||||
a.logger.Fatal(ctx, errors.WithMessage(err, "invalid remote config"))
|
|
||||||
}
|
|
||||||
|
|
||||||
a.logger.SetLevel(newCfg.Logging.LogLevel)
|
|
||||||
|
|
||||||
var newRedisCli redis.UniversalClient
|
|
||||||
if newCfg.Redis != nil {
|
|
||||||
newRedisCli = a.redisClient(*newCfg.Redis)
|
|
||||||
}
|
|
||||||
|
|
||||||
locator := NewLocator(a.logger, a.grpcClientByModuleName, a.httpHostManagerByModuleName, a.routes, a.systemCli, a.adminCli)
|
|
||||||
|
|
||||||
handler, err := locator.Handler(newCfg, a.locations, newRedisCli)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "locator handler")
|
|
||||||
}
|
|
||||||
|
|
||||||
a.server.Upgrade(handler)
|
|
||||||
|
|
||||||
if a.redisCli != nil {
|
|
||||||
_ = a.redisCli.Close()
|
|
||||||
a.redisCli = newRedisCli
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Assembly) Runners() []app.Runner {
|
|
||||||
eventHandler := cluster.NewEventHandler().
|
|
||||||
RoutesReceiver(a.routes).
|
|
||||||
RemoteConfigReceiver(a)
|
|
||||||
|
|
||||||
for moduleName, upgrader := range a.grpcClientByModuleName {
|
|
||||||
eventHandler.RequireModule(moduleName, upgrader)
|
|
||||||
}
|
|
||||||
for moduleName, upgrader := range a.httpHostManagerByModuleName {
|
|
||||||
eventHandler.RequireModule(moduleName, upgrader)
|
|
||||||
}
|
|
||||||
|
|
||||||
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
|
||||||
eventHandler.RequireModule("msp-admin-service", a.adminCli)
|
|
||||||
|
|
||||||
return []app.Runner{
|
|
||||||
app.RunnerFunc(func(ctx context.Context) error {
|
|
||||||
return a.server.ListenAndServe(a.boot.BindingAddress)
|
|
||||||
}),
|
|
||||||
app.RunnerFunc(func(ctx context.Context) error {
|
|
||||||
return a.boot.ClusterCli.Run(ctx, eventHandler)
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Assembly) Closers() []app.Closer {
|
|
||||||
closers := []app.Closer{
|
|
||||||
a.boot.ClusterCli,
|
|
||||||
app.CloserFunc(func() error {
|
|
||||||
return a.server.Shutdown(context.Background())
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
for _, cliCloser := range a.grpcClientByModuleName {
|
|
||||||
closers = append(closers, cliCloser)
|
|
||||||
}
|
|
||||||
closers = append(closers, a.systemCli, a.adminCli, app.CloserFunc(func() error {
|
|
||||||
if a.redisCli != nil {
|
|
||||||
return a.redisCli.Close()
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}))
|
|
||||||
|
|
||||||
return closers
|
|
||||||
}
|
|
||||||
|
|
||||||
// nolint:ireturn
|
|
||||||
func (a *Assembly) redisClient(config conf.Redis) redis.UniversalClient {
|
|
||||||
if config.Sentinel != nil {
|
|
||||||
return redis.NewFailoverClient(&redis.FailoverOptions{
|
|
||||||
MasterName: config.Sentinel.MasterName,
|
|
||||||
SentinelAddrs: config.Sentinel.Addresses,
|
|
||||||
SentinelUsername: config.Sentinel.Username,
|
|
||||||
SentinelPassword: config.Sentinel.Password,
|
|
||||||
Username: config.Username,
|
|
||||||
Password: config.Password,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return redis.NewClient(&redis.Options{
|
|
||||||
Addr: config.Address,
|
|
||||||
Username: config.Username,
|
|
||||||
Password: config.Password,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
package assembly
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"isp-gate-service/conf"
|
|
||||||
"isp-gate-service/middleware"
|
|
||||||
"isp-gate-service/proxy"
|
|
||||||
"isp-gate-service/repository"
|
|
||||||
"isp-gate-service/routes"
|
|
||||||
"isp-gate-service/service"
|
|
||||||
|
|
||||||
mux2 "github.com/gorilla/mux"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
|
||||||
"github.com/txix-open/isp-kit/lb"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Locator struct {
|
|
||||||
logger log.Logger
|
|
||||||
grpcClientByModuleName map[string]*client.Client
|
|
||||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
|
||||||
routes *routes.Routes
|
|
||||||
systemCli *client.Client
|
|
||||||
adminCli *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewLocator(
|
|
||||||
logger log.Logger,
|
|
||||||
grpcClientByModuleName map[string]*client.Client,
|
|
||||||
httpHostManagerByModuleName map[string]*lb.RoundRobin,
|
|
||||||
routes *routes.Routes,
|
|
||||||
systemCli *client.Client,
|
|
||||||
adminCli *client.Client,
|
|
||||||
) Locator {
|
|
||||||
return Locator{
|
|
||||||
logger: logger,
|
|
||||||
grpcClientByModuleName: grpcClientByModuleName,
|
|
||||||
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
|
||||||
routes: routes,
|
|
||||||
systemCli: systemCli,
|
|
||||||
adminCli: adminCli,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli redis.UniversalClient) (http.Handler, error) { // nolint:funlen
|
|
||||||
systemRepo := repository.NewSystem(l.systemCli)
|
|
||||||
adminRepo := repository.NewAdmin(l.adminCli)
|
|
||||||
|
|
||||||
authenticationCache := repository.NewAuthenticationCache(time.Duration(config.Caching.AuthenticationDataInSec) * time.Second)
|
|
||||||
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
|
||||||
|
|
||||||
adminService := service.NewAdmin(
|
|
||||||
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
|
||||||
adminRepo,
|
|
||||||
)
|
|
||||||
|
|
||||||
authorization := service.NewAuthorization(
|
|
||||||
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
|
||||||
systemRepo,
|
|
||||||
)
|
|
||||||
|
|
||||||
dailyLimitRepo := repository.NewDailyLimit(redisCli)
|
|
||||||
dailyLimitService := service.NewDailyLimit(dailyLimitRepo, config.DailyLimits)
|
|
||||||
|
|
||||||
throttlingRepo := repository.NewThrottling(redisCli)
|
|
||||||
throttlingService := service.NewThrottling(throttlingRepo, config.Throttling)
|
|
||||||
|
|
||||||
mux := mux2.NewRouter()
|
|
||||||
for _, location := range locations {
|
|
||||||
var proxyFunc middleware.Handler
|
|
||||||
enableBodyLog := config.Logging.BodyLogEnable
|
|
||||||
|
|
||||||
switch location.Protocol {
|
|
||||||
case conf.GrpcProtocol:
|
|
||||||
cli := l.grpcClientByModuleName[location.TargetModule]
|
|
||||||
proxyFunc = proxy.NewGrpc(cli, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
|
||||||
case conf.HttpProtocol:
|
|
||||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
|
||||||
proxyFunc = proxy.NewHttp(hostManager, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
|
||||||
case conf.WsProtocol:
|
|
||||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
|
||||||
proxyFunc = proxy.NewWs(hostManager, location.SkipAuth)
|
|
||||||
enableBodyLog = false
|
|
||||||
default:
|
|
||||||
return nil, errors.Errorf("not supported protocol %s", location.Protocol)
|
|
||||||
}
|
|
||||||
|
|
||||||
handler := middleware.Chain(
|
|
||||||
proxyFunc,
|
|
||||||
middleware.RequestId(config.EnableClientRequestIdForwarding),
|
|
||||||
middleware.Logger(
|
|
||||||
l.logger, config.Logging.RequestLogEnable,
|
|
||||||
enableBodyLog,
|
|
||||||
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
|
||||||
config.Logging.EnableForceUnescapingUnicode,
|
|
||||||
),
|
|
||||||
middleware.ErrorHandler(l.logger),
|
|
||||||
middleware.Authenticate(authentication),
|
|
||||||
middleware.AdminAuthenticate(adminService),
|
|
||||||
middleware.Authorize(authorization, l.logger),
|
|
||||||
middleware.AdminAuthorize(l.routes, adminService),
|
|
||||||
middleware.Throttling(throttlingService),
|
|
||||||
middleware.DailyLimit(dailyLimitService),
|
|
||||||
)
|
|
||||||
if location.SkipAuth {
|
|
||||||
handler = middleware.Chain(
|
|
||||||
proxyFunc,
|
|
||||||
middleware.RequestId(config.EnableClientRequestIdForwarding),
|
|
||||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
|
|
||||||
enableBodyLog,
|
|
||||||
config.Logging.SkipBodyLoggingEndpointPrefixes,
|
|
||||||
config.Logging.EnableForceUnescapingUnicode,
|
|
||||||
),
|
|
||||||
middleware.ErrorHandler(l.logger),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
entrypoint := middleware.Entrypoint(
|
|
||||||
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd,gomnd
|
|
||||||
handler,
|
|
||||||
l.logger,
|
|
||||||
middleware.EntryPointConfig{
|
|
||||||
WithPrefix: location.WithPrefix,
|
|
||||||
PathPrefix: location.PathPrefix,
|
|
||||||
IsGrpcPath: location.Protocol == "grpc",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
|
|
||||||
}
|
|
||||||
|
|
||||||
return mux, nil
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
package authenticate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/utils"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/integration-system/isp-log/stdcodes"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/routing"
|
||||||
|
"isp-gate-service/service/veritification"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TODO move to isp-lib
|
||||||
|
AdminTokenHeader = "x-auth-admin" //nolint
|
||||||
|
|
||||||
|
awaitLengthVerifiableHeaders = 4
|
||||||
|
)
|
||||||
|
|
||||||
|
var notExpectedHeaders = []string{
|
||||||
|
utils.SystemIdHeader,
|
||||||
|
utils.DomainIdHeader,
|
||||||
|
utils.ServiceIdHeader,
|
||||||
|
utils.ApplicationIdHeader,
|
||||||
|
utils.UserIdHeader,
|
||||||
|
utils.DeviceIdHeader,
|
||||||
|
}
|
||||||
|
|
||||||
|
var auth = authenticate{}
|
||||||
|
|
||||||
|
type (
|
||||||
|
authenticate struct {
|
||||||
|
verify veritification.Verify
|
||||||
|
}
|
||||||
|
|
||||||
|
verifiable struct {
|
||||||
|
appId int32
|
||||||
|
ctx *fasthttp.RequestCtx
|
||||||
|
path string
|
||||||
|
headers map[string]string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func ReceiveConfiguration(conf conf.Cache) {
|
||||||
|
if conf.EnableCache {
|
||||||
|
if timeout, err := time.ParseDuration(conf.EvictTimeout); err != nil {
|
||||||
|
log.Fatalf(stdcodes.ModuleInvalidRemoteConfig, "invalid timeout '%s'", timeout)
|
||||||
|
} else {
|
||||||
|
auth.verify = veritification.NewCacheablesVerify(timeout)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auth.verify = veritification.NewRuntimeVerify()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Do(ctx *fasthttp.RequestCtx, path string) (int32, error) {
|
||||||
|
for _, notExpectedHeader := range notExpectedHeaders {
|
||||||
|
ctx.Request.Header.Del(notExpectedHeader)
|
||||||
|
}
|
||||||
|
|
||||||
|
verifiable := newVerifiable(ctx, path)
|
||||||
|
err := verifiable.verifyAppToken()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = verifiable.verifyUserToken()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
verifiable.setHeaders()
|
||||||
|
|
||||||
|
err = verifiable.checkInnerMethods()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = verifiable.checkUserMethods()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO backward capability for isp-config-service 1.x.x
|
||||||
|
uuid := config.Get().(*conf.Configuration).InstanceUuid
|
||||||
|
ctx.Request.Header.Set(utils.InstanceIdHeader, uuid)
|
||||||
|
|
||||||
|
return verifiable.appId, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newVerifiable(ctx *fasthttp.RequestCtx, path string) *verifiable {
|
||||||
|
return &verifiable{
|
||||||
|
ctx: ctx,
|
||||||
|
path: path,
|
||||||
|
appId: -1,
|
||||||
|
headers: make(map[string]string),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verifiable) verifyAppToken() error {
|
||||||
|
appToken := v.getParam(utils.ApplicationTokenHeader)
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if len(appToken) == 0 {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "application token required")
|
||||||
|
} else if config.GetRemote().(*conf.RemoteConfig).TokensSetting.ApplicationVerify {
|
||||||
|
if v.appId, err = verifyToken.Application(string(appToken)); err != nil || v.appId == 0 {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "received invalid application token")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
verifiableHeaders, err := auth.verify.ApplicationToken(string(appToken))
|
||||||
|
if err != nil {
|
||||||
|
log.Error(log_code.ErrorAuthenticate, err)
|
||||||
|
return createError("internal Server error", codes.Internal)
|
||||||
|
}
|
||||||
|
if len(verifiableHeaders) != awaitLengthVerifiableHeaders {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "received unexpected identities")
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationId, err := strconv.ParseInt(verifiableHeaders[utils.ApplicationIdHeader], 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(log_code.ErrorAuthenticate, errors.WithMessagef(err, "parse appId from redis"))
|
||||||
|
return createError("internal Server error", codes.Internal)
|
||||||
|
}
|
||||||
|
//nolint
|
||||||
|
if v.appId != -1 && int32(applicationId) != v.appId {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "received unexpected application identity")
|
||||||
|
}
|
||||||
|
|
||||||
|
v.appId = int32(applicationId)
|
||||||
|
v.headers = verifiableHeaders
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verifiable) verifyUserToken() error {
|
||||||
|
userToken := string(v.getParam(utils.UserTokenHeader))
|
||||||
|
if userToken != "" {
|
||||||
|
userId, err := verifyToken.User(userToken)
|
||||||
|
if err != nil {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "received invalid user token")
|
||||||
|
}
|
||||||
|
v.headers[utils.UserIdHeader] = userId
|
||||||
|
}
|
||||||
|
v.headers[utils.UserTokenHeader] = userToken
|
||||||
|
|
||||||
|
v.headers[utils.DeviceTokenHeader] = string(v.getParam(utils.DeviceTokenHeader))
|
||||||
|
|
||||||
|
var err error
|
||||||
|
v.headers, err = auth.verify.Identity(v.headers, v.path)
|
||||||
|
if err != nil {
|
||||||
|
switch err {
|
||||||
|
case veritification.ErrorInvalidUserId:
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, err.Error())
|
||||||
|
case veritification.ErrorPermittedToCallUser, veritification.ErrorPermittedToCallApplication:
|
||||||
|
return createError("forbidden", codes.PermissionDenied, err.Error())
|
||||||
|
default:
|
||||||
|
return createError("internal server error", codes.Internal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verifiable) setHeaders() {
|
||||||
|
for key, value := range v.headers {
|
||||||
|
if value != "" {
|
||||||
|
v.ctx.Request.Header.Set(key, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verifiable) checkInnerMethods() error {
|
||||||
|
_, ok := routing.InnerMethods[v.path]
|
||||||
|
if ok {
|
||||||
|
adminToken := string(v.getParam(AdminTokenHeader))
|
||||||
|
if adminToken == "" {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "admin token required")
|
||||||
|
}
|
||||||
|
if verifyToken.Admin(adminToken) != nil {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "received invalid admin token")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verifiable) checkUserMethods() error {
|
||||||
|
if v.headers[utils.UserIdHeader] == "" {
|
||||||
|
if _, ok := routing.AuthUserMethods[v.path]; ok {
|
||||||
|
return createError("unauthorized", codes.Unauthenticated, "user token required")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *verifiable) getParam(key string) []byte {
|
||||||
|
val := v.ctx.Request.Header.Peek(key)
|
||||||
|
if len(val) != 0 {
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
return v.ctx.Request.URI().QueryArgs().Peek(key)
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package authenticate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createError(msg string, status codes.Code, details ...interface{}) error {
|
||||||
|
return ErrorDescription{message: msg, grpcStatus: status, details: details}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ErrorDescription struct {
|
||||||
|
message string
|
||||||
|
grpcStatus codes.Code
|
||||||
|
details []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrorDescription) Error() string {
|
||||||
|
return fmt.Sprintf("code: %v, message: %s, details: %v", e.grpcStatus, e.message, e.details)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrorDescription) Message() string {
|
||||||
|
return e.message
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrorDescription) ConvertToGrpcStatus() codes.Code {
|
||||||
|
return e.grpcStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrorDescription) Details() []interface{} {
|
||||||
|
return e.details
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package authenticate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/dgrijalva/jwt-go"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errInvalidToken = errors.New("invalid token")
|
||||||
|
verifyToken token
|
||||||
|
)
|
||||||
|
|
||||||
|
type appClaims struct {
|
||||||
|
*jwt.StandardClaims
|
||||||
|
AppId int32
|
||||||
|
}
|
||||||
|
|
||||||
|
type userClaims struct {
|
||||||
|
*jwt.StandardClaims
|
||||||
|
UserId int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type token struct{}
|
||||||
|
|
||||||
|
func (t token) Admin(token string) error {
|
||||||
|
secret := config.GetRemote().(*conf.RemoteConfig).TokensSetting.AdminSecret
|
||||||
|
_, err := t.parse(token, secret, jwt.MapClaims{})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t token) Application(token string) (int32, error) {
|
||||||
|
secret := config.GetRemote().(*conf.RemoteConfig).TokensSetting.ApplicationSecret
|
||||||
|
|
||||||
|
parsed, err := t.parse(token, secret, &appClaims{StandardClaims: &jwt.StandardClaims{}})
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
claims, ok := parsed.Claims.(*appClaims)
|
||||||
|
if !ok {
|
||||||
|
return 0, errInvalidToken
|
||||||
|
}
|
||||||
|
return claims.AppId, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t token) User(token string) (string, error) {
|
||||||
|
secret := config.GetRemote().(*conf.RemoteConfig).TokensSetting.UserSecret
|
||||||
|
|
||||||
|
parsed, err := t.parse(token, secret, &userClaims{StandardClaims: &jwt.StandardClaims{}})
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
claims, ok := parsed.Claims.(*userClaims)
|
||||||
|
if !ok {
|
||||||
|
return "", errInvalidToken
|
||||||
|
}
|
||||||
|
|
||||||
|
return cast.ToString(claims.UserId), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (token) parse(token, secret string, claims jwt.Claims) (*jwt.Token, error) {
|
||||||
|
parsed, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) {
|
||||||
|
_, ok := token.Method.(*jwt.SigningMethodHMAC)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||||
|
}
|
||||||
|
return []byte(secret), nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !parsed.Valid {
|
||||||
|
return nil, errInvalidToken
|
||||||
|
}
|
||||||
|
return parsed, nil
|
||||||
|
}
|
||||||
Vendored
-53
@@ -1,53 +0,0 @@
|
|||||||
package cache
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Item struct {
|
|
||||||
data []byte
|
|
||||||
expiredAt time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
type Cache struct {
|
|
||||||
store map[string]Item
|
|
||||||
lock *sync.RWMutex
|
|
||||||
}
|
|
||||||
|
|
||||||
func New() *Cache {
|
|
||||||
return &Cache{
|
|
||||||
store: map[string]Item{},
|
|
||||||
lock: &sync.RWMutex{},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cache) Get(key string) ([]byte, bool) {
|
|
||||||
c.lock.RLock()
|
|
||||||
defer c.lock.RUnlock()
|
|
||||||
|
|
||||||
item, ok := c.store[key]
|
|
||||||
if !ok {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.now().After(item.expiredAt) {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
return item.data, true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cache) Set(key string, data []byte, lifeTime time.Duration) {
|
|
||||||
c.lock.Lock()
|
|
||||||
defer c.lock.Unlock()
|
|
||||||
|
|
||||||
c.store[key] = Item{
|
|
||||||
data: data,
|
|
||||||
expiredAt: c.now().Add(lifeTime),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cache) now() time.Time {
|
|
||||||
return time.Now()
|
|
||||||
}
|
|
||||||
Vendored
-50
@@ -1,50 +0,0 @@
|
|||||||
package cache_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
"isp-gate-service/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGetBasic(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
require := require.New(t)
|
|
||||||
|
|
||||||
cache := cache.New()
|
|
||||||
cache.Set("key", []byte("data"), 24*time.Hour)
|
|
||||||
|
|
||||||
data, ok := cache.Get("key")
|
|
||||||
require.True(ok)
|
|
||||||
require.EqualValues("data", data)
|
|
||||||
|
|
||||||
_, ok = cache.Get("key2")
|
|
||||||
require.False(ok)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetExpired(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
require := require.New(t)
|
|
||||||
|
|
||||||
cache := cache.New()
|
|
||||||
cache.Set("key", []byte("data"), 500*time.Millisecond)
|
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
|
|
||||||
data, ok := cache.Get("key")
|
|
||||||
require.False(ok)
|
|
||||||
require.Nil(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNilValue(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
require := require.New(t)
|
|
||||||
|
|
||||||
cache := cache.New()
|
|
||||||
cache.Set("key", nil, 24*time.Hour)
|
|
||||||
|
|
||||||
data, ok := cache.Get("key")
|
|
||||||
require.True(ok)
|
|
||||||
require.Nil(data)
|
|
||||||
}
|
|
||||||
+9
-15
@@ -1,24 +1,18 @@
|
|||||||
configServiceAddress:
|
configServiceAddress:
|
||||||
ip: 127.0.0.1
|
ip: 127.0.0.1
|
||||||
port: 9001
|
port: 9001
|
||||||
grpcOuterAddress:
|
httpOuterAddress:
|
||||||
#ip: 127.0.0.1
|
ip: 127.0.0.1
|
||||||
port: 9003
|
port: 9003
|
||||||
grpcInnerAddress:
|
httpInnerAddress:
|
||||||
ip: 0.0.0.0
|
ip: 0.0.0.0
|
||||||
port: 9003
|
port: 9003
|
||||||
moduleName: isp-gate-service
|
moduleName: isp-gate
|
||||||
|
instanceUuid: 9d89354b-c728-4b48-b002-a7d3b229f151
|
||||||
infraServerPort: 9553
|
|
||||||
|
|
||||||
logfile:
|
|
||||||
path: /var/log/isp-gate-service/runtime.log
|
|
||||||
maxSizeMb: 512
|
|
||||||
maxBackups: 4
|
|
||||||
compress: true
|
|
||||||
|
|
||||||
|
|
||||||
locations:
|
locations:
|
||||||
- pathPrefix: /api
|
- pathPrefix: /api
|
||||||
protocol: grpc
|
protocol: grpc
|
||||||
targetModule: router
|
targetModule: router
|
||||||
|
- pathPrefix: /mdm
|
||||||
|
protocol: http
|
||||||
|
targetModule: mdm-api
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
configServiceAddress:
|
|
||||||
ip: 127.0.0.1
|
|
||||||
port: 9001
|
|
||||||
grpcOuterAddress:
|
|
||||||
#ip: 127.0.0.1
|
|
||||||
port: 9003
|
|
||||||
grpcInnerAddress:
|
|
||||||
ip: 0.0.0.0
|
|
||||||
port: 9003
|
|
||||||
moduleName: isp-gate-service
|
|
||||||
|
|
||||||
infraServerPort: 9553
|
|
||||||
|
|
||||||
logfile:
|
|
||||||
path: /var/log/isp-gate-service/runtime.log
|
|
||||||
maxSizeMb: 512
|
|
||||||
maxBackups: 4
|
|
||||||
compress: true
|
|
||||||
|
|
||||||
locations:
|
|
||||||
- pathPrefix: /ws/kkd-configuration-service
|
|
||||||
protocol: ws
|
|
||||||
targetModule: kkd-configuration-service
|
|
||||||
- pathPrefix: /api/kkd-configuration-service
|
|
||||||
protocol: http
|
|
||||||
targetModule: kkd-configuration-service
|
|
||||||
- withPrefix: false
|
|
||||||
pathPrefix: /api/kkd-storage-service/report/download
|
|
||||||
protocol: http
|
|
||||||
targetModule: kkd-storage-service
|
|
||||||
skipAuth: true
|
|
||||||
- pathPrefix: /api/kkd-storage-service
|
|
||||||
protocol: http
|
|
||||||
targetModule: kkd-storage-service
|
|
||||||
- pathPrefix: /api
|
|
||||||
protocol: grpc
|
|
||||||
skipAuth: false
|
|
||||||
targetModule: router
|
|
||||||
@@ -1,17 +1,65 @@
|
|||||||
{
|
{
|
||||||
"logging": {
|
"database": {
|
||||||
"logLevel": "debug",
|
"address": "{{ msp_pgsql_address }}",
|
||||||
"requestLogEnable": true,
|
"port": "{{ msp_pgsql_port }}",
|
||||||
"bodyLogEnable": false,
|
"schema": "gate_service",
|
||||||
"skipBodyLoggingEndpointPrefixes": [],
|
"database": "{{ msp_pgsql_name }}",
|
||||||
"enableForceUnescapingUnicode": false
|
"username": "{{ msp_pgsql_user }}",
|
||||||
},
|
"password": "{{ msp_pgsql_password }}",
|
||||||
"caching": {
|
"createSchema": true
|
||||||
"authenticationDataInSec": 60,
|
},
|
||||||
"authorizationDataInSec": 60
|
"grpcSetting": {
|
||||||
},
|
"proxyGrpcErrorDetails": true,
|
||||||
"http": {
|
"enableOriginalProtoErrors": false
|
||||||
"maxRequestBodySizeInMb": 64,
|
},
|
||||||
"proxyTimeoutInSec": 60
|
"httpSetting": {
|
||||||
|
"maxRequestBodySizeBytes": 0
|
||||||
|
},
|
||||||
|
"accountingSetting": {
|
||||||
|
"enable": false,
|
||||||
|
"snapshotTimeout": "15m",
|
||||||
|
"setting": [
|
||||||
|
],
|
||||||
|
"storing": {
|
||||||
|
"size": 10000,
|
||||||
|
"timeout": "10m"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"journalSetting": {
|
||||||
|
"journal": {
|
||||||
|
"filename": "/var/log/isp-gate-service/runtime.log",
|
||||||
|
"maxSizeMb": 512,
|
||||||
|
"bufferSize": 4096,
|
||||||
|
"rotateTimeoutMs": 86400000,
|
||||||
|
"enableRemoteTransfer": true,
|
||||||
|
"enable": false,
|
||||||
|
"compress": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"redis": {
|
||||||
|
"password": "{{ msp_redis_password }}",
|
||||||
|
"defaultDB": 0,
|
||||||
|
"address": {
|
||||||
|
"ip": "{{ msp_redis_address }}",
|
||||||
|
"port": "{{ msp_redis_port }}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"metrics": {
|
||||||
|
"gc": true,
|
||||||
|
"memory": true,
|
||||||
|
"address": {
|
||||||
|
"path": "/metrics",
|
||||||
|
"port": "9553",
|
||||||
|
"ip": "0.0.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tokensSetting": {
|
||||||
|
"applicationSecret": "{{ msp_app_secret }}",
|
||||||
|
"applicationVerify": false,
|
||||||
|
"adminSecret": "{{ msp_admin_secret }}"
|
||||||
|
},
|
||||||
|
"authCacheSetting": {
|
||||||
|
"enableCache": false,
|
||||||
|
"evictTimeout": "1m"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package conf
|
|
||||||
|
|
||||||
const (
|
|
||||||
HttpProtocol = "http"
|
|
||||||
GrpcProtocol = "grpc"
|
|
||||||
WsProtocol = "ws"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Local struct {
|
|
||||||
Locations []Location
|
|
||||||
}
|
|
||||||
|
|
||||||
type Location struct {
|
|
||||||
WithPrefix bool
|
|
||||||
SkipAuth bool
|
|
||||||
PathPrefix string `validate:"required"`
|
|
||||||
Protocol string `validate:"required,oneof=http grpc ws"`
|
|
||||||
TargetModule string `validate:"required"`
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package conf
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Configuration struct {
|
||||||
|
InstanceUuid string `valid:"required~Required"`
|
||||||
|
ModuleName string `valid:"required~Required"`
|
||||||
|
ConfigServiceAddress structure.AddressConfiguration `valid:"required~Required"`
|
||||||
|
HttpOuterAddress structure.AddressConfiguration `valid:"required~Required" json:"httpOuterAddress"`
|
||||||
|
HttpInnerAddress structure.AddressConfiguration `valid:"required~Required" json:"httpInnerAddress"`
|
||||||
|
Locations []Location
|
||||||
|
}
|
||||||
|
|
||||||
|
Location struct {
|
||||||
|
SkipAuth bool
|
||||||
|
SkipExistCheck bool
|
||||||
|
PathPrefix string `valid:"required~Required"`
|
||||||
|
Protocol string `valid:"required~Required"`
|
||||||
|
TargetModule string `valid:"required~Required"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetLocationsByTargetModule(locations []Location) map[string][]Location {
|
||||||
|
requiredModules := make(map[string][]Location)
|
||||||
|
|
||||||
|
for _, location := range locations {
|
||||||
|
if location.TargetModule == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if loc, ok := requiredModules[location.TargetModule]; ok {
|
||||||
|
requiredModules[location.TargetModule] = append(loc, location)
|
||||||
|
} else {
|
||||||
|
requiredModules[location.TargetModule] = []Location{location}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return requiredModules
|
||||||
|
}
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
// nolint:gochecknoinits,lll
|
|
||||||
package conf
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"github.com/txix-open/isp-kit/rc/schema"
|
|
||||||
"github.com/txix-open/jsonschema"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
|
||||||
t.Type = "string"
|
|
||||||
t.Enum = []interface{}{"debug", "info", "warn", "error", "fatal"}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
type Remote struct {
|
|
||||||
Redis *Redis `schema:"Настройки Redis,обязательно, если используется механизм суточных ограничений или ограничений пропускной способности"`
|
|
||||||
Http Http `schema:"Настройки HTTP"`
|
|
||||||
Logging Logging `schema:"Настройки логирования"`
|
|
||||||
Caching Caching `schema:"Настройки кеширования"`
|
|
||||||
DailyLimits []DailyLimit `schema:"Настройки суточных ограничений,сбрасываются раз в сутки в 00:00"`
|
|
||||||
Throttling []Throttling `schema:"Настройки пропускной способности"`
|
|
||||||
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Http struct {
|
|
||||||
MaxRequestBodySizeInMb int64 `validate:"required" schema:"Максимальная длинна тела запроса,в мегабайтах"`
|
|
||||||
ProxyTimeoutInSec int `validate:"required" schema:"Таймаут на проксирование,в секундах"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Logging struct {
|
|
||||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
|
||||||
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
|
||||||
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
|
||||||
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
|
|
||||||
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Caching struct {
|
|
||||||
AuthenticationDataInSec int `validate:"required" schema:"Время кеширования данных аутентификации,в секундах"`
|
|
||||||
AuthorizationDataInSec int `validate:"required" schema:"Время кеширования данных авторизации,в секундах"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type DailyLimit struct {
|
|
||||||
ApplicationId int `validate:"required" schema:"ID приложения"`
|
|
||||||
RequestsPerDay int64 `validate:"required" schema:"Запросов в сутки"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Throttling struct {
|
|
||||||
ApplicationId int `validate:"required" schema:"ID приложения"`
|
|
||||||
RequestsPerSeconds int `validate:"required,min=1,max=1000" schema:"Запросов в секунду,не конфликтует с суточными ограничениями, алгоритм не работает на значениях больше 1000"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Redis struct {
|
|
||||||
Address string `schema:"Адрес,обязателено, если sentinel не указан"`
|
|
||||||
Username string `schema:"Имя пользовтаеля"`
|
|
||||||
Password string `schema:"Пароль"`
|
|
||||||
Sentinel *RedisSentinel `schema:"Настройки sentinel,обязательно, если address не указан"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type RedisSentinel struct {
|
|
||||||
Addresses []string `validate:"required" schema:"Адреса нод в кластере"`
|
|
||||||
MasterName string `validate:"required" schema:"Имя мастера"`
|
|
||||||
Username string `schema:"Имя пользовтаеля в sentinel"`
|
|
||||||
Password string `schema:"Пароль в sentinel"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Remote) Validate() error {
|
|
||||||
if (len(r.Throttling) > 0 || len(r.DailyLimits) > 0) && r.Redis == nil {
|
|
||||||
return errors.New("redis is required if dailyLimits or throttling were specified")
|
|
||||||
}
|
|
||||||
if r.Redis != nil && r.Redis.Sentinel == nil && r.Redis.Address == "" {
|
|
||||||
return errors.New("invalid redis config. sentinel or address are required")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
//nolint
|
||||||
|
package conf
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-journal/rx"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
KB = int64(1024)
|
||||||
|
MB = int64(1 << 20)
|
||||||
|
|
||||||
|
defaultSyncTimeout = 30 * time.Second
|
||||||
|
defaultStreamTimeout = 60 * time.Second
|
||||||
|
|
||||||
|
defaultBufferSize = 4 * KB
|
||||||
|
defaultMaxRequestBodySize = 512 * MB
|
||||||
|
DefaultMaxResponseBodySize = 32 * MB
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
RemoteConfig struct {
|
||||||
|
Database structure.DBConfiguration `schema:"Настройка подключения к базе данных"`
|
||||||
|
TokensSetting TokensSetting `schema:"Настройка секретов"`
|
||||||
|
HttpSetting HttpSetting `schema:"Настройка сервера"`
|
||||||
|
GrpcSetting GrpcSetting `schema:"Настройка grpc соединения"`
|
||||||
|
Metrics structure.MetricConfiguration `schema:"Настройка метрик"`
|
||||||
|
JournalSetting Journal `schema:"Настройка журалирования"`
|
||||||
|
Redis structure.RedisConfiguration `schema:"Настройка Redis" valid:"required~Required"`
|
||||||
|
AccountingSetting Accounting `schema:"Настройка учета запросов"`
|
||||||
|
AuthCacheSetting Cache `schema:"Настройка кеширования данных аутентификации приложений" valid:"required~Required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache struct {
|
||||||
|
EnableCache bool `schema:"Кеширование,включает кеширования для токена приложения"`
|
||||||
|
EvictTimeout string `schema:"Время жизни записи в кеше"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Journal struct {
|
||||||
|
Journal rx.Config `schema:"Настройка конфигурации"`
|
||||||
|
MethodsPatterns []string `schema:"Список методов для логирования,список строк вида: 'module/group/method'(* - для частичного совпадения). При обработке запроса, если вызываемый метод совпадает со строкой из списка, тела запроса и ответа записываются в лог"`
|
||||||
|
}
|
||||||
|
|
||||||
|
TokensSetting struct {
|
||||||
|
AdminSecret string `schema:"Секрет для проверки токена администратора"`
|
||||||
|
ApplicationSecret string `schema:"Секрет для проверки токена приложений"`
|
||||||
|
ApplicationVerify bool `schema:"Проверка подписи токена приложений"`
|
||||||
|
UserSecret string `schema:"Секрет для проверки токена пользователя"`
|
||||||
|
}
|
||||||
|
|
||||||
|
Accounting struct {
|
||||||
|
Enable bool `schema:"Учет запросов,включает/отключает учет запросов"`
|
||||||
|
SnapshotTimeout string `schema:"Частота выгрузки ограничений для приложений" valid:"required~Required"`
|
||||||
|
Setting []AccountingSetting `schema:"Настройка учета для приложений"`
|
||||||
|
Storing StoringSetting `schema:"Настройка хранения всех запросов"`
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountingSetting struct {
|
||||||
|
ApplicationId int32 `valid:"required~Required" schema:"Идентификатор приложения"`
|
||||||
|
EnableStoring bool `schema:"Хранение запросов,если включено, каждый факт обработки запроса будет фиксироваться в БД"`
|
||||||
|
Limits []LimitSetting `schema:"Настройка ограничений на запросы"`
|
||||||
|
}
|
||||||
|
|
||||||
|
LimitSetting struct {
|
||||||
|
Pattern string `valid:"required~Required" schema:"Шаблон пути,указывается путь для которого будут применяется ограничения; поддерживается '/*' для неполного совпадения"`
|
||||||
|
MaxCount int `schema:"Количество запросов"`
|
||||||
|
Timeout string `schema:"Время жизни одного запроса"`
|
||||||
|
}
|
||||||
|
|
||||||
|
StoringSetting struct {
|
||||||
|
Size int `schema:"Размер буфера,размер буфера,при достижении которого данные сбрасываются в БД" valid:"required,range(1|1000000)"`
|
||||||
|
Timeout string `schema:"Частота выгрузки всех учтенных запросов,периодичность сброса данных в БД" valid:"required~Required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpSetting struct {
|
||||||
|
MaxRequestBodySizeBytes int64 `schema:"Максимальный размер тела запроса,в байтайх, по умолчанию: 512 MB"`
|
||||||
|
}
|
||||||
|
|
||||||
|
GrpcSetting struct {
|
||||||
|
EnableOriginalProtoErrors bool `schema:"Проксирование ошибок в протобаф,включение/отключение проксирования, по умолчанию отключено"`
|
||||||
|
ProxyGrpcErrorDetails bool `schema:"Проксирование первого элемента из details GRPC ошибки,включение/отключение проксирования, по умолчанию отключено"`
|
||||||
|
MultipartDataTransferBufferSizeBytes int64 `schema:"Размер буфера для передачи бинарных файлов,по умолчанию 4 KB"`
|
||||||
|
SyncInvokeMethodTimeoutMs int64 `schema:"Время ожидания вызова метода,значение в миллисекундах, по умолчанию: 30000"`
|
||||||
|
StreamInvokeMethodTimeoutMs int64 `schema:"Время ожидания передачи и обработки файла,значение в миллисекундах, по умолчанию: 60000"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (cfg GrpcSetting) GetSyncInvokeTimeout() time.Duration {
|
||||||
|
if cfg.SyncInvokeMethodTimeoutMs <= 0 {
|
||||||
|
return defaultSyncTimeout
|
||||||
|
}
|
||||||
|
return time.Duration(cfg.SyncInvokeMethodTimeoutMs) * time.Millisecond
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg GrpcSetting) GetStreamInvokeTimeout() time.Duration {
|
||||||
|
if cfg.StreamInvokeMethodTimeoutMs <= 0 {
|
||||||
|
return defaultStreamTimeout
|
||||||
|
}
|
||||||
|
return time.Duration(cfg.StreamInvokeMethodTimeoutMs) * time.Millisecond
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg GrpcSetting) GetTransferFileBufferSize() int64 {
|
||||||
|
if cfg.MultipartDataTransferBufferSizeBytes <= 0 {
|
||||||
|
return defaultBufferSize
|
||||||
|
}
|
||||||
|
return cfg.MultipartDataTransferBufferSizeBytes
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cfg HttpSetting) GetMaxRequestBodySize() int64 {
|
||||||
|
if cfg.MaxRequestBodySizeBytes <= 0 {
|
||||||
|
return defaultMaxRequestBodySize
|
||||||
|
}
|
||||||
|
return cfg.MaxRequestBodySizeBytes
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package conf_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/test/rct"
|
|
||||||
"isp-gate-service/conf"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestDefaultRemoteConfig(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
rct.Test(t, "default_remote_config.json", conf.Remote{})
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package domain
|
|
||||||
|
|
||||||
type AdminAuthenticateResponse struct {
|
|
||||||
Authenticated bool
|
|
||||||
ErrorReason string
|
|
||||||
AdminId int
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package domain
|
|
||||||
|
|
||||||
type AuthData struct {
|
|
||||||
SystemId int
|
|
||||||
DomainId int
|
|
||||||
ServiceId int
|
|
||||||
ApplicationId int
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package domain
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrAuthenticationCacheMiss = errors.New("authentication not found in cache")
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package domain
|
||||||
|
|
||||||
|
type ProxyResponse struct {
|
||||||
|
requestBody []byte
|
||||||
|
responseBody []byte
|
||||||
|
error error
|
||||||
|
}
|
||||||
|
|
||||||
|
func Create() ProxyResponse {
|
||||||
|
return ProxyResponse{requestBody: nil, responseBody: nil, error: nil}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ProxyResponse) SetRequestBody(requestBody []byte) ProxyResponse {
|
||||||
|
p.requestBody = requestBody
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ProxyResponse) SetResponseBody(responseBody []byte) ProxyResponse {
|
||||||
|
p.responseBody = responseBody
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ProxyResponse) SetError(err error) ProxyResponse {
|
||||||
|
p.error = err
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p ProxyResponse) Get() (requestBody, responseBody []byte, err error) {
|
||||||
|
return p.requestBody, p.responseBody, p.error
|
||||||
|
}
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package domain
|
|
||||||
|
|
||||||
type AuthenticateRequest struct {
|
|
||||||
Token string
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthenticateResponse struct {
|
|
||||||
Authenticated bool
|
|
||||||
ErrorReason string
|
|
||||||
AuthData *AuthData
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthorizeRequest struct {
|
|
||||||
ApplicationId int
|
|
||||||
Endpoint string
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthorizeResponse struct {
|
|
||||||
Authorized bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type AdminAuthorizeRequest struct {
|
|
||||||
AdminId int
|
|
||||||
Permission string
|
|
||||||
}
|
|
||||||
|
|
||||||
type AdminAuthorizeResponse struct {
|
|
||||||
Authorized bool
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package domain
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RateLimitResult struct {
|
|
||||||
Allow bool
|
|
||||||
Remaining int
|
|
||||||
RetryAfter time.Duration
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"isp-gate-service/accounting/state"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Snapshot struct {
|
||||||
|
TableName string `sql:"?db_schema.snapshot" json:"-"`
|
||||||
|
AppId int32 `sql:",pk"`
|
||||||
|
LimitState map[string]state.Snapshot
|
||||||
|
Version int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Request struct {
|
||||||
|
TableName string `sql:"?db_schema.requests" json:"-"`
|
||||||
|
Id int `sql:",pk"`
|
||||||
|
AppId int32
|
||||||
|
Method string
|
||||||
|
CreatedAt time.Time
|
||||||
|
}
|
||||||
@@ -1,79 +1,23 @@
|
|||||||
module isp-gate-service
|
module isp-gate-service
|
||||||
|
|
||||||
go 1.24
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-redis/redis_rate/v10 v10.0.1
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||||
github.com/google/uuid v1.6.0
|
github.com/fasthttp/websocket v1.4.1
|
||||||
github.com/gorilla/mux v1.8.1
|
github.com/go-pg/pg/v9 v9.1.7
|
||||||
github.com/gorilla/websocket v1.5.3
|
github.com/go-redis/redis/v8 v8.0.0-beta.2
|
||||||
|
github.com/golang/protobuf v1.3.5
|
||||||
|
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f
|
||||||
|
github.com/integration-system/isp-journal v1.5.0
|
||||||
|
github.com/integration-system/isp-lib/v2 v2.6.3-0.20200925192756-f336302805fa
|
||||||
|
github.com/integration-system/isp-log v1.1.5
|
||||||
|
github.com/json-iterator/go v1.1.10
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
github.com/redis/go-redis/v9 v9.7.3
|
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
|
||||||
github.com/stretchr/testify v1.10.0
|
github.com/spf13/cast v1.3.1
|
||||||
github.com/tomakado/websocketproxy v0.1.0
|
github.com/stretchr/testify v1.6.1
|
||||||
github.com/txix-open/isp-kit v1.51.0
|
github.com/valyala/fasthttp v1.16.0
|
||||||
github.com/txix-open/jsonschema v1.3.0
|
golang.org/x/net v0.0.0-20200822124328-c89045814202
|
||||||
golang.org/x/net v0.40.0
|
google.golang.org/grpc v1.29.1
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2
|
|
||||||
google.golang.org/grpc v1.72.0
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/txix-open/etp/v4 v4.0.1 // indirect
|
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
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/v4 v4.3.0 // 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/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
|
|
||||||
github.com/getsentry/sentry-go v0.32.0 // 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/json-iterator/go v1.1.12 // indirect
|
|
||||||
github.com/julienschmidt/httprouter v1.3.0 // indirect
|
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
|
||||||
github.com/mailru/easyjson v0.9.0 // indirect
|
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
||||||
github.com/prometheus/client_golang v1.22.0 // indirect
|
|
||||||
github.com/prometheus/client_model v0.6.2 // indirect
|
|
||||||
github.com/prometheus/common v0.63.0 // indirect
|
|
||||||
github.com/prometheus/procfs v0.16.1 // indirect
|
|
||||||
github.com/txix-open/bellows v1.2.0 // indirect
|
|
||||||
github.com/txix-open/etp/v3 v3.2.0
|
|
||||||
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
|
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.60.0 // indirect
|
|
||||||
go.opentelemetry.io/otel v1.35.0 // indirect
|
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
|
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0 // indirect
|
|
||||||
go.opentelemetry.io/otel/metric v1.35.0 // indirect
|
|
||||||
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
|
|
||||||
go.opentelemetry.io/otel/trace v1.35.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/sys v0.33.0 // indirect
|
|
||||||
golang.org/x/text v0.25.0 // indirect
|
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 // 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
|
|
||||||
)
|
)
|
||||||
@@ -1,194 +1,608 @@
|
|||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||||
|
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7 h1:qELHH0AWCvf98Yf+CNIJx9vOZOfHFDDzgDRYsnNk/vs=
|
||||||
|
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60=
|
||||||
|
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||||
|
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||||
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
|
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
|
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||||
|
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||||
|
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||||
|
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/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
|
||||||
|
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||||
|
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
|
||||||
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
|
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg=
|
||||||
|
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f h1:y2hSFdXeA1y5z5f0vfNO0Dg5qVY036qzlz3Pds0B92o=
|
||||||
|
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||||
|
github.com/aws/aws-sdk-go v1.29.9/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg=
|
||||||
|
github.com/benbjohnson/clock v1.0.0 h1:78Jk/r6m4wCi6sndMpty7A//t4dw/RW5fV4ZgDVfX1w=
|
||||||
|
github.com/benbjohnson/clock v1.0.0/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
|
||||||
|
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/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
github.com/buaazp/fasthttprouter v0.1.1 h1:4oAnN0C3xZjylvZJdP35cxfclyn4TYkW6Y+DSvS+h8Q=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/buaazp/fasthttprouter v0.1.1/go.mod h1:h/Ap5oRVLeItGKTVBb+heQPks+HdIUtGmI4H5WCYijM=
|
||||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
github.com/cenkalti/backoff/v4 v4.0.0 h1:6VeaLF9aI+MAUQ95106HwWzYZgJJpZ4stumjj6RFYAU=
|
||||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
|
||||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
github.com/cenkalti/backoff/v4 v4.0.2 h1:JIufpQLbh4DkbQoii76ItQIUFzevQSqOLZca4eamEDs=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
|
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
|
||||||
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
|
github.com/codemodus/kace v0.5.1 h1:4OCsBlE2c/rSJo375ggfnucv9eRzge/U5LrrOZd47HA=
|
||||||
|
github.com/codemodus/kace v0.5.1/go.mod h1:coddaHoX1ku1YFSe4Ip0mL9kQjJvKkzb9CfIdG1YR04=
|
||||||
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/getsentry/sentry-go v0.32.0 h1:YKs+//QmwE3DcYtfKRH8/KyOOF/I6Qnx7qYGNHCGmCY=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/getsentry/sentry-go v0.32.0/go.mod h1:CYNcMMz73YigoHljQRG+qPF+eMq8gG72XcGN/p71BAY=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/fasthttp/websocket v1.4.1 h1:fisgNMCNCbIPM5GRRRTAckRrynbSzf76fevcJYJYnSM=
|
||||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
github.com/fasthttp/websocket v1.4.1/go.mod h1:toetUvZ3KISxtZERe0wzPPpnaN8GZCKHCowWctwA50o=
|
||||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||||
github.com/go-redis/redis_rate/v10 v10.0.1 h1:calPxi7tVlxojKunJwQ72kwfozdy25RjA0bCj1h0MUo=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
github.com/go-redis/redis_rate/v10 v10.0.1/go.mod h1:EMiuO9+cjRkR7UvdvwMO7vbgqJkltQHtwbdIQvaBKIU=
|
github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
|
||||||
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
|
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
|
||||||
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
|
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
|
||||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
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-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
|
||||||
|
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||||
|
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.4 h1:3Vw+rh13uq2JFNxgnMTGE1rnoieU9FmyE1gvnyylsYg=
|
||||||
|
github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg=
|
||||||
|
github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||||
|
github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
|
||||||
|
github.com/go-openapi/spec v0.19.9 h1:9z9cbFuZJ7AcvOHKIY+f6Aevb4vObNDkTEyoMfO7rAc=
|
||||||
|
github.com/go-openapi/spec v0.19.9/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28=
|
||||||
|
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
|
||||||
|
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||||
|
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||||
|
github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE=
|
||||||
|
github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY=
|
||||||
|
github.com/go-pg/pg/v9 v9.0.0-beta.14/go.mod h1:T2Sr6bpTCOr2lUqOUMiXLMJqZHSUBKk1LdgSqjwhZfA=
|
||||||
|
github.com/go-pg/pg/v9 v9.0.3/go.mod h1:Tm/Q3Vt6gdQOH6TTN1H/xLlIXc+Qrka7TZ6uREtu/eA=
|
||||||
|
github.com/go-pg/pg/v9 v9.1.4/go.mod h1:QM13HBLkdml4zcKOfUfGLymM6hb72aKTJLrmaH8rsFg=
|
||||||
|
github.com/go-pg/pg/v9 v9.1.7 h1:JSAszC/xbOHmvS86fPnvxCQ288lR0ecX7yqxiPnBoNo=
|
||||||
|
github.com/go-pg/pg/v9 v9.1.7/go.mod h1:QM13HBLkdml4zcKOfUfGLymM6hb72aKTJLrmaH8rsFg=
|
||||||
|
github.com/go-pg/urlstruct v0.1.0/go.mod h1:2Nag+BIny6G/KYCkdt++ZnqU/VinzimGapKfs4kwlN0=
|
||||||
|
github.com/go-pg/urlstruct v0.2.6/go.mod h1:dxENwVISWSOX+k87hDt0ueEJadD+gZWv3tHzwfmZPu8=
|
||||||
|
github.com/go-pg/urlstruct v0.3.0 h1:ORiTb205uT7v7lvq4VUOQ4ddJ5TjFRlVRWqWsMBgek4=
|
||||||
|
github.com/go-pg/urlstruct v0.3.0/go.mod h1:/XKyiUOUUS3onjF+LJxbfmSywYAdl6qMfVbX33Q8rgg=
|
||||||
|
github.com/go-pg/zerochecker v0.1.1 h1:av77Qe7Gs+1oYGGh51k0sbZ0bUaxJEdeP0r8YE64Dco=
|
||||||
|
github.com/go-pg/zerochecker v0.1.1/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo=
|
||||||
|
github.com/go-redis/redis v6.15.6+incompatible h1:H9evprGPLI8+ci7fxQx6WNZHJSb7be8FqJQRhdQZ5Sg=
|
||||||
|
github.com/go-redis/redis v6.15.6+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||||
|
github.com/go-redis/redis/v8 v8.0.0-beta.2 h1:9S28J9QMBotgI3tGgXbX1Wk9i8QYC3Orw4bTLoPrQeI=
|
||||||
|
github.com/go-redis/redis/v8 v8.0.0-beta.2/go.mod h1:o1M7JtsgfDYyv3o+gBn/jJ1LkqpnCrmil7PSppZGBak=
|
||||||
|
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||||
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
|
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
|
||||||
|
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
||||||
|
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
|
||||||
|
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||||
|
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
|
||||||
|
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||||
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
|
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||||
|
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
|
||||||
|
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||||
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
|
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
|
||||||
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
|
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk=
|
||||||
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
|
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
|
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c h1:yyIH4qCFf5LD5PKhXoX4BZh3wRjd59xBV4eAQTBwS6k=
|
||||||
|
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c/go.mod h1:6cf4ZNvtzZ/KMiuc+d5Y7rSHjzlYBWEqbVyDfUDhqIE=
|
||||||
|
github.com/integration-system/bellows v1.0.0 h1:fVFBYo7Oty4IiIWukjSgBoaCi+0EmPz7LMO8ACs+gDc=
|
||||||
|
github.com/integration-system/bellows v1.0.0/go.mod h1:qHPg1ptN3AHHr0f/wvoicfA2LOCprOyrbXnIa5QIRe0=
|
||||||
|
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f h1:52UOJguw5yqe1y2JjmyVxGcZf3kv2BQeUodR363MkiQ=
|
||||||
|
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f/go.mod h1:w+dmaWojuIwNujSYg6qt1wKHhSdorLOivCEl/XuLzbM=
|
||||||
|
github.com/integration-system/gowsdl v1.0.0 h1:rDv5HrzNUs6aWTj9roSDS9ZdIf58FzF0YVP2nusvbto=
|
||||||
|
github.com/integration-system/gowsdl v1.0.0/go.mod h1:ZwTCE+Av5aQLnPj2/3PIop6mzCs1FY7jXrcWDvSjrBA=
|
||||||
|
github.com/integration-system/isp-etp-go/v2 v2.1.0 h1:qRw4J04vwYxSm52OUIt6lKWpxEQE2aZjUT7kZDG/A4Q=
|
||||||
|
github.com/integration-system/isp-etp-go/v2 v2.1.0/go.mod h1:Ndq5DMM3sDJjZn4cyKKvZrVED0FMeoXMRWHZTq+2Z1o=
|
||||||
|
github.com/integration-system/isp-etp-go/v2 v2.1.1 h1:6LU9eE1cGVpp8HNRYu83K4hY49YlNPFd/uj3+Iog4ro=
|
||||||
|
github.com/integration-system/isp-etp-go/v2 v2.1.1/go.mod h1:Ndq5DMM3sDJjZn4cyKKvZrVED0FMeoXMRWHZTq+2Z1o=
|
||||||
|
github.com/integration-system/isp-io v0.0.0-20190723122940-3daf588d878f h1:nJGOobuawo5d3QgoLl1i2SJVDIHkxMl0bhH1+iqZmnk=
|
||||||
|
github.com/integration-system/isp-io v0.0.0-20190723122940-3daf588d878f/go.mod h1:1cjy4g5F8WXrOB3l/bL3mw+TCWDppOL1pz08wOAMi9Y=
|
||||||
|
github.com/integration-system/isp-journal v1.5.0 h1:7Lpt7dHhpq1zRY4qRRYUMiEnaQZbxyPHRcy/ik/Vm8I=
|
||||||
|
github.com/integration-system/isp-journal v1.5.0/go.mod h1:B6cLJqjNL+XHWv4IzKt5aIZ7AjbHX2tQFXgRSaWNNIo=
|
||||||
|
github.com/integration-system/isp-lib/v2 v2.3.1 h1:jPsrovXg3yt+A64AQB+Mc/KyJYcC8d+MZK3OLSHCxZY=
|
||||||
|
github.com/integration-system/isp-lib/v2 v2.3.1/go.mod h1:eRSmS3+S8WXTUKu7YtSimFJDrLF+/esM/989NBEsP2o=
|
||||||
|
github.com/integration-system/isp-lib/v2 v2.6.3-0.20200925192756-f336302805fa h1:sORWdPlJqhLpYnYfyB67dDQ1u8LJqPwlawQQhEiNQ4k=
|
||||||
|
github.com/integration-system/isp-lib/v2 v2.6.3-0.20200925192756-f336302805fa/go.mod h1:ZGW7qQsCuELBHRBnSSDSEonPx+FxAfHiAfwsGQZzVO4=
|
||||||
|
github.com/integration-system/isp-log v1.1.2 h1:bnWxPjDOC1Y/tEzFxa42aG+xaPRWizuJADAwXgp2i5U=
|
||||||
|
github.com/integration-system/isp-log v1.1.2/go.mod h1:VVMr3cHW+RuFurPUSeVz71KUnOGQxogxO5atV9N8ISs=
|
||||||
|
github.com/integration-system/isp-log v1.1.5 h1:YiMx+hV2YyCTfHu5vIjtqSkRtPjr/WY9xvKsvONDVNU=
|
||||||
|
github.com/integration-system/isp-log v1.1.5/go.mod h1:VVMr3cHW+RuFurPUSeVz71KUnOGQxogxO5atV9N8ISs=
|
||||||
|
github.com/integration-system/jsonschema v1.0.0 h1:Lci4sHGhOX27qCgZo5rvJ37Bjcfm+qCwU0yvw6ImEX4=
|
||||||
|
github.com/integration-system/jsonschema v1.0.0/go.mod h1:EoqDH7RmC8Epg5EgjboIxDo7Udv3WX2exGqtIVB4hI0=
|
||||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
|
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||||
|
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||||
|
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
|
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||||
|
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||||
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||||
|
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||||
|
github.com/klauspost/compress v1.10.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||||
|
github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
|
||||||
|
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||||
|
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||||
|
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||||
|
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 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||||
|
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||||
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
|
||||||
|
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||||
|
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||||
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
|
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||||
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
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/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 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||||
|
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||||
|
github.com/nats-io/nats-server/v2 v2.1.4/go.mod h1:Jw1Z28soD/QasIA2uWjXyM9El1jly3YwyFOuR8tH1rg=
|
||||||
|
github.com/nats-io/nats-streaming-server v0.17.0/go.mod h1:ewPBEsmp62Znl3dcRsYtlcfwudxHEdYMtYqUQSt4fE0=
|
||||||
|
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||||
|
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||||
|
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||||
|
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||||
|
github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac=
|
||||||
|
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
|
||||||
|
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||||
|
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||||
|
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||||
|
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||||
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
|
github.com/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 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
|
github.com/pressly/goose v2.6.0+incompatible h1:3f8zIQ8rfgP9tyI0Hmcs2YNAqUCL1c+diLe3iU8Qd/k=
|
||||||
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
|
github.com/pressly/goose v2.6.0+incompatible/go.mod h1:m+QHWCqxR3k8D9l7qfzuC/djtlfzxr34mozWDYEu1z8=
|
||||||
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
|
github.com/profefe/profefe v0.0.0-20200307211836-5ab457f7a4d8 h1:9lI6rm0yjyeB6Q5zE/SytxlNDgRQ1thnRZGQChtsLRs=
|
||||||
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
|
github.com/profefe/profefe v0.0.0-20200307211836-5ab457f7a4d8/go.mod h1:QOlABo1QFtwVrB7Rdl8gwY9pqxmln8lIWOQEW1oj1uI=
|
||||||
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
|
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
|
||||||
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
|
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||||
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
|
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
|
||||||
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||||
github.com/redis/go-redis/v9 v9.7.3 h1:YpPyAayJV+XErNsatSElgRZZVCwXX9QzkKYNvO7x0wM=
|
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/redis/go-redis/v9 v9.7.3/go.mod h1:bGUrSggJ9X9GUmZpZNEOQKaANxSGgOEBRltRTZHSvrA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||||
|
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||||
|
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
|
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||||
|
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
|
||||||
|
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||||
|
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
|
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||||
|
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
|
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
|
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||||
|
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||||
|
github.com/prometheus/procfs v0.0.9/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||||
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ=
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
|
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/rs/xid v1.2.2-0.20200205151950-d13a6085d55c/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
|
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||||
|
github.com/savsgio/gotils v0.0.0-20190714152828-365999d0a274 h1:F52t1X2ziOrMcQMVHo8ZxwOrDTMAq6MrlKtL1Atu2wU=
|
||||||
|
github.com/savsgio/gotils v0.0.0-20190714152828-365999d0a274/go.mod h1:w803/Fg1m0hrp1ZT9KNfQe4E4+WOMMFLcgzPvOcye10=
|
||||||
|
github.com/segmentio/encoding v0.1.10 h1:0b8dva47cSuNQR5ZcU3d0pfi9EnPpSK6q7y5ZGEW36Q=
|
||||||
|
github.com/segmentio/encoding v0.1.10/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
|
||||||
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||||
|
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||||
|
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||||
|
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||||
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
|
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||||
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
|
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||||
|
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
|
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||||
|
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||||
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
|
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||||
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
|
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
|
||||||
|
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
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.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/tomakado/websocketproxy v0.1.0 h1:e037TLXDvEYYHlxHE5pqmj/DytFKm2NRn7i4wbVzIyE=
|
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM=
|
||||||
github.com/tomakado/websocketproxy v0.1.0/go.mod h1:EXg/3jcTJYZ04Hsf93RpY90FYA9lj1Sl+VM7lZI6xpM=
|
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E=
|
||||||
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
|
github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI=
|
||||||
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba h1:lUPlXKqgbqT2SVg2Y+eT9mu5wbqMnG+i/+Q9nK7C0Rs=
|
||||||
github.com/txix-open/etp/v3 v3.2.0 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M=
|
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba/go.mod h1:O1lAbCgAAX/KZ80LM/OXwtWFI/5TvZlwxSg8Cq08PV0=
|
||||||
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
|
github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y=
|
||||||
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio=
|
||||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
github.com/swaggo/swag v1.6.7 h1:e8GC2xDllJZr3omJkm9YfmK0Y56+rMO3cg0JBKNz09s=
|
||||||
github.com/txix-open/grmq v1.8.1 h1:bcPLuYZXJ+1h9D3w7JYzUTypnQsw9XAT0Ftl/Fu+cZA=
|
github.com/swaggo/swag v1.6.7/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc=
|
||||||
github.com/txix-open/grmq v1.8.1/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3 h1:COy7ekr2jBEd34npP2LvMTqk9UtiLkuvkjiJFHihlTo=
|
||||||
github.com/txix-open/isp-kit v1.51.0 h1:sSDs/M5EaAiIJGbefRprbZH2GgCfdjwgpUV94NWd73A=
|
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3/go.mod h1:ehwM4AFY4byYSorQbigh79cKUOUNL3pAOz5eCAQNlGI=
|
||||||
github.com/txix-open/isp-kit v1.51.0/go.mod h1:OkscabRkpFGjUOFrbPM7yTKD/Br2/iv5/PWr/T2Jtd4=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||||
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0=
|
||||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
|
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
|
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
github.com/valyala/fasthttp v1.4.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
github.com/valyala/fasthttp v1.16.0 h1:9zAqOYLl8Tuy3E5R6ckzGDJ1g8+pw15oQp2iL9Jl6gQ=
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA=
|
||||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.60.0 h1:0tY123n7CdWMem7MOVdKOt0YfshufLCwfE5Bob+hQuM=
|
github.com/vmihailenco/bufpool v0.1.5 h1:mEO/biwhAgiY97yPMmAdH4PvaIu63C6uGBdfSdoMo/I=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.60.0/go.mod h1:CosX/aS4eHnG9D7nESYpV753l4j9q5j3SL/PUYd2lR8=
|
github.com/vmihailenco/bufpool v0.1.5/go.mod h1:fL9i/PRTuS7AELqAHwSU1Zf1c70xhkhGe/cD5ud9pJk=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
|
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
|
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
|
||||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
github.com/vmihailenco/msgpack/v4 v4.3.5/go.mod h1:DuaveEe48abshDmz5UBKyZ+yDugvaeFk5ayfrewUOaw=
|
||||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
github.com/vmihailenco/msgpack/v4 v4.3.7 h1:Aj4eMY2qXTRfWRwHKJ2n/CWKVy15pCYN327QMJ/OUVs=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 h1:1fTNlAIJZGWLP5FVu0fikVry1IsiUnXjf7QFvoNN3Xw=
|
github.com/vmihailenco/msgpack/v4 v4.3.7/go.mod h1:Ii+PksJlvFT5ZRcB/4YLAInMIp6a0WOCm0L3BU0aNG4=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0/go.mod h1:zjPK58DtkqQFn+YUMbx0M2XV3QgKU0gS9LeGohREyK4=
|
github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0cd26cZoE=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0 h1:xJ2qHD0C1BeYVTLLR9sX12+Qb95kfeD/byKj6Ky1pXg=
|
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.35.0/go.mod h1:u5BF1xyjstDowA1R5QAO9JHzqK+ublenEW/dyqTjBVk=
|
github.com/vmihailenco/tagparser v0.1.0/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
|
||||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w=
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
go.opentelemetry.io/otel v0.5.0 h1:tdIR1veg/z+VRJaw/6SIxz+QX3l+m+BDleYLTs+GC1g=
|
||||||
go.opentelemetry.io/proto/otlp v1.6.0 h1:jQjP+AQyTf+Fe7OKj/MfkDrmK4MNVtw2NpXsf9fefDI=
|
go.opentelemetry.io/otel v0.5.0/go.mod h1:jzBIgIzK43Iu1BpDAXwqOd6UPsSAk+ewVZ5ofSXw4Ek=
|
||||||
go.opentelemetry.io/proto/otlp v1.6.0/go.mod h1:cicgGehlFuNdgZkcALOCh3VE6K/u2tAjzlRhDwmVpZc=
|
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY=
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
go.uber.org/multierr v1.3.0 h1:sFPn2GLc3poCkfrpIXGhBD2X0CMIo4Q/zSULXrj/+uc=
|
||||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
|
||||||
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||||
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 h1:vPV0tzlsK6EzEDHNNH5sa7Hs9bd7iXR7B1tSiPepkV0=
|
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:pKLAc5OolXC3ViWGI62vvC0n10CpwAtRcTNCFwTKBEw=
|
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 h1:IqsN8hx+lWLqlN+Sc3DoMy/watjofWiU8sRFgQ8fhKM=
|
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
|
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
|
golang.org/x/crypto v0.0.0-20191128160524-b544559bb6d1/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
|
||||||
|
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
|
||||||
|
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||||
|
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||||
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/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-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
|
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
|
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200222033325-078779b8f2d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
|
||||||
|
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/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-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 h1:sfkvUWPNGwSV+8/fNqctR5lS2AqCSqYwXdrjCxp/dXo=
|
||||||
|
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
|
||||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
|
||||||
|
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
|
||||||
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||||
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
|
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||||
|
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20200220224806-8a925fa4c0df h1:oQFmpjL+rb2xLkgPCpdGSAGDdq1geTZVvIfCMxSB/wQ=
|
||||||
|
golang.org/x/tools v0.0.0-20200220224806-8a925fa4c0df/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.0.0-20200826040757-bc8aaaa29e06 h1:ChBCbOHeLqK+j+znGPlWCcvx/t2PdxmyPBheVZxXbcc=
|
||||||
|
golang.org/x/tools v0.0.0-20200826040757-bc8aaaa29e06/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
|
||||||
|
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||||
|
google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200211111953-2dc5924e3898 h1:bKX1IGaSj2XD9yfWNts9HKRdQRH0lOZ0S7Nb8meQSlY=
|
||||||
|
google.golang.org/genproto v0.0.0-20200211111953-2dc5924e3898/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36 h1:j7CmVRD4Kec0+f8VuBAc2Ak2MFfXm5Q2/RxuJLL+76E=
|
||||||
|
google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
|
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4=
|
||||||
|
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||||
|
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
|
||||||
|
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||||
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||||
|
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||||
|
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||||
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||||
|
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||||
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
|
honnef.co/go/tools v0.0.1-2020.1.2 h1:8w2Ud1JmaU9M5os2j8aKMpPs4guVq+RMUN5phK2najE=
|
||||||
|
honnef.co/go/tools v0.0.1-2020.1.2/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
|
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
|
||||||
|
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
|
||||||
|
nhooyr.io/websocket v1.7.4 h1:w/LGB2sZT0RV8lZYR7nfyaYz4PUbYZ5oF7NBon2M0NY=
|
||||||
|
nhooyr.io/websocket v1.7.4/go.mod h1:PxYxCwFdFYQ0yRvtQz3s/dC+VEm7CSuC/4b9t8MQQxw=
|
||||||
|
nhooyr.io/websocket v1.8.4 h1:P43INlkmY2eCxLvHeiMFK/ROUiOm0NdzRGGDtURbe58=
|
||||||
|
nhooyr.io/websocket v1.8.4/go.mod h1:LiqdCg1Cu7TPWxEvPjPa0TGYxCsy4pHNTN9gGluwBpQ=
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"isp-gate-service/accounting"
|
||||||
|
"isp-gate-service/authenticate"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/invoker"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/proxy"
|
||||||
|
"isp-gate-service/routing"
|
||||||
|
"isp-gate-service/service"
|
||||||
|
"isp-gate-service/service/matcher"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
execution = 1e6
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errAccounting = errors.New("accounting error")
|
||||||
|
|
||||||
|
helper handlerHelper
|
||||||
|
)
|
||||||
|
|
||||||
|
type handlerHelper struct{}
|
||||||
|
|
||||||
|
func CompleteRequest(ctx *fasthttp.RequestCtx) {
|
||||||
|
currentTime := time.Now()
|
||||||
|
|
||||||
|
method, resp := helper.AuthenticateAccountingProxy(ctx)
|
||||||
|
|
||||||
|
executionTime := time.Since(currentTime) / execution
|
||||||
|
|
||||||
|
statusCode := ctx.Response.StatusCode()
|
||||||
|
service.Metrics.UpdateStatusCounter(helper.SetMetricStatus(statusCode))
|
||||||
|
if statusCode == http.StatusOK {
|
||||||
|
service.Metrics.UpdateMethodResponseTime(method, executionTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
logEnable := config.GetRemote().(*conf.RemoteConfig).JournalSetting.Journal.Enable
|
||||||
|
//nolint
|
||||||
|
if logEnable && matcher.JournalMethods.Match(method) {
|
||||||
|
requestBody, responseBody, err := resp.Get()
|
||||||
|
if err != nil {
|
||||||
|
if err := invoker.Journal.Error(method, requestBody, responseBody, err); err != nil {
|
||||||
|
log.Warnf(log_code.WarnJournalCouldNotWriteToFile, "could not write to file journal: %v", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := invoker.Journal.Info(method, requestBody, responseBody); err != nil {
|
||||||
|
log.Warnf(log_code.WarnJournalCouldNotWriteToFile, "could not write to file journal: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (handlerHelper) AuthenticateAccountingProxy(ctx *fasthttp.RequestCtx) (string, domain.ProxyResponse) {
|
||||||
|
initialPath := string(ctx.Path())
|
||||||
|
|
||||||
|
p, path := proxy.Find(initialPath)
|
||||||
|
if p == nil {
|
||||||
|
msg := fmt.Sprintf("unknown proxy for '%s'", initialPath)
|
||||||
|
utils.WriteError(ctx, msg, codes.NotFound, nil)
|
||||||
|
return initialPath, domain.Create().SetError(errors.New(msg))
|
||||||
|
}
|
||||||
|
|
||||||
|
if !p.SkipExistCheck() {
|
||||||
|
if _, ok := routing.AllMethods[path]; !ok {
|
||||||
|
msg := "not implemented"
|
||||||
|
utils.WriteError(ctx, msg, codes.Unimplemented, nil)
|
||||||
|
return path, domain.Create().SetError(errors.New(msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !p.SkipAuth() {
|
||||||
|
applicationId, err := authenticate.Do(ctx, path)
|
||||||
|
if err != nil {
|
||||||
|
message := "unknown error"
|
||||||
|
status := codes.Unknown
|
||||||
|
details := make([]interface{}, 0)
|
||||||
|
if e, ok := err.(authenticate.ErrorDescription); ok {
|
||||||
|
message = e.Message()
|
||||||
|
status = e.ConvertToGrpcStatus()
|
||||||
|
details = e.Details()
|
||||||
|
}
|
||||||
|
utils.WriteError(ctx, message, status, details)
|
||||||
|
return path, domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !accounting.AcceptRequest(applicationId, path) {
|
||||||
|
err := errAccounting
|
||||||
|
utils.WriteError(ctx, "too many requests", codes.ResourceExhausted, nil)
|
||||||
|
return path, domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path, p.ProxyRequest(ctx, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (handlerHelper) SetMetricStatus(statusCode int) string {
|
||||||
|
metricStatus := "5xx"
|
||||||
|
switch {
|
||||||
|
case statusCode >= 100 && statusCode < 200:
|
||||||
|
metricStatus = "1xx"
|
||||||
|
case statusCode >= 200 && statusCode < 300:
|
||||||
|
metricStatus = "2xx"
|
||||||
|
case statusCode >= 300 && statusCode < 400:
|
||||||
|
metricStatus = "3xx"
|
||||||
|
case statusCode >= 400 && statusCode < 500:
|
||||||
|
metricStatus = "4xx"
|
||||||
|
case statusCode >= 500 && statusCode < 600:
|
||||||
|
metricStatus = "5xx"
|
||||||
|
}
|
||||||
|
return metricStatus
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package httperrors
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
type HttpError struct {
|
|
||||||
statusCode int
|
|
||||||
userMessage string
|
|
||||||
details []any
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(statusCode int, userMessage string, internalError error) *HttpError {
|
|
||||||
return &HttpError{
|
|
||||||
statusCode: statusCode,
|
|
||||||
userMessage: userMessage,
|
|
||||||
err: internalError,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *HttpError) Error() string {
|
|
||||||
return e.err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *HttpError) WriteError(w http.ResponseWriter) error {
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
w.WriteHeader(e.statusCode)
|
|
||||||
data := map[string]interface{}{
|
|
||||||
"errorCode": http.StatusText(e.statusCode),
|
|
||||||
"errorMessage": e.userMessage,
|
|
||||||
"details": e.details,
|
|
||||||
}
|
|
||||||
return json.NewEncoder(w).Encode(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *HttpError) WithDetails(details ...any) {
|
|
||||||
e.details = details
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package invoker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-journal/rx"
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type journalService struct {
|
||||||
|
*rx.RxJournal
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
journalClient = backend.NewRxGrpcClient(
|
||||||
|
backend.WithDialOptions(grpc.WithInsecure()),
|
||||||
|
)
|
||||||
|
Journal = &journalService{RxJournal: rx.NewDefaultRxJournal(journalClient)}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (*journalService) ReceiveServiceAddressList(list []structure.AddressConfiguration) bool {
|
||||||
|
if ok := journalClient.ReceiveAddressList(list); !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
go Journal.CollectAndTransferExistedLogs()
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package log_code
|
||||||
|
|
||||||
|
const (
|
||||||
|
WarnHttpServerShutdown = 602
|
||||||
|
ErrorHttpServerListen = 603
|
||||||
|
|
||||||
|
WarnProxyGrpcHandler = 604 //metadata: {"typeData":"", "method":""}
|
||||||
|
WarnConvertErrorDataMarshalResponse = 605
|
||||||
|
|
||||||
|
ErrorClientGrpc = 606
|
||||||
|
|
||||||
|
WarnJournalCouldNotWriteToFile = 607
|
||||||
|
|
||||||
|
ErrorClientJournal = 608
|
||||||
|
ErrorClientRedis = 609
|
||||||
|
ErrorClientHttp = 611
|
||||||
|
|
||||||
|
ErrorAuthenticate = 612
|
||||||
|
|
||||||
|
ErrorClientDatabase = 615
|
||||||
|
ErrorSnapshotAccounting = 616
|
||||||
|
ErrorUnloadAccounting = 617
|
||||||
|
|
||||||
|
ErrorWebsocketProxy = 618
|
||||||
|
)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package log_code
|
||||||
|
|
||||||
|
const (
|
||||||
|
MdTypeData = "typeData"
|
||||||
|
MdMethod = "method"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
TypeData = typeData{
|
||||||
|
SendMultipart: "sendMultipart",
|
||||||
|
GetFile: "getFile",
|
||||||
|
JsonContent: "jsonContent",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
typeData struct {
|
||||||
|
SendMultipart string
|
||||||
|
GetFile string
|
||||||
|
JsonContent string
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -1,37 +1,117 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/txix-open/isp-kit/bootstrap"
|
"context"
|
||||||
"github.com/txix-open/isp-kit/shutdown"
|
"os"
|
||||||
"isp-gate-service/assembly"
|
|
||||||
|
"github.com/integration-system/isp-lib/v2/bootstrap"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config/schema"
|
||||||
|
"github.com/integration-system/isp-lib/v2/metric"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/integration-system/isp-log/stdcodes"
|
||||||
|
"isp-gate-service/accounting"
|
||||||
|
"isp-gate-service/authenticate"
|
||||||
"isp-gate-service/conf"
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/invoker"
|
||||||
|
"isp-gate-service/model"
|
||||||
|
"isp-gate-service/proxy"
|
||||||
|
"isp-gate-service/redis"
|
||||||
|
"isp-gate-service/routing"
|
||||||
|
"isp-gate-service/server"
|
||||||
|
"isp-gate-service/service"
|
||||||
|
"isp-gate-service/service/matcher"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
version = "1.0.0"
|
version = "0.1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
boot := bootstrap.New(version, conf.Remote{}, nil)
|
cfg := config.InitConfig(&conf.Configuration{}).(*conf.Configuration)
|
||||||
app := boot.App
|
|
||||||
logger := app.Logger()
|
|
||||||
|
|
||||||
assembly, err := assembly.New(boot)
|
bs := bootstrap.
|
||||||
|
ServiceBootstrap(&conf.Configuration{}, &conf.RemoteConfig{}).
|
||||||
|
OnLocalConfigLoad(onLocalConfigLoad).
|
||||||
|
DefaultRemoteConfigPath(schema.ResolveDefaultConfigPath("default_remote_config.json")).
|
||||||
|
DeclareMe(makeDeclaration).
|
||||||
|
SocketConfiguration(socketConfiguration).
|
||||||
|
RequireRoutes(handleRouteUpdate).
|
||||||
|
RequireModule("journal", invoker.Journal.ReceiveServiceAddressList, false).
|
||||||
|
SubscribeBroadcastEvent(bootstrap.ListenRestartEvent())
|
||||||
|
|
||||||
|
requiredModules, err := proxy.InitProxies(cfg.Locations)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal(app.Context(), err)
|
log.Fatal(stdcodes.ModuleInvalidLocalConfig, err)
|
||||||
}
|
}
|
||||||
app.AddRunners(assembly.Runners()...)
|
for module, consumer := range requiredModules {
|
||||||
app.AddClosers(assembly.Closers()...)
|
bs.RequireModule(module, consumer, false)
|
||||||
|
}
|
||||||
|
bs.RequireModule(cfg.ModuleName, accounting.NewConnectionConsumer, false).
|
||||||
|
OnShutdown(onShutdown).
|
||||||
|
OnRemoteConfigReceive(onRemoteConfigReceive).
|
||||||
|
Run()
|
||||||
|
}
|
||||||
|
|
||||||
shutdown.On(func() {
|
func onLocalConfigLoad(_ *conf.Configuration) {
|
||||||
logger.Info(app.Context(), "starting shutdown")
|
|
||||||
app.Shutdown()
|
|
||||||
logger.Info(app.Context(), "shutdown completed")
|
|
||||||
})
|
|
||||||
|
|
||||||
err = app.Run()
|
}
|
||||||
|
|
||||||
|
func onRemoteConfigReceive(remoteConfig, oldRemoteConfig *conf.RemoteConfig) {
|
||||||
|
localCfg := config.Get().(*conf.Configuration)
|
||||||
|
|
||||||
|
model.DbClient.ReceiveConfiguration(remoteConfig.Database)
|
||||||
|
invoker.Journal.ReceiveConfiguration(remoteConfig.JournalSetting.Journal, localCfg.ModuleName)
|
||||||
|
matcher.JournalMethods = matcher.NewAtLeastOneMatcher(remoteConfig.JournalSetting.MethodsPatterns)
|
||||||
|
|
||||||
|
redis.Client.ReceiveConfiguration(remoteConfig.Redis)
|
||||||
|
authenticate.ReceiveConfiguration(remoteConfig.AuthCacheSetting)
|
||||||
|
accounting.ReceiveConfiguration(remoteConfig.AccountingSetting)
|
||||||
|
|
||||||
|
metric.InitCollectors(remoteConfig.Metrics, oldRemoteConfig.Metrics)
|
||||||
|
metric.InitHttpServer(remoteConfig.Metrics)
|
||||||
|
service.Metrics.Init()
|
||||||
|
|
||||||
|
server.Http.Init(remoteConfig.HttpSetting, oldRemoteConfig.HttpSetting)
|
||||||
|
}
|
||||||
|
|
||||||
|
func socketConfiguration(cfg interface{}) structure.SocketConfiguration {
|
||||||
|
appConfig := cfg.(*conf.Configuration)
|
||||||
|
return structure.SocketConfiguration{
|
||||||
|
Host: appConfig.ConfigServiceAddress.IP,
|
||||||
|
Port: appConfig.ConfigServiceAddress.Port,
|
||||||
|
Secure: false,
|
||||||
|
UrlParams: map[string]string{
|
||||||
|
"module_name": appConfig.ModuleName,
|
||||||
|
"instance_uuid": appConfig.InstanceUuid,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onShutdown(_ context.Context, _ os.Signal) {
|
||||||
|
server.Http.Close()
|
||||||
|
accounting.Close()
|
||||||
|
proxy.Close()
|
||||||
|
_ = redis.Client.Close()
|
||||||
|
_ = invoker.Journal.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleRouteUpdate(configs structure.RoutingConfig) bool {
|
||||||
|
routing.InitRoutes(configs)
|
||||||
|
err := proxy.InitProxiesFromConfigs(configs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Shutdown()
|
log.Error(stdcodes.ReceiveErrorFromConfig, err)
|
||||||
logger.Fatal(app.Context(), err)
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeDeclaration(localConfig interface{}) bootstrap.ModuleInfo {
|
||||||
|
cfg := localConfig.(*conf.Configuration)
|
||||||
|
return bootstrap.ModuleInfo{
|
||||||
|
ModuleName: cfg.ModuleName,
|
||||||
|
ModuleVersion: version,
|
||||||
|
GrpcOuterAddress: cfg.HttpOuterAddress,
|
||||||
|
Endpoints: []structure.EndpointDescriptor{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
adminAuthHeader = "x-auth-admin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AdminAuthenticator interface {
|
|
||||||
AdminAuthenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AdminAuthenticate(auth AdminAuthenticator) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
adminToken := ctx.Param(adminAuthHeader)
|
|
||||||
if adminToken == "" {
|
|
||||||
return next.Handle(ctx)
|
|
||||||
}
|
|
||||||
resp, err := auth.AdminAuthenticate(ctx.Context(), adminToken)
|
|
||||||
if err != nil {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusUnauthorized,
|
|
||||||
"invalid admin token",
|
|
||||||
errors.WithMessage(err, "admin authenticate: authenticate"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if !resp.Authenticated {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusUnauthorized,
|
|
||||||
"invalid admin token",
|
|
||||||
errors.WithMessage(errors.New(resp.ErrorReason), "admin authenticate: authenticate"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
ctx.AuthenticateAdmin(resp.AdminId, adminToken)
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AdminMethodStore interface {
|
|
||||||
IsInnerEndpoint(path string) bool
|
|
||||||
RequiredAdminPermission(path string) (string, bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
type AdminAuthorizer interface {
|
|
||||||
AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AdminAuthorize(store AdminMethodStore, authorizer AdminAuthorizer) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
isInner := store.IsInnerEndpoint(ctx.Endpoint())
|
|
||||||
if !isInner {
|
|
||||||
return next.Handle(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !ctx.IsAdminAuthenticated() {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusForbidden,
|
|
||||||
"admin authentication required",
|
|
||||||
errors.Errorf("admin authorization: admin authentication required for '%s'", ctx.Endpoint()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
requiredPerm, ok := store.RequiredAdminPermission(ctx.Endpoint())
|
|
||||||
if !ok {
|
|
||||||
return next.Handle(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err := authorizer.AdminAuthorize(ctx.Context(), ctx.AdminId(), requiredPerm)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "admin authorization: authorize")
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusForbidden,
|
|
||||||
"endpoint is not allowed",
|
|
||||||
errors.Errorf(
|
|
||||||
"admin authorization: endpoint '%s' requires '%s' permission, but admin '%d' doesn't have it",
|
|
||||||
ctx.Endpoint(), requiredPerm, ctx.AdminId(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
applicationTokenHeader = "x-application-token"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Authenticator interface {
|
|
||||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Authenticate(authenticator Authenticator) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
token := ctx.Param(applicationTokenHeader)
|
|
||||||
if token == "" {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusUnauthorized,
|
|
||||||
"application token required",
|
|
||||||
errors.New("authenticate: application token required"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := authenticator.Authenticate(ctx.Context(), token)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessagef(err, "authenticate: authenticate")
|
|
||||||
}
|
|
||||||
if !resp.Authenticated {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusUnauthorized,
|
|
||||||
"invalid application token",
|
|
||||||
errors.WithMessage(errors.New(resp.ErrorReason), "authenticate: authenticate"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
ctx.Authenticate(request.AuthData(*resp.AuthData))
|
|
||||||
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Authorizer interface {
|
|
||||||
Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
authData, err := ctx.GetAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "authorize: get auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err := authorizer.Authorize(ctx.Context(), authData.ApplicationId, ctx.Endpoint())
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "authorize: authorize")
|
|
||||||
}
|
|
||||||
if !ok && ctx.IsAdminAuthenticated() {
|
|
||||||
logger.Info(
|
|
||||||
ctx.Context(),
|
|
||||||
"bypassing unauthorized request because it has admin privilege",
|
|
||||||
log.Int("applicationId", authData.ApplicationId),
|
|
||||||
log.Int("adminId", ctx.AdminId()),
|
|
||||||
)
|
|
||||||
return next.Handle(ctx)
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusForbidden,
|
|
||||||
"endpoint is not allowed",
|
|
||||||
errors.Errorf("authorize: endpoint '%s' is not allowed for application '%d'", ctx.Endpoint(), authData.ApplicationId),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DailyLimitChecker interface {
|
|
||||||
IncrementAndCheck(ctx context.Context, applicationId int) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func DailyLimit(checker DailyLimitChecker) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
authData, err := ctx.GetAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "daily limit: get auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err := checker.IncrementAndCheck(ctx.Context(), authData.ApplicationId)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "daily limit: increment and check")
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusTooManyRequests,
|
|
||||||
"daily requests limit has been reached",
|
|
||||||
errors.Errorf("daily limit: daily requests limit has been reached for application '%d'", authData.ApplicationId),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type EntryPointConfig struct {
|
|
||||||
PathPrefix string
|
|
||||||
WithPrefix bool
|
|
||||||
IsGrpcPath bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, cfg EntryPointConfig) http.Handler {
|
|
||||||
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
|
||||||
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
|
|
||||||
ctx := request.NewContext(req, writer, getEndpoint(req, cfg))
|
|
||||||
err := next.Handle(ctx)
|
|
||||||
if err != nil {
|
|
||||||
logger.Error(req.Context(), errors.WithMessage(err, "uncaught error"))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func getEndpoint(req *http.Request, cfg EntryPointConfig) string {
|
|
||||||
if cfg.WithPrefix {
|
|
||||||
return req.URL.Path
|
|
||||||
}
|
|
||||||
if cfg.IsGrpcPath {
|
|
||||||
cfg.PathPrefix += "/"
|
|
||||||
}
|
|
||||||
return strings.TrimPrefix(req.URL.Path, cfg.PathPrefix)
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type HttpError interface {
|
|
||||||
WriteError(w http.ResponseWriter) error
|
|
||||||
}
|
|
||||||
|
|
||||||
func ErrorHandler(logger log.Logger) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
err := next.Handle(ctx)
|
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Error(ctx.Context(), err)
|
|
||||||
|
|
||||||
httpErr, ok := err.(HttpError)
|
|
||||||
if ok {
|
|
||||||
return httpErr.WriteError(ctx.ResponseWriter())
|
|
||||||
}
|
|
||||||
|
|
||||||
return httperrors.
|
|
||||||
New(http.StatusInternalServerError, "internal service error", err).
|
|
||||||
WriteError(ctx.ResponseWriter())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"bytes"
|
|
||||||
"github.com/txix-open/isp-kit/json"
|
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/http/endpoint/buffer"
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
unicodeEscapePrefix = []byte("\\u") // nolint:gochecknoglobals
|
|
||||||
)
|
|
||||||
|
|
||||||
type scSource interface {
|
|
||||||
StatusCode() int
|
|
||||||
}
|
|
||||||
|
|
||||||
type writerWrapper struct {
|
|
||||||
http.ResponseWriter
|
|
||||||
statusCode int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *writerWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
|
||||||
upstream, ok := w.ResponseWriter.(http.Hijacker)
|
|
||||||
if !ok {
|
|
||||||
return nil, nil, errors.New("writerWrapper: upstream writer doesn't implement Hijack")
|
|
||||||
}
|
|
||||||
return upstream.Hijack()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *writerWrapper) StatusCode() int {
|
|
||||||
if w.statusCode == 0 {
|
|
||||||
return http.StatusOK
|
|
||||||
}
|
|
||||||
return w.statusCode
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *writerWrapper) WriteHeader(statusCode int) {
|
|
||||||
w.statusCode = statusCode
|
|
||||||
w.ResponseWriter.WriteHeader(statusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Logger( // nolint:gocognit
|
|
||||||
logger log.Logger,
|
|
||||||
enableRequestLogging bool,
|
|
||||||
enableBodyLogging bool,
|
|
||||||
skipBodyLoggingEndpointPrefixes []string,
|
|
||||||
enableForceUnescapingUnicode bool,
|
|
||||||
) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
if !enableRequestLogging {
|
|
||||||
return next.Handle(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
r := ctx.Request()
|
|
||||||
|
|
||||||
logBodyFromCurrenRequest := enableBodyLogging
|
|
||||||
if logBodyFromCurrenRequest {
|
|
||||||
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
|
||||||
if strings.HasPrefix(ctx.Endpoint(), prefix) {
|
|
||||||
logBodyFromCurrenRequest = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var scSrc scSource
|
|
||||||
var buf *buffer.Buffer
|
|
||||||
if logBodyFromCurrenRequest {
|
|
||||||
buf = buffer.Acquire(ctx.ResponseWriter())
|
|
||||||
defer buffer.Release(buf)
|
|
||||||
|
|
||||||
err := buf.ReadRequestBody(r.Body)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "logger: read request body for logging")
|
|
||||||
}
|
|
||||||
err = r.Body.Close()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "logger: close request reader")
|
|
||||||
}
|
|
||||||
r.Body = io.NopCloser(bytes.NewBuffer(buf.RequestBody()))
|
|
||||||
|
|
||||||
scSrc = buf
|
|
||||||
ctx.SetResponseWriter(buf)
|
|
||||||
} else {
|
|
||||||
writer := &writerWrapper{ResponseWriter: ctx.ResponseWriter()}
|
|
||||||
scSrc = writer
|
|
||||||
ctx.SetResponseWriter(writer)
|
|
||||||
}
|
|
||||||
|
|
||||||
originalPath := r.URL.Path //
|
|
||||||
// can be changed in http proxy
|
|
||||||
err := next.Handle(ctx)
|
|
||||||
|
|
||||||
authData, _ := ctx.GetAuthData()
|
|
||||||
fields := []log.Field{
|
|
||||||
log.String("httpMethod", r.Method),
|
|
||||||
log.String("remoteAddr", r.RemoteAddr),
|
|
||||||
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
|
||||||
log.Int("statusCode", scSrc.StatusCode()),
|
|
||||||
log.String("path", originalPath),
|
|
||||||
log.String("endpoint", ctx.Endpoint()),
|
|
||||||
log.Int("applicationId", authData.ApplicationId),
|
|
||||||
log.Int("adminId", ctx.AdminId()),
|
|
||||||
}
|
|
||||||
|
|
||||||
if logBodyFromCurrenRequest {
|
|
||||||
if enableForceUnescapingUnicode && bytes.Contains(buf.RequestBody(), unicodeEscapePrefix) {
|
|
||||||
fields = append(fields, log.ByteString("request", forceUnescapingUnicode(buf.RequestBody())))
|
|
||||||
} else {
|
|
||||||
fields = append(fields, log.ByteString("request", buf.RequestBody()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fields = append(fields, log.ByteString("response", buf.ResponseBody()))
|
|
||||||
}
|
|
||||||
logger.Debug(ctx.Context(), "log request", fields...)
|
|
||||||
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func forceUnescapingUnicode(data []byte) []byte {
|
|
||||||
var body any
|
|
||||||
err := json.Unmarshal(data, &body)
|
|
||||||
if err != nil {
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
newData, err := json.Marshal(body)
|
|
||||||
if err != nil {
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
return newData
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Handler interface {
|
|
||||||
Handle(ctx *request.Context) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type HandlerFunc func(ctx *request.Context) error
|
|
||||||
|
|
||||||
func (f HandlerFunc) Handle(ctx *request.Context) error {
|
|
||||||
return f(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Middleware func(next Handler) Handler
|
|
||||||
|
|
||||||
// nolint:ireturn
|
|
||||||
func Chain(root Handler, middlewares ...Middleware) Handler {
|
|
||||||
for i := len(middlewares) - 1; i >= 0; i-- {
|
|
||||||
root = middlewares[i](root)
|
|
||||||
}
|
|
||||||
return root
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"isp-gate-service/request"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/log"
|
|
||||||
"github.com/txix-open/isp-kit/requestid"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
requestIdHeader = "x-request-id"
|
|
||||||
)
|
|
||||||
|
|
||||||
func RequestId(forwardClientRequestId bool) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
requestId := requestid.Next()
|
|
||||||
clientRequestId := strings.TrimSpace(ctx.Request().Header.Get(requestIdHeader))
|
|
||||||
|
|
||||||
logFields := make([]log.Field, 0)
|
|
||||||
if clientRequestId != "" {
|
|
||||||
logFields = append(logFields, log.String("clientRequestId", clientRequestId))
|
|
||||||
if forwardClientRequestId {
|
|
||||||
requestId = clientRequestId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logFields = append(logFields, log.String("requestId", requestId))
|
|
||||||
|
|
||||||
context := requestid.ToContext(ctx.Context(), requestId)
|
|
||||||
context = log.ToContext(context, logFields...)
|
|
||||||
|
|
||||||
ctx.SetContext(context)
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package middleware
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Throttler interface {
|
|
||||||
AllowRateLimit(ctx context.Context, applicationId int) (*domain.RateLimitResult, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Throttling(throttler Throttler) Middleware {
|
|
||||||
return func(next Handler) Handler {
|
|
||||||
return HandlerFunc(func(ctx *request.Context) error {
|
|
||||||
authData, err := ctx.GetAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "throttling: get auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := throttler.AllowRateLimit(ctx.Context(), authData.ApplicationId)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "throttling: allow rate limit")
|
|
||||||
}
|
|
||||||
if !result.Allow {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusTooManyRequests,
|
|
||||||
fmt.Sprintf("rate limit has been reached, try after %dms", result.RetryAfter.Milliseconds()),
|
|
||||||
errors.Errorf("throttling: rate limit has been reached for application '%d'", authData.ApplicationId),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return next.Handle(ctx)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
-- +goose Up
|
||||||
|
|
||||||
|
CREATE TABLE snapshot(
|
||||||
|
app_id INTEGER PRIMARY KEY,
|
||||||
|
limit_state JSONB
|
||||||
|
);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP SCHEMA IF EXISTS gate_service CASCADE;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
-- +goose Up
|
||||||
|
|
||||||
|
CREATE TABLE requests
|
||||||
|
(
|
||||||
|
id SERIAL8 PRIMARY KEY,
|
||||||
|
app_id INT4 NOT NULL,
|
||||||
|
method VARCHAR(255) NOT NULL,
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT now()
|
||||||
|
);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP TABLE requests;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- +goose Up
|
||||||
|
|
||||||
|
ALTER TABLE snapshot
|
||||||
|
ADD version BIGINT NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/database"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
DbClient = database.NewRxDbClient(
|
||||||
|
database.WithSchemaEnsuring(),
|
||||||
|
database.WithSchemaAutoInjecting(),
|
||||||
|
database.WithMigrationsEnsuring(),
|
||||||
|
database.WithInitializingErrorHandler(func(err *database.ErrorEvent) {
|
||||||
|
log.Error(log_code.ErrorClientDatabase, err)
|
||||||
|
}))
|
||||||
|
|
||||||
|
SnapshotRep SnapshotRepository = snapshotRepository{rxClient: DbClient}
|
||||||
|
RequestsRep RequestsRepository = requestsRepository{rxClient: DbClient}
|
||||||
|
)
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-pg/pg/v9/orm"
|
||||||
|
"github.com/integration-system/isp-lib/v2/database"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
RequestsRepository interface {
|
||||||
|
Insert([]entity.Request) error
|
||||||
|
}
|
||||||
|
|
||||||
|
requestsRepository struct {
|
||||||
|
DB orm.DB
|
||||||
|
rxClient *database.RxDbClient
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r requestsRepository) Insert(model []entity.Request) error {
|
||||||
|
_, err := r.getDb().Model(&model).Insert()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r requestsRepository) getDb() orm.DB {
|
||||||
|
if r.DB != nil {
|
||||||
|
return r.DB
|
||||||
|
}
|
||||||
|
return r.rxClient.Unsafe()
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-pg/pg/v9"
|
||||||
|
"github.com/integration-system/isp-lib/v2/database"
|
||||||
|
"isp-gate-service/entity"
|
||||||
|
|
||||||
|
"github.com/go-pg/pg/v9/orm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
SnapshotRepository interface {
|
||||||
|
GetByApplication(int32) (*entity.Snapshot, error)
|
||||||
|
Update([]entity.Snapshot) error
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotRepository struct {
|
||||||
|
DB orm.DB
|
||||||
|
rxClient *database.RxDbClient
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (r snapshotRepository) Update(list []entity.Snapshot) error {
|
||||||
|
_, err := r.getDb().Model(&list).OnConflict("(app_id) DO UPDATE").
|
||||||
|
Set("version = EXCLUDED.version").
|
||||||
|
Set("app_id = EXCLUDED.app_id").
|
||||||
|
Set("limit_state = EXCLUDED.limit_state").
|
||||||
|
Where("snapshot.version < EXCLUDED.version").
|
||||||
|
Insert()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r snapshotRepository) GetByApplication(appId int32) (*entity.Snapshot, error) {
|
||||||
|
model := new(entity.Snapshot)
|
||||||
|
if err := r.getDb().Model(model).Where("app_id = ?", appId).Select(); err != nil {
|
||||||
|
if err == pg.ErrNoRows {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
return model, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r snapshotRepository) getDb() orm.DB {
|
||||||
|
if r.DB != nil {
|
||||||
|
return r.DB
|
||||||
|
}
|
||||||
|
return r.rxClient.Unsafe()
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
const (
|
|
||||||
xAdminIdHeader = "x-admin-id"
|
|
||||||
)
|
|
||||||
-166
@@ -1,166 +0,0 @@
|
|||||||
// nolint:gochecknoinits
|
|
||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/isp"
|
|
||||||
"github.com/txix-open/isp-kit/json"
|
|
||||||
"github.com/txix-open/isp-kit/requestid"
|
|
||||||
_ "google.golang.org/genproto/googleapis/rpc/errdetails"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
for httpCode, grpcCode := range codeMap {
|
|
||||||
inverseCodeMap[grpcCode] = httpCode
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
codeMap = map[int]codes.Code{
|
|
||||||
http.StatusOK: codes.OK,
|
|
||||||
http.StatusRequestTimeout: codes.Canceled,
|
|
||||||
http.StatusBadRequest: codes.InvalidArgument,
|
|
||||||
http.StatusGatewayTimeout: codes.DeadlineExceeded,
|
|
||||||
http.StatusNotFound: codes.NotFound,
|
|
||||||
http.StatusConflict: codes.AlreadyExists,
|
|
||||||
http.StatusForbidden: codes.PermissionDenied,
|
|
||||||
http.StatusUnauthorized: codes.Unauthenticated,
|
|
||||||
http.StatusTooManyRequests: codes.ResourceExhausted,
|
|
||||||
http.StatusPreconditionFailed: codes.FailedPrecondition,
|
|
||||||
http.StatusNotImplemented: codes.Unimplemented,
|
|
||||||
http.StatusInternalServerError: codes.Internal,
|
|
||||||
http.StatusServiceUnavailable: codes.Unavailable,
|
|
||||||
}
|
|
||||||
inverseCodeMap = map[codes.Code]int{}
|
|
||||||
)
|
|
||||||
|
|
||||||
type Grpc struct {
|
|
||||||
cli *client.Client
|
|
||||||
skipAuth bool
|
|
||||||
timeout time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGrpc(cli *client.Client, skipAuth bool, timeout time.Duration) Grpc {
|
|
||||||
return Grpc{
|
|
||||||
cli: cli,
|
|
||||||
skipAuth: skipAuth,
|
|
||||||
timeout: timeout,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Grpc) Handle(ctx *request.Context) error {
|
|
||||||
body, err := io.ReadAll(ctx.Request().Body)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "grpc: read body")
|
|
||||||
}
|
|
||||||
|
|
||||||
requestId := requestid.FromContext(ctx.Context())
|
|
||||||
md := metadata.MD{
|
|
||||||
grpc.ProxyMethodNameHeader: {ctx.Endpoint()},
|
|
||||||
requestid.Header: {requestId},
|
|
||||||
}
|
|
||||||
|
|
||||||
if !p.skipAuth {
|
|
||||||
authData, err := ctx.GetAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "get auth data")
|
|
||||||
}
|
|
||||||
md[grpc.SystemIdHeader] = []string{strconv.Itoa(authData.SystemId)}
|
|
||||||
md[grpc.DomainIdHeader] = []string{strconv.Itoa(authData.DomainId)}
|
|
||||||
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(authData.ServiceId)}
|
|
||||||
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(authData.ApplicationId)}
|
|
||||||
if ctx.IsAdminAuthenticated() {
|
|
||||||
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
requestContext := metadata.NewOutgoingContext(ctx.Context(), md)
|
|
||||||
|
|
||||||
requestContext, cancel := context.WithTimeout(requestContext, p.timeout)
|
|
||||||
defer cancel()
|
|
||||||
result, err := p.cli.BackendClient().Request(requestContext, &isp.Message{
|
|
||||||
Body: &isp.Message_BytesBody{BytesBody: body},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return p.handleError(err, ctx.ResponseWriter())
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.writeResponse(http.StatusOK, result.GetBytesBody(), requestId, ctx.ResponseWriter())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Grpc) handleError(err error, w http.ResponseWriter) error {
|
|
||||||
status, ok := status.FromError(err)
|
|
||||||
if !ok {
|
|
||||||
return httperrors.New(
|
|
||||||
http.StatusServiceUnavailable,
|
|
||||||
"upstream is not available",
|
|
||||||
errors.WithMessage(err, "grpc proxy"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
statusCode := p.codeToHttpStatus(status.Code())
|
|
||||||
for _, detail := range status.Details() {
|
|
||||||
switch typeOfDetail := detail.(type) {
|
|
||||||
case *isp.Message:
|
|
||||||
switch {
|
|
||||||
case typeOfDetail.GetBytesBody() != nil:
|
|
||||||
return p.writeResponse(statusCode, typeOfDetail.GetBytesBody(), "", w)
|
|
||||||
case typeOfDetail.GetListBody() != nil:
|
|
||||||
return p.writeProto(statusCode, typeOfDetail.GetListBody(), w)
|
|
||||||
case typeOfDetail.GetStructBody() != nil:
|
|
||||||
return p.writeProto(statusCode, typeOfDetail.GetStructBody(), w)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return p.writeProto(statusCode, typeOfDetail, w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return httperrors.New(
|
|
||||||
statusCode,
|
|
||||||
status.Message(),
|
|
||||||
status.Err(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Grpc) writeProto(statusCode int, proto interface{}, w http.ResponseWriter) error {
|
|
||||||
data, err := json.Marshal(proto)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "marshal grpc details to json")
|
|
||||||
}
|
|
||||||
return p.writeResponse(statusCode, data, "", w)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Grpc) writeResponse(statusCode int, data []byte, requestId string, w http.ResponseWriter) error {
|
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
||||||
if requestId != "" {
|
|
||||||
w.Header().Set(requestid.Header, requestId)
|
|
||||||
}
|
|
||||||
w.WriteHeader(statusCode)
|
|
||||||
_, err := w.Write(data)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "response write")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Grpc) codeToHttpStatus(code codes.Code) int {
|
|
||||||
s, ok := inverseCodeMap[code]
|
|
||||||
if !ok {
|
|
||||||
return http.StatusInternalServerError
|
|
||||||
}
|
|
||||||
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package grpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/proxy/grpc/handlers"
|
||||||
|
)
|
||||||
|
|
||||||
|
type grpcProxy struct {
|
||||||
|
client *backend.RxGrpcClient
|
||||||
|
skipAuth bool
|
||||||
|
skipExistCheck bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProxy(skipAuth, skipExistCheck bool) *grpcProxy {
|
||||||
|
return &grpcProxy{
|
||||||
|
client: backend.NewRxGrpcClient(
|
||||||
|
backend.WithDialOptions(
|
||||||
|
grpc.WithInsecure(),
|
||||||
|
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(int(conf.DefaultMaxResponseBodySize))),
|
||||||
|
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(int(conf.DefaultMaxResponseBodySize))),
|
||||||
|
)),
|
||||||
|
skipAuth: skipAuth,
|
||||||
|
skipExistCheck: skipExistCheck,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *grpcProxy) ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse {
|
||||||
|
return handlers.Handler.Get(ctx).Complete(ctx, path, p.client)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *grpcProxy) Consumer(addr []structure.AddressConfiguration) bool {
|
||||||
|
return p.client.ReceiveAddressList(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *grpcProxy) SkipAuth() bool {
|
||||||
|
return p.skipAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *grpcProxy) SkipExistCheck() bool {
|
||||||
|
return p.skipExistCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *grpcProxy) Close() {
|
||||||
|
_ = p.client.Close()
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
structpb "github.com/golang/protobuf/ptypes/struct"
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
http2 "github.com/integration-system/isp-lib/v2/http"
|
||||||
|
"github.com/integration-system/isp-lib/v2/isp"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"github.com/integration-system/isp-lib/v2/utils"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
jsoniter "github.com/json-iterator/go"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
utils2 "isp-gate-service/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
headerKeyContentDisposition = "Content-Disposition"
|
||||||
|
headerKeyContentType = "Content-Type"
|
||||||
|
headerKeyContentLength = "Content-Length"
|
||||||
|
headerKeyTransferEncoding = "Transfer-Encoding"
|
||||||
|
|
||||||
|
errorMsgInternal = "Internal server error"
|
||||||
|
errorMsgInvalidArg = "Not able to read request body"
|
||||||
|
)
|
||||||
|
|
||||||
|
var json = jsoniter.ConfigFastest
|
||||||
|
|
||||||
|
func convertError(err error) ([]byte, int) {
|
||||||
|
s, ok := status.FromError(err)
|
||||||
|
if !ok {
|
||||||
|
return []byte(utils.ServiceError), http.StatusServiceUnavailable
|
||||||
|
}
|
||||||
|
cfg := config.GetRemote().(*conf.RemoteConfig).GrpcSetting
|
||||||
|
if cfg.EnableOriginalProtoErrors {
|
||||||
|
body, err := proto.Marshal(s.Proto())
|
||||||
|
if err != nil {
|
||||||
|
return []byte(utils.ServiceError), http.StatusServiceUnavailable
|
||||||
|
}
|
||||||
|
return body, http2.CodeToHttpStatus(s.Code())
|
||||||
|
}
|
||||||
|
|
||||||
|
details := s.Details()
|
||||||
|
newDetails := make([]interface{}, len(details))
|
||||||
|
for i, detail := range details {
|
||||||
|
switch typeOfDetail := detail.(type) {
|
||||||
|
case *structpb.Struct:
|
||||||
|
newDetails[i] = utils.ConvertGrpcStructToInterface(
|
||||||
|
&structpb.Value{Kind: &structpb.Value_StructValue{StructValue: typeOfDetail}},
|
||||||
|
)
|
||||||
|
case *isp.Message:
|
||||||
|
newDetails[i] = utils.ConvertGrpcStructToInterface(
|
||||||
|
backend.ResolveBody(typeOfDetail),
|
||||||
|
)
|
||||||
|
default:
|
||||||
|
newDetails[i] = typeOfDetail
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var respBody interface{}
|
||||||
|
if cfg.ProxyGrpcErrorDetails && len(newDetails) > 0 {
|
||||||
|
respBody = newDetails[0]
|
||||||
|
} else {
|
||||||
|
respBody = structure.GrpcError{ErrorMessage: s.Message(), ErrorCode: s.Code().String(), Details: newDetails}
|
||||||
|
}
|
||||||
|
|
||||||
|
errorData, err := json.Marshal(respBody)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(log_code.WarnConvertErrorDataMarshalResponse, err)
|
||||||
|
return []byte(utils.ServiceError), http.StatusServiceUnavailable
|
||||||
|
}
|
||||||
|
return errorData, http2.CodeToHttpStatus(s.Code())
|
||||||
|
}
|
||||||
|
|
||||||
|
func getResponse(msg *isp.Message, err error) ([]byte, int, error) {
|
||||||
|
if err != nil {
|
||||||
|
errorBody, errorStatus := convertError(err)
|
||||||
|
return errorBody, errorStatus, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes := msg.GetBytesBody()
|
||||||
|
if bytes != nil {
|
||||||
|
return bytes, http.StatusOK, nil
|
||||||
|
}
|
||||||
|
result := backend.ResolveBody(msg)
|
||||||
|
data := utils.ConvertGrpcStructToInterface(result)
|
||||||
|
byteResponse, err := json.Marshal(data)
|
||||||
|
return byteResponse, http.StatusOK, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func logHandlerError(typeData, method string, err error) {
|
||||||
|
log.WithMetadata(map[string]interface{}{
|
||||||
|
log_code.MdTypeData: typeData,
|
||||||
|
log_code.MdMethod: method,
|
||||||
|
}).Warn(log_code.WarnProxyGrpcHandler, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func openStream(headers *fasthttp.RequestHeader, method string, timeout time.Duration, client *backend.RxGrpcClient) (
|
||||||
|
isp.BackendService_RequestStreamClient, context.CancelFunc, error) {
|
||||||
|
cli := client.Conn()
|
||||||
|
md, _ := makeMetadata(headers, method)
|
||||||
|
ctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||||
|
stream, err := cli.RequestStream(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return stream, cancel, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeMetadata(r *fasthttp.RequestHeader, method string) (metadata.MD, string) {
|
||||||
|
md := make(metadata.MD, 5)
|
||||||
|
md[utils.ProxyMethodNameHeader] = []string{method}
|
||||||
|
r.VisitAll(func(key, v []byte) {
|
||||||
|
lowerHeader := bytes.ToLower(key)
|
||||||
|
if len(v) > 0 && bytes.HasPrefix(lowerHeader, []byte("x-")) {
|
||||||
|
md[string(lowerHeader)] = []string{string(v)}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return md, method
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkError(err error, ctx *fasthttp.RequestCtx, method string) (bool, bool, domain.ProxyResponse) {
|
||||||
|
var (
|
||||||
|
ok = true
|
||||||
|
eof = false
|
||||||
|
resp = domain.ProxyResponse{}
|
||||||
|
msg = errorMsgInternal
|
||||||
|
code = codes.Internal
|
||||||
|
details []interface{} = nil
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if err != io.EOF {
|
||||||
|
s, itStatus := status.FromError(err)
|
||||||
|
if itStatus {
|
||||||
|
msg = s.Message()
|
||||||
|
code = s.Code()
|
||||||
|
details = s.Details()
|
||||||
|
}
|
||||||
|
logHandlerError(log_code.TypeData.GetFile, method, err)
|
||||||
|
utils2.WriteError(ctx, msg, code, details)
|
||||||
|
resp = domain.Create().SetError(err)
|
||||||
|
ok, eof = false, false
|
||||||
|
} else {
|
||||||
|
ok, eof = true, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok, eof, resp
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
u "github.com/integration-system/isp-lib/v2/utils"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
"mime"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Handler handlerHelper
|
||||||
|
|
||||||
|
type (
|
||||||
|
handlerHelper struct{}
|
||||||
|
|
||||||
|
handler interface {
|
||||||
|
Complete(ctx *fasthttp.RequestCtx, method string, client *backend.RxGrpcClient) domain.ProxyResponse
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (h handlerHelper) Get(ctx *fasthttp.RequestCtx) handler {
|
||||||
|
isMultipart := h.isMultipart(ctx)
|
||||||
|
isExpectFile := string(ctx.Request.Header.Peek(u.ExpectFileHeader)) == "true"
|
||||||
|
|
||||||
|
if isMultipart {
|
||||||
|
ctx.Response.Header.SetContentTypeBytes(utils.JsonContentType)
|
||||||
|
return sendMultipartData
|
||||||
|
}
|
||||||
|
if isExpectFile {
|
||||||
|
return getFile
|
||||||
|
}
|
||||||
|
ctx.Response.Header.SetContentTypeBytes(utils.JsonContentType)
|
||||||
|
return handleJson
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h handlerHelper) isMultipart(ctx *fasthttp.RequestCtx) bool {
|
||||||
|
if !ctx.IsPost() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
v := string(ctx.Request.Header.ContentType())
|
||||||
|
if v == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
d, params, err := mime.ParseMediaType(v)
|
||||||
|
if err != nil || d != "multipart/form-data" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
_, ok := params["boundary"]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/isp"
|
||||||
|
s "github.com/integration-system/isp-lib/v2/streaming"
|
||||||
|
u "github.com/integration-system/isp-lib/v2/utils"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"io"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errInvalidJson = errors.New("invalid json format. Expected object or array")
|
||||||
|
getFile getFileDesc
|
||||||
|
)
|
||||||
|
|
||||||
|
type getFileDesc struct{}
|
||||||
|
|
||||||
|
func (g getFileDesc) Complete(ctx *fasthttp.RequestCtx, method string, client *backend.RxGrpcClient) domain.ProxyResponse {
|
||||||
|
req, err := g.readJsonBody(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return g.formError(ctx, err, method, err.Error(), codes.InvalidArgument)
|
||||||
|
}
|
||||||
|
|
||||||
|
timeout := config.GetRemote().(*conf.RemoteConfig).GrpcSetting.GetStreamInvokeTimeout()
|
||||||
|
stream, cancel, err := openStream(&ctx.Request.Header, method, timeout, client)
|
||||||
|
defer func() {
|
||||||
|
if cancel != nil {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
return g.formError(ctx, err, method, errorMsgInternal, codes.Internal)
|
||||||
|
}
|
||||||
|
|
||||||
|
if req != nil {
|
||||||
|
value := u.ConvertInterfaceToGrpcStruct(req)
|
||||||
|
err := stream.Send(backend.WrapBody(value))
|
||||||
|
if err != nil {
|
||||||
|
return g.formError(ctx, err, method, errorMsgInternal, codes.Internal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := stream.Recv()
|
||||||
|
if err != nil {
|
||||||
|
response, status, err := getResponse(nil, err)
|
||||||
|
if err == nil {
|
||||||
|
ctx.SetStatusCode(status)
|
||||||
|
ctx.SetBody(response)
|
||||||
|
}
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
bf := s.BeginFile{}
|
||||||
|
err = bf.FromMessage(msg)
|
||||||
|
if err != nil {
|
||||||
|
response, status, err := getResponse(nil, err)
|
||||||
|
if err == nil {
|
||||||
|
ctx.SetStatusCode(status)
|
||||||
|
ctx.SetBody(response)
|
||||||
|
}
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
header := &ctx.Response.Header
|
||||||
|
header.Set(headerKeyContentDisposition, fmt.Sprintf("attachment; filename=%s", bf.FileName))
|
||||||
|
header.Set(headerKeyContentType, bf.ContentType)
|
||||||
|
if bf.ContentLength > 0 {
|
||||||
|
header.Set(headerKeyContentLength, strconv.Itoa(int(bf.ContentLength)))
|
||||||
|
} else {
|
||||||
|
header.Set(headerKeyTransferEncoding, "chunked")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = g.write(ctx, stream, method)
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//nolint
|
||||||
|
func (getFileDesc) write(ctx *fasthttp.RequestCtx, stream isp.BackendService_RequestStreamClient, method string) error {
|
||||||
|
for {
|
||||||
|
msg, err := stream.Recv()
|
||||||
|
if s.IsEndOfFile(msg) || err == io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
logHandlerError(log_code.TypeData.GetFile, method, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
bytes := msg.GetBytesBody()
|
||||||
|
if bytes == nil {
|
||||||
|
log.WithMetadata(map[string]interface{}{
|
||||||
|
log_code.MdTypeData: log_code.TypeData.GetFile,
|
||||||
|
log_code.MdMethod: method,
|
||||||
|
}).Errorf(log_code.WarnProxyGrpcHandler, "Method %s. Expected bytes array", method)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
_, err = ctx.Write(bytes)
|
||||||
|
if err != nil {
|
||||||
|
logHandlerError(log_code.TypeData.GetFile, method, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (getFileDesc) readJsonBody(ctx *fasthttp.RequestCtx) (interface{}, error) {
|
||||||
|
requestBody := ctx.Request.Body()
|
||||||
|
var body interface{}
|
||||||
|
if len(requestBody) == 0 {
|
||||||
|
requestBody = []byte("{}")
|
||||||
|
}
|
||||||
|
switch requestBody[0] {
|
||||||
|
case '{':
|
||||||
|
body = make(map[string]interface{})
|
||||||
|
case '[':
|
||||||
|
body = make([]interface{}, 0)
|
||||||
|
default:
|
||||||
|
return nil, errInvalidJson
|
||||||
|
}
|
||||||
|
err := json.Unmarshal(requestBody, &body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return body, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (getFileDesc) formError(ctx *fasthttp.RequestCtx, err error, method, msg string, code codes.Code) domain.ProxyResponse {
|
||||||
|
logHandlerError(log_code.TypeData.GetFile, method, err)
|
||||||
|
utils.WriteError(ctx, msg, code, nil)
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/isp"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var handleJson handleJsonDesc
|
||||||
|
|
||||||
|
type handleJsonDesc struct{}
|
||||||
|
|
||||||
|
func (p handleJsonDesc) Complete(c *fasthttp.RequestCtx, method string, client *backend.RxGrpcClient) domain.ProxyResponse {
|
||||||
|
body := c.Request.Body()
|
||||||
|
|
||||||
|
md, methodName := makeMetadata(&c.Request.Header, method)
|
||||||
|
ctx := metadata.NewOutgoingContext(context.Background(), md)
|
||||||
|
grpcSetting := config.GetRemote().(*conf.RemoteConfig).GrpcSetting
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, grpcSetting.GetSyncInvokeTimeout())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
cli := client.Conn()
|
||||||
|
|
||||||
|
msg, invokerErr := cli.Request(
|
||||||
|
ctx,
|
||||||
|
&isp.Message{
|
||||||
|
Body: &isp.Message_BytesBody{BytesBody: body},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if response, status, err := getResponse(msg, invokerErr); err == nil {
|
||||||
|
c.SetStatusCode(status)
|
||||||
|
c.SetContentTypeBytes(utils.JsonContentType)
|
||||||
|
c.Response.Header.SetContentLength(len(response))
|
||||||
|
_, _ = c.Write(response)
|
||||||
|
return domain.Create().SetRequestBody(body).SetResponseBody(c.Response.Body()).SetError(invokerErr)
|
||||||
|
} else {
|
||||||
|
logHandlerError(log_code.TypeData.JsonContent, methodName, err)
|
||||||
|
utils.WriteError(c, errorMsgInternal, codes.Internal, nil)
|
||||||
|
return domain.Create().SetRequestBody(body).SetResponseBody(c.Response.Body()).SetError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/backend"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
"github.com/integration-system/isp-lib/v2/isp"
|
||||||
|
s "github.com/integration-system/isp-lib/v2/streaming"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
"mime/multipart"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var sendMultipartData sendMultipartDataDesc
|
||||||
|
|
||||||
|
type sendMultipartDataDesc struct{}
|
||||||
|
|
||||||
|
func (h sendMultipartDataDesc) Complete(c *fasthttp.RequestCtx, method string, client *backend.RxGrpcClient) domain.ProxyResponse {
|
||||||
|
cfg := config.GetRemote().(*conf.RemoteConfig).GrpcSetting
|
||||||
|
timeout := cfg.GetStreamInvokeTimeout()
|
||||||
|
|
||||||
|
stream, cancel, err := openStream(&c.Request.Header, method, timeout, client)
|
||||||
|
defer func() {
|
||||||
|
if cancel != nil {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
logHandlerError(log_code.TypeData.SendMultipart, method, err)
|
||||||
|
utils.WriteError(c, errorMsgInternal, codes.Internal, nil)
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
form, err := c.MultipartForm()
|
||||||
|
defer func() {
|
||||||
|
if form != nil {
|
||||||
|
_ = form.RemoveAll()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
logHandlerError(log_code.TypeData.SendMultipart, method, err)
|
||||||
|
utils.WriteError(c, errorMsgInvalidArg, codes.InvalidArgument, nil)
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, proxyResp, ok := h.formResponse(c, stream, form, method)
|
||||||
|
err = stream.CloseSend()
|
||||||
|
if err != nil {
|
||||||
|
logHandlerError(log_code.TypeData.SendMultipart, method, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
arrayBody := strings.Join(resp, ",")
|
||||||
|
_, err = c.WriteString("[" + arrayBody + "]")
|
||||||
|
if err != nil {
|
||||||
|
logHandlerError(log_code.TypeData.SendMultipart, method, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return proxyResp
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h sendMultipartDataDesc) formResponse(c *fasthttp.RequestCtx, stream isp.BackendService_RequestStreamClient,
|
||||||
|
form *multipart.Form, method string) ([]string, domain.ProxyResponse, bool) {
|
||||||
|
formData := make(map[string]interface{}, len(form.Value))
|
||||||
|
for k, v := range form.Value {
|
||||||
|
if len(v) > 0 {
|
||||||
|
formData[k] = v[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
resp = make([]string, 0)
|
||||||
|
buffer = make([]byte, config.GetRemote().(*conf.RemoteConfig).GrpcSetting.GetTransferFileBufferSize())
|
||||||
|
proxyResp domain.ProxyResponse
|
||||||
|
ok = true
|
||||||
|
eof bool
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
for formDataName, files := range form.File {
|
||||||
|
if len(files) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
file := files[0]
|
||||||
|
fileName := file.Filename
|
||||||
|
contentType := file.Header.Get(headerKeyContentType)
|
||||||
|
contentLength := file.Size
|
||||||
|
bf := s.BeginFile{
|
||||||
|
FileName: fileName,
|
||||||
|
FormDataName: formDataName,
|
||||||
|
ContentType: contentType,
|
||||||
|
ContentLength: contentLength,
|
||||||
|
FormData: formData,
|
||||||
|
}
|
||||||
|
err = stream.Send(bf.ToMessage())
|
||||||
|
ok, eof, proxyResp = checkError(err, c, method)
|
||||||
|
if !ok || eof {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := file.Open()
|
||||||
|
ok, eof, proxyResp = checkError(err, c, method)
|
||||||
|
if !ok || eof {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
ok, eof, proxyResp = h.transferFile(f, stream, buffer, c, method)
|
||||||
|
if !ok || eof {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, invokeErr := stream.Recv()
|
||||||
|
ok, eof, proxyResp = checkError(invokeErr, c, method)
|
||||||
|
if !ok || eof {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
response, _, err := getResponse(msg, invokeErr)
|
||||||
|
if err != nil {
|
||||||
|
ok = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
resp = append(resp, string(response))
|
||||||
|
}
|
||||||
|
return resp, proxyResp, ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sendMultipartDataDesc) transferFile(f multipart.File, stream isp.BackendService_RequestStreamClient,
|
||||||
|
buffer []byte, ctx *fasthttp.RequestCtx, method string) (bool, bool, domain.ProxyResponse) {
|
||||||
|
var (
|
||||||
|
ok = true
|
||||||
|
eof bool
|
||||||
|
proxyResp domain.ProxyResponse
|
||||||
|
)
|
||||||
|
for {
|
||||||
|
n, err := f.Read(buffer)
|
||||||
|
if n > 0 {
|
||||||
|
err = stream.Send(&isp.Message{Body: &isp.Message_BytesBody{BytesBody: buffer[:n]}})
|
||||||
|
ok, eof, proxyResp = checkError(err, ctx, method)
|
||||||
|
if !ok || eof {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
ok, eof, proxyResp = checkError(err, ctx, method)
|
||||||
|
if ok && eof {
|
||||||
|
err = stream.Send(s.FileEnd())
|
||||||
|
ok, eof, proxyResp = checkError(err, ctx, method)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok, eof, proxyResp
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package health_check
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
type healthCheckProxy struct {
|
||||||
|
skipAuth bool
|
||||||
|
skipExistCheck bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProxy(skipAuth, skipExistCheck bool) *healthCheckProxy {
|
||||||
|
return &healthCheckProxy{skipAuth: skipAuth, skipExistCheck: skipExistCheck}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *healthCheckProxy) Consumer(addressList []structure.AddressConfiguration) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *healthCheckProxy) ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse {
|
||||||
|
ctx.Response.SetBody(ctx.Request.Body())
|
||||||
|
ctx.Request.SetRequestURI(path)
|
||||||
|
return domain.Create()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *healthCheckProxy) SkipAuth() bool {
|
||||||
|
return p.skipAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *healthCheckProxy) SkipExistCheck() bool {
|
||||||
|
return p.skipExistCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *healthCheckProxy) Close() {
|
||||||
|
|
||||||
|
}
|
||||||
-115
@@ -1,115 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httputil"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/grpc"
|
|
||||||
"github.com/txix-open/isp-kit/requestid"
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
|
||||||
|
|
||||||
// nolint:gomnd
|
|
||||||
var (
|
|
||||||
httpTransport = &http.Transport{
|
|
||||||
Proxy: http.ProxyFromEnvironment,
|
|
||||||
DialContext: defaultTransportDialContext(&net.Dialer{
|
|
||||||
Timeout: 3 * time.Second,
|
|
||||||
KeepAlive: 30 * time.Second,
|
|
||||||
}),
|
|
||||||
ForceAttemptHTTP2: true,
|
|
||||||
MaxIdleConns: 512,
|
|
||||||
MaxIdleConnsPerHost: 32,
|
|
||||||
IdleConnTimeout: 60 * time.Second,
|
|
||||||
TLSHandshakeTimeout: 5 * time.Second,
|
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
type HttpHostManager interface {
|
|
||||||
Next() (string, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Http struct {
|
|
||||||
hostManager HttpHostManager
|
|
||||||
skipAuth bool
|
|
||||||
timeout time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewHttp(hostManager HttpHostManager, skipAuth bool, timeout time.Duration) Http {
|
|
||||||
return Http{
|
|
||||||
hostManager: hostManager,
|
|
||||||
skipAuth: skipAuth,
|
|
||||||
timeout: timeout,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Http) Handle(ctx *request.Context) error {
|
|
||||||
host, err := p.hostManager.Next()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "http: next host")
|
|
||||||
}
|
|
||||||
|
|
||||||
rawUrl := fmt.Sprintf("http://%s", host) // secure HTTP links are reset connection
|
|
||||||
target, err := url.Parse(rawUrl)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "http: parse url")
|
|
||||||
}
|
|
||||||
|
|
||||||
request := ctx.Request()
|
|
||||||
request.URL.Path = ctx.Endpoint()
|
|
||||||
err = setHttpHeaders(ctx, request.Header, p.skipAuth)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
reverseProxy := httputil.NewSingleHostReverseProxy(target)
|
|
||||||
reverseProxy.Transport = httpTransport
|
|
||||||
var resultError error
|
|
||||||
reverseProxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, err error) {
|
|
||||||
resultError = httperrors.New(
|
|
||||||
http.StatusServiceUnavailable,
|
|
||||||
"upstream is not available",
|
|
||||||
errors.WithMessagef(err, "http proxy to %s", host),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
|
||||||
defer cancel()
|
|
||||||
request = request.WithContext(context)
|
|
||||||
reverseProxy.ServeHTTP(ctx.ResponseWriter(), request)
|
|
||||||
|
|
||||||
return resultError
|
|
||||||
}
|
|
||||||
|
|
||||||
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) error {
|
|
||||||
header.Set(requestid.Header, requestid.FromContext(ctx.Context()))
|
|
||||||
if !skipAuth {
|
|
||||||
authData, err := ctx.GetAuthData()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "http: get auth data")
|
|
||||||
}
|
|
||||||
header.Set(grpc.SystemIdHeader, strconv.Itoa(authData.SystemId))
|
|
||||||
header.Set(grpc.DomainIdHeader, strconv.Itoa(authData.DomainId))
|
|
||||||
header.Set(grpc.ServiceIdHeader, strconv.Itoa(authData.ServiceId))
|
|
||||||
header.Set(grpc.ApplicationIdHeader, strconv.Itoa(authData.ApplicationId))
|
|
||||||
if ctx.IsAdminAuthenticated() {
|
|
||||||
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId())) //nolint:canonicalheader
|
|
||||||
} else {
|
|
||||||
header.Del(xAdminIdHeader) //nolint:canonicalheader
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
|
||||||
return dialer.DialContext
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package http
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errNotInitialized = errors.New("http proxy not initialized")
|
||||||
|
)
|
||||||
|
|
||||||
|
type httpProxy struct {
|
||||||
|
client *fasthttp.HostClient
|
||||||
|
skipAuth bool
|
||||||
|
skipExistCheck bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProxy(skipAuth, skipExistCheck bool) *httpProxy {
|
||||||
|
return &httpProxy{client: nil, skipAuth: skipAuth, skipExistCheck: skipExistCheck}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *httpProxy) Consumer(addressList []structure.AddressConfiguration) bool {
|
||||||
|
if len(addressList) == 0 {
|
||||||
|
p.client = nil
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
addresses := make([]string, len(addressList))
|
||||||
|
for key, addr := range addressList {
|
||||||
|
addresses[key] = addr.GetAddress()
|
||||||
|
}
|
||||||
|
|
||||||
|
p.client = &fasthttp.HostClient{
|
||||||
|
Addr: strings.Join(addresses, `,`),
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *httpProxy) ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse {
|
||||||
|
client := p.client
|
||||||
|
if client == nil {
|
||||||
|
log.Error(log_code.ErrorClientHttp, errNotInitialized)
|
||||||
|
utils.WriteError(ctx, errNotInitialized.Error(), codes.Internal, nil)
|
||||||
|
return domain.Create().
|
||||||
|
SetRequestBody(ctx.Request.Body()).
|
||||||
|
SetResponseBody(ctx.Response.Body()).
|
||||||
|
SetError(errNotInitialized)
|
||||||
|
}
|
||||||
|
|
||||||
|
req := &ctx.Request
|
||||||
|
res := &ctx.Response
|
||||||
|
req.URI().SetPath("/" + path)
|
||||||
|
|
||||||
|
if addr, _, err := net.SplitHostPort(ctx.RemoteAddr().String()); err == nil {
|
||||||
|
req.Header.Add("X-Forwarded-For", addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := client.Do(req, res)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(log_code.ErrorClientHttp, err)
|
||||||
|
}
|
||||||
|
return domain.Create().
|
||||||
|
SetRequestBody(ctx.Request.Body()).
|
||||||
|
SetResponseBody(ctx.Response.Body()).
|
||||||
|
SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *httpProxy) SkipAuth() bool {
|
||||||
|
return p.skipAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *httpProxy) SkipExistCheck() bool {
|
||||||
|
return p.skipExistCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *httpProxy) Close() {
|
||||||
|
p.client = nil
|
||||||
|
}
|
||||||
+168
@@ -0,0 +1,168 @@
|
|||||||
|
package proxy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/proxy/grpc"
|
||||||
|
"isp-gate-service/proxy/health_check"
|
||||||
|
"isp-gate-service/proxy/http"
|
||||||
|
"isp-gate-service/proxy/websocket"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
store = make([]storeItem, 0)
|
||||||
|
locationsStore = make([]storeItem, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
httpProtocol = "http"
|
||||||
|
websocketProtocol = "websocket"
|
||||||
|
grpcProtocol = "grpc"
|
||||||
|
healthCheckProtocol = "healthсheck"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Proxy interface {
|
||||||
|
ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse
|
||||||
|
Consumer([]structure.AddressConfiguration) bool
|
||||||
|
SkipAuth() bool
|
||||||
|
SkipExistCheck() bool
|
||||||
|
Close()
|
||||||
|
}
|
||||||
|
storeItem struct {
|
||||||
|
pathPrefix string
|
||||||
|
paths []string // if pathPrefix is empty
|
||||||
|
proxy Proxy
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitProxies(locations []conf.Location) (map[string]func([]structure.AddressConfiguration) bool, error) {
|
||||||
|
locationsByTargetModule := conf.GetLocationsByTargetModule(locations)
|
||||||
|
requiredModules := make(map[string]func([]structure.AddressConfiguration) bool)
|
||||||
|
|
||||||
|
for targetModule, locations := range locationsByTargetModule {
|
||||||
|
consumerStorage := make([]func([]structure.AddressConfiguration) bool, len(locations))
|
||||||
|
for i, location := range locations {
|
||||||
|
if location.PathPrefix[0] != '/' {
|
||||||
|
return nil, errors.Errorf("path must begin with '/' in path '%s'", location.PathPrefix)
|
||||||
|
}
|
||||||
|
p, err := makeProxy(location.Protocol, location.SkipAuth, location.SkipExistCheck)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
store = append(store, storeItem{
|
||||||
|
pathPrefix: location.PathPrefix,
|
||||||
|
proxy: p,
|
||||||
|
})
|
||||||
|
consumerStorage[i] = p.Consumer
|
||||||
|
}
|
||||||
|
requiredModules[targetModule] = aggregateConsumers(consumerStorage...)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(store, func(i, j int) bool {
|
||||||
|
return store[i].pathPrefix > store[j].pathPrefix
|
||||||
|
})
|
||||||
|
locationsStore = store
|
||||||
|
return requiredModules, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitProxiesFromConfigs(configs structure.RoutingConfig) error {
|
||||||
|
store = locationsStore
|
||||||
|
for _, config := range configs { //nolint
|
||||||
|
ip := config.Address.IP
|
||||||
|
|
||||||
|
for protocol, info := range config.HandlersInfo {
|
||||||
|
p, err := makeProxy(protocol, info.SkipAuth, info.SkipExistCheck)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "bad dynamic config in service %s with protocol %s", config.ModuleName, protocol)
|
||||||
|
}
|
||||||
|
addressConfig := []structure.AddressConfiguration{{
|
||||||
|
Port: info.Port,
|
||||||
|
IP: ip,
|
||||||
|
}}
|
||||||
|
p.Consumer(addressConfig)
|
||||||
|
item := storeItem{
|
||||||
|
pathPrefix: "",
|
||||||
|
proxy: p,
|
||||||
|
paths: getPathsFromEndpoints(info.Endpoints),
|
||||||
|
}
|
||||||
|
store = append(store, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPathsFromEndpoints(endpoints []structure.EndpointDescriptor) []string {
|
||||||
|
paths := make([]string, len(endpoints)-1)
|
||||||
|
for i := range endpoints {
|
||||||
|
endpoint := endpoints[i]
|
||||||
|
paths = append(paths, endpoint.Path)
|
||||||
|
}
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeProxy(protocol string, skipAuth, skipExistCheck bool) (Proxy, error) {
|
||||||
|
var proxy Proxy
|
||||||
|
switch protocol {
|
||||||
|
case httpProtocol:
|
||||||
|
proxy = http.NewProxy(skipAuth, skipExistCheck)
|
||||||
|
case grpcProtocol:
|
||||||
|
proxy = grpc.NewProxy(skipAuth, skipExistCheck)
|
||||||
|
case healthCheckProtocol:
|
||||||
|
proxy = health_check.NewProxy(skipAuth, skipExistCheck)
|
||||||
|
case websocketProtocol:
|
||||||
|
proxy = websocket.NewProxy(skipAuth, skipExistCheck)
|
||||||
|
default:
|
||||||
|
return nil, errors.Errorf("unknown protocol '%s'", protocol)
|
||||||
|
}
|
||||||
|
|
||||||
|
return proxy, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Find(path string) (Proxy, string) {
|
||||||
|
for _, item := range store {
|
||||||
|
if item.pathPrefix != "" {
|
||||||
|
if strings.HasPrefix(path, item.pathPrefix) {
|
||||||
|
return item.proxy, getPathWithoutPrefix(path, item.pathPrefix)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, iPath := range item.paths {
|
||||||
|
if path == iPath {
|
||||||
|
return item.proxy, path
|
||||||
|
}
|
||||||
|
if path == "/"+iPath {
|
||||||
|
return item.proxy, path[1:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func Close() {
|
||||||
|
for _, p := range store {
|
||||||
|
p.proxy.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPathWithoutPrefix(path, prefix string) string {
|
||||||
|
s := strings.TrimPrefix(path, prefix)
|
||||||
|
if len(s) > 0 && s[0] == '/' {
|
||||||
|
return s[1:]
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func aggregateConsumers(consumers ...func([]structure.AddressConfiguration) bool) func([]structure.AddressConfiguration) bool {
|
||||||
|
return func(list []structure.AddressConfiguration) bool {
|
||||||
|
for _, consumer := range consumers {
|
||||||
|
consumer(list)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package proxy //nolint
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_getPathWithoutPrefix(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
path string
|
||||||
|
prefix string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{name: "#1", args: args{
|
||||||
|
path: "/api/some/11/22",
|
||||||
|
prefix: "/api/some",
|
||||||
|
}, want: "11/22"},
|
||||||
|
{name: "#2", args: args{
|
||||||
|
path: "/api/service/group/method",
|
||||||
|
prefix: "/api",
|
||||||
|
}, want: "service/group/method"},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
tt := test
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if got := getPathWithoutPrefix(tt.args.path, tt.args.prefix); got != tt.want {
|
||||||
|
t.Errorf("getPathWithoutPrefix() = %v, want %v", got, tt.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RoundRobinAddrs struct {
|
||||||
|
mu *sync.Mutex
|
||||||
|
addrs []structure.AddressConfiguration
|
||||||
|
index int
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *RoundRobinAddrs) Get() structure.AddressConfiguration {
|
||||||
|
u.mu.Lock()
|
||||||
|
u.index = (u.index + 1) % len(u.addrs)
|
||||||
|
addr := u.addrs[u.index]
|
||||||
|
u.mu.Unlock()
|
||||||
|
return addr
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRoundRobinAddrs(addrs []structure.AddressConfiguration) *RoundRobinAddrs {
|
||||||
|
return &RoundRobinAddrs{
|
||||||
|
addrs: addrs,
|
||||||
|
index: -1,
|
||||||
|
mu: new(sync.Mutex),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
package websocket
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
|
"net/url"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/fasthttp/websocket"
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"isp-gate-service/domain"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"isp-gate-service/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
writeBufSize = 4 << 10
|
||||||
|
readBufSize = 4 << 10
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errNoAddresses = errors.New("no available address")
|
||||||
|
pool = &sync.Pool{New: func() interface{} {
|
||||||
|
buf := make([]byte, readBufSize)
|
||||||
|
return &buf
|
||||||
|
}}
|
||||||
|
)
|
||||||
|
|
||||||
|
// used to filter client request headers
|
||||||
|
//
|
||||||
|
var forbiddenDuplicateHeaders = map[string]struct{}{
|
||||||
|
"Upgrade": {},
|
||||||
|
"Connection": {},
|
||||||
|
"Sec-Websocket-Key": {},
|
||||||
|
"Sec-Websocket-Version": {},
|
||||||
|
"Sec-Websocket-Extensions": {},
|
||||||
|
"Sec-Websocket-Protocol": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
var upgrader = websocket.FastHTTPUpgrader{
|
||||||
|
ReadBufferSize: readBufSize,
|
||||||
|
WriteBufferSize: writeBufSize,
|
||||||
|
CheckOrigin: func(ctx *fasthttp.RequestCtx) bool {
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type websocketProxy struct {
|
||||||
|
addrs *RoundRobinAddrs
|
||||||
|
skipAuth bool
|
||||||
|
skipExistCheck bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProxy(skipAuth, skipExistCheck bool) *websocketProxy {
|
||||||
|
return &websocketProxy{addrs: nil, skipAuth: skipAuth, skipExistCheck: skipExistCheck}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *websocketProxy) Consumer(addressList []structure.AddressConfiguration) bool {
|
||||||
|
if len(addressList) == 0 {
|
||||||
|
p.addrs = nil
|
||||||
|
} else {
|
||||||
|
p.addrs = NewRoundRobinAddrs(addressList)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *websocketProxy) ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse {
|
||||||
|
addrs := p.addrs
|
||||||
|
if addrs == nil {
|
||||||
|
msg := errNoAddresses
|
||||||
|
log.Error(log_code.ErrorWebsocketProxy, msg)
|
||||||
|
utils.WriteError(ctx, msg.Error(), codes.Internal, nil)
|
||||||
|
return domain.Create().
|
||||||
|
SetRequestBody(ctx.Request.Body()).
|
||||||
|
SetResponseBody(ctx.Response.Body()).
|
||||||
|
SetError(errNoAddresses)
|
||||||
|
}
|
||||||
|
|
||||||
|
reqHeaders := fasthttp.RequestHeader{}
|
||||||
|
ctx.Request.Header.CopyTo(&reqHeaders)
|
||||||
|
reqHost := string(ctx.Request.URI().Host())
|
||||||
|
reqScheme := string(ctx.Request.URI().Scheme())
|
||||||
|
|
||||||
|
if addr, _, err := net.SplitHostPort(ctx.RemoteAddr().String()); err == nil {
|
||||||
|
reqHeaders.Add("X-Forwarded-For", addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
err := upgrader.Upgrade(ctx, func(incomingConn *websocket.Conn) {
|
||||||
|
outgoingDialer := websocket.Dialer{
|
||||||
|
ReadBufferSize: readBufSize,
|
||||||
|
WriteBufferSize: writeBufSize,
|
||||||
|
NetDial: net.Dial,
|
||||||
|
}
|
||||||
|
|
||||||
|
addr := addrs.Get()
|
||||||
|
uri := ctx.Request.URI()
|
||||||
|
uri.SetSchemeBytes([]byte("ws"))
|
||||||
|
uri.SetHost(addr.GetAddress())
|
||||||
|
uri.SetPath("/" + path)
|
||||||
|
header := http.Header{}
|
||||||
|
|
||||||
|
reqHeaders.VisitAll(func(key, value []byte) {
|
||||||
|
keyStr := string(key)
|
||||||
|
if _, forbidden := forbiddenDuplicateHeaders[keyStr]; !forbidden {
|
||||||
|
header.Add(keyStr, string(value))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
cookie := make([]*http.Cookie, 0)
|
||||||
|
reqHeaders.VisitAllCookie(func(key, value []byte) {
|
||||||
|
cookie = append(cookie, &http.Cookie{Domain: reqHost, Name: string(key), Value: string(value)})
|
||||||
|
})
|
||||||
|
cookies := &cookiejar.Jar{}
|
||||||
|
cookies.SetCookies(&url.URL{Host: reqHost, Scheme: reqScheme}, cookie)
|
||||||
|
outgoingDialer.Jar = cookies
|
||||||
|
|
||||||
|
//nolint
|
||||||
|
outgoingConn, _, err := outgoingDialer.Dial(uri.String(), header)
|
||||||
|
if err == nil {
|
||||||
|
go func() {
|
||||||
|
_ = p.proxyConn(outgoingConn, incomingConn)
|
||||||
|
}()
|
||||||
|
_ = p.proxyConn(incomingConn, outgoingConn)
|
||||||
|
} else {
|
||||||
|
log.Errorf(log_code.ErrorWebsocketProxy, "unable to connect to service %s: %v", uri.String(), err)
|
||||||
|
_ = incomingConn.Close()
|
||||||
|
_ = outgoingConn.Close()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return domain.Create().SetError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *websocketProxy) SkipAuth() bool {
|
||||||
|
return p.skipAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *websocketProxy) SkipExistCheck() bool {
|
||||||
|
return p.skipExistCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *websocketProxy) Close() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *websocketProxy) proxyConn(from, to *websocket.Conn) error {
|
||||||
|
buf := pool.Get().(*[]byte)
|
||||||
|
defer func() {
|
||||||
|
_ = from.Close()
|
||||||
|
_ = to.Close()
|
||||||
|
pool.Put(buf)
|
||||||
|
}()
|
||||||
|
for {
|
||||||
|
msgType, reader, err := from.NextReader()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
writer, err := to.NextWriter(msgType)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := io.CopyBuffer(writer, reader, *buf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := writer.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-71
@@ -1,71 +0,0 @@
|
|||||||
package proxy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/tomakado/websocketproxy"
|
|
||||||
"isp-gate-service/httperrors"
|
|
||||||
"isp-gate-service/request"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Ws struct {
|
|
||||||
hostManager HttpHostManager
|
|
||||||
skipAuth bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewWs(hostManager HttpHostManager, skipAuth bool) Ws {
|
|
||||||
return Ws{
|
|
||||||
hostManager: hostManager,
|
|
||||||
skipAuth: skipAuth,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//nolint:gomnd
|
|
||||||
func (ws Ws) Handle(ctx *request.Context) error {
|
|
||||||
host, err := ws.hostManager.Next()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "ws: next host")
|
|
||||||
}
|
|
||||||
|
|
||||||
rawUrl := fmt.Sprintf("ws://%s", host)
|
|
||||||
target, err := url.Parse(rawUrl)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "ws: parse url")
|
|
||||||
}
|
|
||||||
|
|
||||||
request := ctx.Request()
|
|
||||||
request.URL.Path = ctx.Endpoint()
|
|
||||||
|
|
||||||
var resultError error
|
|
||||||
proxy := websocketproxy.NewProxy(target)
|
|
||||||
proxy.Director = func(incoming *http.Request, out http.Header) {
|
|
||||||
_ = setHttpHeaders(ctx, out, ws.skipAuth)
|
|
||||||
}
|
|
||||||
proxy.Upgrader = &websocket.Upgrader{
|
|
||||||
HandshakeTimeout: 5 * time.Second,
|
|
||||||
ReadBufferSize: 1024,
|
|
||||||
WriteBufferSize: 1024,
|
|
||||||
WriteBufferPool: nil,
|
|
||||||
Subprotocols: nil,
|
|
||||||
Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) {
|
|
||||||
resultError = httperrors.New(
|
|
||||||
http.StatusServiceUnavailable,
|
|
||||||
"upstream is not available",
|
|
||||||
errors.WithMessagef(reason, "ws proxy to %s", host),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
CheckOrigin: func(r *http.Request) bool {
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
EnableCompression: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy.ServeHTTP(ctx.ResponseWriter(), ctx.Request())
|
|
||||||
|
|
||||||
return resultError
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package redis
|
||||||
|
|
||||||
|
import (
|
||||||
|
rd "github.com/integration-system/isp-lib/v2/redis"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Client = rd.NewRxClient(
|
||||||
|
rd.WithInitHandler(func(c *rd.Client, err error) {
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(log_code.ErrorClientRedis, err)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
)
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
// nolint:dupl
|
|
||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
adminAuthenticate = "admin/secure/authenticate"
|
|
||||||
adminAuthorize = "admin/secure/authorize"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Admin struct {
|
|
||||||
cli *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAdmin(cli *client.Client) Admin {
|
|
||||||
return Admin{cli: cli}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
|
||||||
resp := domain.AdminAuthenticateResponse{}
|
|
||||||
err := r.cli.Invoke(adminAuthenticate).
|
|
||||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
Do(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessagef(err, "grpc client invoke %s", adminAuthenticate)
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Admin) Authorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
|
||||||
resp := domain.AdminAuthorizeResponse{}
|
|
||||||
err := r.cli.Invoke(adminAuthorize).
|
|
||||||
JsonRequestBody(domain.AdminAuthorizeRequest{AdminId: adminId, Permission: permission}).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
Do(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "grpc client invoke: %s", adminAuthorize)
|
|
||||||
}
|
|
||||||
return resp.Authorized, nil
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/json"
|
|
||||||
"isp-gate-service/cache"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuthenticationCache struct {
|
|
||||||
cache *cache.Cache
|
|
||||||
duration time.Duration
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAuthenticationCache(duration time.Duration) AuthenticationCache {
|
|
||||||
return AuthenticationCache{
|
|
||||||
duration: duration,
|
|
||||||
cache: cache.New(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r AuthenticationCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
|
||||||
data, ok := r.cache.Get(token)
|
|
||||||
if !ok {
|
|
||||||
return nil, domain.ErrAuthenticationCacheMiss
|
|
||||||
}
|
|
||||||
|
|
||||||
result := domain.AuthData{}
|
|
||||||
err := json.Unmarshal(data, &result)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
return &result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r AuthenticationCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
|
||||||
value, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "json marshal auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
r.cache.Set(token, value, r.duration)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"isp-gate-service/cache"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuthorizationCache struct {
|
|
||||||
duration time.Duration
|
|
||||||
cache *cache.Cache
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAuthorizationCache(duration time.Duration) *AuthorizationCache {
|
|
||||||
return &AuthorizationCache{
|
|
||||||
duration: duration,
|
|
||||||
cache: cache.New(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r AuthorizationCache) Get(ctx context.Context, id int, endpoint string) (bool, error) {
|
|
||||||
key := r.key(id, endpoint)
|
|
||||||
_, ok := r.cache.Get(key)
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r AuthorizationCache) SetAuthorized(ctx context.Context, id int, endpoint string) error {
|
|
||||||
key := r.key(id, endpoint)
|
|
||||||
r.cache.Set(key, nil, r.duration)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r AuthorizationCache) key(id int, endpoint string) string {
|
|
||||||
return fmt.Sprintf("%d:%s", id, endpoint)
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DailyLimit struct {
|
|
||||||
cli redis.UniversalClient
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDailyLimit(cli redis.UniversalClient) DailyLimit {
|
|
||||||
return DailyLimit{
|
|
||||||
cli: cli,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r DailyLimit) Increment(ctx context.Context, applicationId int, today time.Time) (int64, error) {
|
|
||||||
key := r.key(applicationId, today)
|
|
||||||
value, err := r.cli.Incr(ctx, key).Result()
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.WithMessage(err, "incr")
|
|
||||||
}
|
|
||||||
|
|
||||||
if value == 1 {
|
|
||||||
err := r.cli.ExpireNX(ctx, key, 24*time.Hour).Err() //nolint:mnd,gomnd
|
|
||||||
if err != nil {
|
|
||||||
return 0, errors.WithMessage(err, "expire nx")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r DailyLimit) key(applicationId int, today time.Time) string {
|
|
||||||
y, m, d := today.Date()
|
|
||||||
return fmt.Sprintf("daily_limit:%d:%d-%d-%d", applicationId, y, m, d)
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
// nolint:dupl
|
|
||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/txix-open/isp-kit/grpc/client"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
authenticate = "system/secure/authenticate"
|
|
||||||
authorize = "system/secure/authorize"
|
|
||||||
)
|
|
||||||
|
|
||||||
type System struct {
|
|
||||||
cli *client.Client
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSystem(cli *client.Client) System {
|
|
||||||
return System{
|
|
||||||
cli: cli,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r System) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
|
||||||
resp := domain.AuthenticateResponse{}
|
|
||||||
err := r.cli.Invoke(authenticate).
|
|
||||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
Do(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessagef(err, "grpc client invoke: %s", authenticate)
|
|
||||||
}
|
|
||||||
return &resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r System) Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
|
||||||
resp := domain.AuthorizeResponse{}
|
|
||||||
err := r.cli.Invoke(authorize).
|
|
||||||
JsonRequestBody(domain.AuthorizeRequest{ApplicationId: applicationId, Endpoint: endpoint}).
|
|
||||||
JsonResponseBody(&resp).
|
|
||||||
Do(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "grpc client invoke: %s", authorize)
|
|
||||||
}
|
|
||||||
return resp.Authorized, nil
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package repository
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/go-redis/redis_rate/v10"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Throttling struct {
|
|
||||||
cli *redis_rate.Limiter
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewThrottling(cli redis.UniversalClient) Throttling {
|
|
||||||
return Throttling{
|
|
||||||
cli: redis_rate.NewLimiter(cli),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Throttling) IsAllowRequestPerSecond(ctx context.Context, applicationId int, rate int) (*domain.RateLimitResult, error) {
|
|
||||||
result, err := r.cli.Allow(ctx, r.key(applicationId), redis_rate.PerSecond(rate))
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "redis_rate/Allow")
|
|
||||||
}
|
|
||||||
return &domain.RateLimitResult{
|
|
||||||
Allow: result.Allowed > 0,
|
|
||||||
Remaining: result.Remaining,
|
|
||||||
RetryAfter: result.RetryAfter,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r Throttling) key(applicationId int) string {
|
|
||||||
return fmt.Sprintf("throttling:%d", applicationId)
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package unused
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
"github.com/txix-open/isp-kit/json"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RedisAuthCache struct {
|
|
||||||
cli redis.UniversalClient
|
|
||||||
duration time.Duration
|
|
||||||
db int
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRedisAuthCache(cli redis.UniversalClient, duration time.Duration, db int) RedisAuthCache {
|
|
||||||
return RedisAuthCache{
|
|
||||||
cli: cli,
|
|
||||||
duration: duration,
|
|
||||||
db: db,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
|
||||||
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
|
||||||
p.Select(ctx, r.db)
|
|
||||||
p.Get(ctx, token)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil && !errors.Is(err, redis.Nil) {
|
|
||||||
return nil, errors.WithMessage(err, "pipelined")
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := results[1].(*redis.StringCmd).Result() // nolint: forcetypeassert
|
|
||||||
if errors.Is(err, redis.Nil) {
|
|
||||||
return nil, domain.ErrAuthenticationCacheMiss
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "get")
|
|
||||||
}
|
|
||||||
|
|
||||||
result := domain.AuthData{}
|
|
||||||
err = json.Unmarshal([]byte(data), &result)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
return &result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RedisAuthCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
|
||||||
value, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "json marshal auth data")
|
|
||||||
}
|
|
||||||
|
|
||||||
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
|
||||||
p.Select(ctx, r.db)
|
|
||||||
p.SetEx(ctx, token, string(value), r.duration)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "pipelined")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = results[1].Err()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "set ex")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
package unused
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/redis/go-redis/v9"
|
|
||||||
)
|
|
||||||
|
|
||||||
type RedisAuthzCache struct {
|
|
||||||
cli redis.UniversalClient
|
|
||||||
duration time.Duration
|
|
||||||
db int
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRedisAuthzCache(cli redis.UniversalClient, duration time.Duration, db int) *RedisAuthzCache {
|
|
||||||
return &RedisAuthzCache{
|
|
||||||
cli: cli,
|
|
||||||
duration: duration,
|
|
||||||
db: db,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RedisAuthzCache) Get(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
|
||||||
result, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
|
||||||
p.Select(ctx, r.db)
|
|
||||||
p.Get(ctx, r.key(applicationId, endpoint))
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil && !errors.Is(err, redis.Nil) {
|
|
||||||
return false, errors.WithMessage(err, "pipelined")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = result[1].(*redis.StringCmd).Result() // nolint: forcetypeassert
|
|
||||||
if errors.Is(err, redis.Nil) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "get")
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RedisAuthzCache) SetAuthorized(ctx context.Context, applicationId int, endpoint string) error {
|
|
||||||
result, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
|
||||||
p.Select(ctx, r.db)
|
|
||||||
p.SetEx(ctx, r.key(applicationId, endpoint), "authorized", r.duration)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "pipelined")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = result[1].Err()
|
|
||||||
if err != nil {
|
|
||||||
return errors.WithMessage(err, "set ex")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RedisAuthzCache) key(applicationId int, endpoint string) string {
|
|
||||||
return fmt.Sprintf("%d:%s", applicationId, endpoint)
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package request
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
ErrNotAuthenticated = errors.New("not authenticated")
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuthData struct {
|
|
||||||
SystemId int
|
|
||||||
DomainId int
|
|
||||||
ServiceId int
|
|
||||||
ApplicationId int
|
|
||||||
}
|
|
||||||
|
|
||||||
type Context struct {
|
|
||||||
request *http.Request
|
|
||||||
responseWriter http.ResponseWriter
|
|
||||||
|
|
||||||
endpoint string
|
|
||||||
|
|
||||||
authenticated bool
|
|
||||||
authData *AuthData
|
|
||||||
|
|
||||||
adminAuthenticated bool
|
|
||||||
adminId int
|
|
||||||
adminToken string
|
|
||||||
|
|
||||||
queryParams map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewContext(request *http.Request, response http.ResponseWriter, endpoint string) *Context {
|
|
||||||
return &Context{
|
|
||||||
request: request,
|
|
||||||
responseWriter: response,
|
|
||||||
endpoint: endpoint,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) Request() *http.Request {
|
|
||||||
return c.request
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) ResponseWriter() http.ResponseWriter {
|
|
||||||
return c.responseWriter
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) SetResponseWriter(writer http.ResponseWriter) {
|
|
||||||
c.responseWriter = writer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) Endpoint() string {
|
|
||||||
return c.endpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) Authenticate(authData AuthData) {
|
|
||||||
c.authenticated = true
|
|
||||||
c.authData = &authData
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) GetAuthData() (AuthData, error) {
|
|
||||||
if !c.authenticated {
|
|
||||||
return AuthData{}, ErrNotAuthenticated
|
|
||||||
}
|
|
||||||
return *c.authData, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) IsAdminAuthenticated() bool {
|
|
||||||
return c.adminAuthenticated
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) AdminId() int {
|
|
||||||
return c.adminId
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) AdminToken() string {
|
|
||||||
return c.adminToken
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) AuthenticateAdmin(adminId int, adminToken string) {
|
|
||||||
c.adminAuthenticated = true
|
|
||||||
c.adminId = adminId
|
|
||||||
c.adminToken = adminToken
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) Context() context.Context {
|
|
||||||
return c.request.Context()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) SetContext(ctx context.Context) {
|
|
||||||
c.request = c.request.WithContext(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Context) Param(name string) string {
|
|
||||||
value := c.request.Header.Get(name)
|
|
||||||
if value != "" {
|
|
||||||
return strings.TrimSpace(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.queryParams == nil {
|
|
||||||
query := c.request.URL.Query()
|
|
||||||
c.queryParams = map[string]string{}
|
|
||||||
for key, values := range query {
|
|
||||||
if len(values) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c.queryParams[strings.ToLower(key)] = values[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
value = c.queryParams[strings.ToLower(name)]
|
|
||||||
|
|
||||||
return strings.TrimSpace(value)
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package routes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/txix-open/isp-kit/cluster"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Routes struct {
|
|
||||||
innerEndpoints map[string]bool
|
|
||||||
requiredPermissions map[string]string
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRoutes() *Routes {
|
|
||||||
return &Routes{
|
|
||||||
innerEndpoints: make(map[string]bool),
|
|
||||||
requiredPermissions: make(map[string]string),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig) error {
|
|
||||||
newInnerMethods := make(map[string]bool)
|
|
||||||
newRequiredPermissions := make(map[string]string)
|
|
||||||
for _, backend := range routes {
|
|
||||||
for _, v := range backend.Endpoints {
|
|
||||||
if v.Inner {
|
|
||||||
newInnerMethods[v.Path] = true
|
|
||||||
}
|
|
||||||
perm, ok := cluster.GetRequiredAdminPermission(v)
|
|
||||||
if ok {
|
|
||||||
newRequiredPermissions[v.Path] = perm
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s.innerEndpoints = newInnerMethods
|
|
||||||
s.requiredPermissions = newRequiredPermissions
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Routes) IsInnerEndpoint(path string) bool {
|
|
||||||
return s.innerEndpoints[path]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Routes) RequiredAdminPermission(path string) (string, bool) {
|
|
||||||
perm, ok := s.requiredPermissions[path]
|
|
||||||
return perm, ok
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package routing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/isp-lib/v2/structure"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
InnerMethods = make(map[string]bool)
|
||||||
|
AllMethods = make(map[string]bool)
|
||||||
|
AuthUserMethods = make(map[string]bool)
|
||||||
|
)
|
||||||
|
|
||||||
|
func InitRoutes(configs structure.RoutingConfig) {
|
||||||
|
newAddressMap := make(map[string]bool)
|
||||||
|
newInnerAddressMap := make(map[string]bool)
|
||||||
|
newAuthUserAddressMap := make(map[string]bool)
|
||||||
|
for i := range configs {
|
||||||
|
backend := &configs[i]
|
||||||
|
if backend.Address.IP == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if backend.HandlersInfo == nil {
|
||||||
|
if len(backend.Endpoints) == 0 || backend.Address.Port == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
addEndpointsToMaps(backend.Endpoints, newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||||
|
} else {
|
||||||
|
for _, info := range backend.HandlersInfo {
|
||||||
|
if info.Port != "" {
|
||||||
|
addEndpointsToMaps(info.Endpoints, newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AllMethods = newAddressMap
|
||||||
|
InnerMethods = newInnerAddressMap
|
||||||
|
AuthUserMethods = newAuthUserAddressMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func addEndpointsToMaps(endpoints []structure.EndpointDescriptor, newAddressMap map[string]bool, newInnerAddressMap map[string]bool, newAuthUserAddressMap map[string]bool) { //nolint
|
||||||
|
for _, el := range endpoints {
|
||||||
|
newAddressMap[el.Path] = true
|
||||||
|
if el.Inner {
|
||||||
|
newInnerAddressMap[el.Path] = true
|
||||||
|
}
|
||||||
|
if el.UserAuthRequired {
|
||||||
|
newAuthUserAddressMap[el.Path] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/integration-system/go-cmp/cmp"
|
||||||
|
"github.com/integration-system/isp-lib/v2/config"
|
||||||
|
log "github.com/integration-system/isp-log"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"isp-gate-service/conf"
|
||||||
|
"isp-gate-service/handler"
|
||||||
|
"isp-gate-service/log_code"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaultTimeout = 60 * time.Second
|
||||||
|
|
||||||
|
var Http = &httpSrv{mx: sync.Mutex{}}
|
||||||
|
|
||||||
|
type httpSrv struct {
|
||||||
|
working bool
|
||||||
|
srv *fasthttp.Server
|
||||||
|
mx sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *httpSrv) Init(new, old conf.HttpSetting) {
|
||||||
|
if s.working {
|
||||||
|
if !cmp.Equal(new, old) {
|
||||||
|
s.run(new.GetMaxRequestBodySize())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
s.run(new.GetMaxRequestBodySize())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *httpSrv) run(maxRequestBodySize int64) {
|
||||||
|
s.mx.Lock()
|
||||||
|
s.working = true
|
||||||
|
if s.srv != nil {
|
||||||
|
if err := s.srv.Shutdown(); err != nil {
|
||||||
|
log.Warn(log_code.WarnHttpServerShutdown, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
localConfig := config.Get().(*conf.Configuration)
|
||||||
|
restAddress := localConfig.HttpInnerAddress.GetAddress()
|
||||||
|
s.srv = &fasthttp.Server{
|
||||||
|
Handler: handler.CompleteRequest,
|
||||||
|
WriteTimeout: defaultTimeout,
|
||||||
|
ReadTimeout: defaultTimeout,
|
||||||
|
MaxRequestBodySize: int(maxRequestBodySize),
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
if err := s.srv.ListenAndServe(restAddress); err != nil {
|
||||||
|
log.Error(log_code.ErrorHttpServerListen, err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
s.mx.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *httpSrv) Close() {
|
||||||
|
if s.srv != nil {
|
||||||
|
s.working = false
|
||||||
|
if err := s.srv.Shutdown(); err != nil {
|
||||||
|
log.Warn(log_code.WarnHttpServerShutdown, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AdminAuth interface {
|
|
||||||
Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error)
|
|
||||||
Authorize(ctx context.Context, adminId int, permission string) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Admin struct {
|
|
||||||
cache AuthorizationCache
|
|
||||||
repo AdminAuth
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAdmin(cache AuthorizationCache, adminAuth AdminAuth) Admin {
|
|
||||||
return Admin{
|
|
||||||
cache: cache,
|
|
||||||
repo: adminAuth,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Admin) AdminAuthenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
|
||||||
resp, err := s.repo.Authenticate(ctx, token)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "get admin token data from admin service")
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Admin) AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
|
||||||
ok, err := s.cache.Get(ctx, adminId, permission)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "authz cache get")
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err = s.repo.Authorize(ctx, adminId, permission)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "authz repo authorize")
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
err = s.cache.SetAuthorized(ctx, adminId, permission)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "authz cache set")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/domain"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuthenticationCache interface {
|
|
||||||
Get(ctx context.Context, token string) (*domain.AuthData, error)
|
|
||||||
Set(ctx context.Context, token string, data domain.AuthData) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthenticationRepo interface {
|
|
||||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Auth struct {
|
|
||||||
cache AuthenticationCache
|
|
||||||
repo AuthenticationRepo
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAuthentication(cache AuthenticationCache, repo AuthenticationRepo) Auth {
|
|
||||||
return Auth{
|
|
||||||
cache: cache,
|
|
||||||
repo: repo,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Auth) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
|
||||||
authData, err := s.cache.Get(ctx, token)
|
|
||||||
if errors.Is(err, domain.ErrAuthenticationCacheMiss) {
|
|
||||||
resp, err := s.repo.Authenticate(ctx, token)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "auth repo authenticate")
|
|
||||||
}
|
|
||||||
if !resp.Authenticated {
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
err = s.cache.Set(ctx, token, *resp.AuthData)
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "auth cache set")
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.WithMessage(err, "auth cache get")
|
|
||||||
}
|
|
||||||
return &domain.AuthenticateResponse{
|
|
||||||
Authenticated: true,
|
|
||||||
ErrorReason: "",
|
|
||||||
AuthData: authData,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type AuthorizationCache interface {
|
|
||||||
Get(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
|
||||||
SetAuthorized(ctx context.Context, applicationId int, endpoint string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthorizationRepo interface {
|
|
||||||
Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Authorization struct {
|
|
||||||
cache AuthorizationCache
|
|
||||||
repo AuthorizationRepo
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewAuthorization(cache AuthorizationCache, repo AuthorizationRepo) Authorization {
|
|
||||||
return Authorization{
|
|
||||||
cache: cache,
|
|
||||||
repo: repo,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s Authorization) Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
|
||||||
ok, err := s.cache.Get(ctx, applicationId, endpoint)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "authz cache get")
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ok, err = s.repo.Authorize(ctx, applicationId, endpoint)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "authz repo authorize")
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
err = s.cache.SetAuthorized(ctx, applicationId, endpoint)
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessagef(err, "authz cache set")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok, nil
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package service
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-gate-service/conf"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DailyLimitRepo interface {
|
|
||||||
Increment(ctx context.Context, applicationId int, today time.Time) (int64, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type DailyLimit struct {
|
|
||||||
repo DailyLimitRepo
|
|
||||||
limits map[int]int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDailyLimit(repo DailyLimitRepo, configs []conf.DailyLimit) DailyLimit {
|
|
||||||
limits := make(map[int]int64)
|
|
||||||
for _, config := range configs {
|
|
||||||
limits[config.ApplicationId] = config.RequestsPerDay
|
|
||||||
}
|
|
||||||
return DailyLimit{
|
|
||||||
repo: repo,
|
|
||||||
limits: limits,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s DailyLimit) IncrementAndCheck(ctx context.Context, applicationId int) (bool, error) {
|
|
||||||
limit, ok := s.limits[applicationId]
|
|
||||||
if !ok {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
newValue, err := s.repo.Increment(ctx, applicationId, time.Now())
|
|
||||||
if err != nil {
|
|
||||||
return false, errors.WithMessage(err, "increment")
|
|
||||||
}
|
|
||||||
|
|
||||||
return newValue <= limit, nil
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package matcher
|
||||||
|
|
||||||
|
import "sync"
|
||||||
|
|
||||||
|
type atLeastOneMatcher struct {
|
||||||
|
cache map[string]bool
|
||||||
|
lock sync.RWMutex
|
||||||
|
rm runtimeMatcher
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mm *atLeastOneMatcher) Match(method string) bool {
|
||||||
|
if len(mm.rm.patterns) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
mm.lock.RLock()
|
||||||
|
matched, ok := mm.cache[method]
|
||||||
|
mm.lock.RUnlock()
|
||||||
|
if ok {
|
||||||
|
return matched
|
||||||
|
}
|
||||||
|
|
||||||
|
mm.lock.Lock()
|
||||||
|
defer mm.lock.Unlock()
|
||||||
|
if matched, ok = mm.cache[method]; ok {
|
||||||
|
return matched
|
||||||
|
} else {
|
||||||
|
arrayPattern := mm.rm.Match(method)
|
||||||
|
matched = len(arrayPattern) > 0
|
||||||
|
}
|
||||||
|
mm.cache[method] = matched
|
||||||
|
return matched
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package matcher
|
||||||
|
|
||||||
|
import "sync"
|
||||||
|
|
||||||
|
type cacheableMatcher struct {
|
||||||
|
cache map[string][]string
|
||||||
|
lock sync.RWMutex
|
||||||
|
rm runtimeMatcher
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mm *cacheableMatcher) Match(method string) []string {
|
||||||
|
if len(mm.rm.patterns) == 0 {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
mm.lock.RLock()
|
||||||
|
arrayPattern, ok := mm.cache[method]
|
||||||
|
mm.lock.RUnlock()
|
||||||
|
if ok {
|
||||||
|
return arrayPattern
|
||||||
|
}
|
||||||
|
|
||||||
|
mm.lock.Lock()
|
||||||
|
defer mm.lock.Unlock()
|
||||||
|
if arrayPattern, ok = mm.cache[method]; ok {
|
||||||
|
return arrayPattern
|
||||||
|
} else if arrayPattern = mm.rm.Match(method); len(arrayPattern) > 0 {
|
||||||
|
mm.cache[method] = arrayPattern
|
||||||
|
}
|
||||||
|
|
||||||
|
return arrayPattern
|
||||||
|
}
|
||||||
Loaded 100 of 115 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user