Compare commits

..
20 Commits
Author SHA1 Message Date
txix d4846359e4 2025-10-02 16:02:08: merge [main:13db082fcac220b28433a207845ceb3bef8bd07d];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-10-02 16:02:08 +03:00
txix 13cf0075f6 2025-09-17 18:07:26: merge [main:f5bfe7d2ba0d7a2f391f4ffaff6fffc1686ba3c7];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-09-17 18:07:26 +03:00
txix 135e551473 2025-08-21 15:04:13: merge [main:a4b6e5fd1d9685c751c5988518e9f8dd62a8e519]; 2025-08-21 15:04:13 +03:00
txix 689f730a3e 2025-07-09 12:35:19: merge [main:9f485b5e57937029be52e58137ef79ad5c3ca524];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-07-09 12:35:19 +03:00
txix a30582fa38 2025-07-03 12:26:31: merge [main:66e6c4b9c432b19b644d033703545d38aba3b847];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-07-03 12:26:31 +03:00
txix 5b1ce14467 2025-07-01 16:40:11: merge [main:61f11c0bda72fe35f473f8302edfaf86f151c0ad];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-07-01 16:40:11 +03:00
txix 264b438cdb 2025-07-01 13:32:55: merge [main:6491e79afd06cd665731c89f8ab2cd373351c1b4]; 2025-07-01 13:32:55 +03:00
txix f699aefa58 2025-05-27 14:32:05: merge [master:01f8dcdc36fb3f9867a65ffb7379ad25c85cd988];
Create and publish a Docker image / build-and-push-image (push) Canceled after 0s
2025-05-27 14:32:05 +03:00
txix 8d40e76637 2025-05-13 13:05:46: merge [master:49d1bfaa3f027c5465de7a0c0d46a9bab0588e19]; 2025-05-13 13:05:46 +03:00
txix e2b4becfd6 2025-04-29 14:57:30: merge [master:357ce03935a551e8be5766b349a621104998de83]; 2025-04-29 14:57:30 +03:00
txix e4ef2d8645 2025-04-23 12:39:56: merge [master:82ac257e917aa3f9ab915b911afbd28c0f52f88e]; 2025-04-23 12:39:56 +03:00
txix bfc28503d5 2025-04-18 12:46:39: merge [master:7b5fc0b41640a6b6648e6391777fa08099997af1]; 2025-04-18 12:46:39 +03:00
txix d759f883f4 2025-04-18 12:26:12: merge [master:576ef18526fa6f0685f8ab997cae0d31a4ebce90]; 2025-04-18 12:26:13 +03:00
txix 64373fdf3c 2025-04-03 17:31:43: merge [master:03df79d7b37febb99439347c2da79707bf437498]; 2025-04-03 17:31:43 +03:00
txix 1dd566593e 2024-12-27 17:46:16: merge [master:4898a95fc423e3ae55135d3023a1b78fb18edebc]; 2024-12-27 17:46:16 +03:00
txix 560c1f22c4 2024-12-27 12:28:18: merge [master:9ec52bd8525d6120bfebe62b6da4eb172a000ee8]; 2024-12-27 12:28:18 +03:00
txix 171b85f627 2024-12-27 12:14:12: merge [master:bf6ba426f66d82ef1e76da30674890898919501b]; 2024-12-27 12:14:12 +03:00
txix 734b83b2b8 2024-12-11 12:34:04: merge [master:744eaa2605c9d3eb73b2db76661b2d0a6949d4d9]; 2024-12-11 12:34:04 +03:00
txix bdeb2c0753 2024-12-03 13:02:16: merge [master:b21f96b8a5ec988002a89bd9d1f51e90c01a2d21]; 2024-12-03 13:02:16 +03:00
txix 97c44fb3bd 2024-10-11 14:58:36: merge [master:7f99b95ceaaed865d2833070a0397cf191949b8e]; 2024-10-11 14:58:36 +03:00
40 changed files with 774 additions and 634 deletions

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
name: Create and publish a Docker image
on:
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
APP_NAME: ${{ github.event.repository.name }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version from tag
id: version_reader
run: |
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_reader.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.version=${{ steps.version_reader.outputs.version }}
build-args: |
app_name=${{ env.APP_NAME }}
version=${{ steps.version_reader.outputs.version }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
+3
View File
@@ -0,0 +1,3 @@
include:
- project: '$CI_PROJECT_PATH'
file: '/ci-isp-go-service.yml'
+74 -60
View File
@@ -1,66 +1,80 @@
version: "2"
run:
allow-parallel-runners: true
issues:
exclude-rules:
- path: controller #достаточное кол-во контекса на уровне контроллеров
linters:
- wrapcheck
- path: transaction #транзакции прозрачны
linters:
- wrapcheck
- path: middleware #отсутствует необходимость оборачивать ошибки
linters:
- wrapcheck
- path: proxy
linters:
- gochecknoglobals
- mnd
- path: httperrors #отсутствует необходимость оборачивать ошибки
linters:
- wrapcheck
linters:
enable-all: true
default: all
disable:
- goimports #у нас собственные правила форматирования импортов
- wsl #расставление пробелов очень индивидуально
- exhaustivestruct #не имеет смысла
- varnamelen #очень индивидуально (db)
- exhaustruct #не имеет смысла
- golint #устарел
- contextcheck #не имеет смысла
- gci #у нас собственные правила форматирования импортов
- gofumpt #у нас собственные правила форматирования импортов
- nolintlint #Goland все равно форматирует с отступом
- nlreturn #не всегда имеет смысл
- godot #не актуально для свагера
- ifshort #приняли решение, что мы так не пишем if err := ...; err != nil {}
- godox #не позволяет оставлять todo
- maligned #аллокацией памяти для структур конфликтует с удобством их чтения
- nosnakecase #не позволяет заводить пакеты используя snake_case
- depguard #не всегда имеет смысл
- dupword #не имеет смысла
- tagalign #не всегда имеет смысл
- musttag #у нас собственные правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внених для нас структур
- perfsprint #мнимая производительность в угоду читаемости
- contextcheck # не имеет смысла
- depguard # не всегда имеет смысл
- dupword # не имеет смысла
- exhaustruct # не имеет смысла
- godot # не актуально для swagger
- godox # не позволяет оставлять todo
- musttag # у нас собственное правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внешних для нас структур
- nlreturn # не всегда имеет смысл
- nolintlint # Goland все равно форматирует с отступом
- perfsprint # мнимая производительность в угоду читаемости
- tagalign # не всегда имеет смысл
- testpackage
linters-settings:
funlen:
lines: 80
lll:
line-length: 150
cyclop:
max-complexity: 15 #по умолчанию 10 мало
revive:
- varnamelen # очень индивидуально (db)
- wsl # расставление пробелов очень индивидуально
- wsl_v5 # расставление пробелов очень индивидуально
settings:
cyclop:
max-complexity: 15 # по умолчанию 10 мало
funlen:
lines: 80
lll:
line-length: 150
revive:
rules:
- name: var-naming # отключаем Id -> ID
disabled: true
staticcheck:
checks: # отключаем Id -> ID
- -ST1000
- -ST1016
- -ST1020
- -ST1021
- -ST1022
testifylint:
disable:
- compares
- equal-values
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- name: var-naming #отключаем Id -> ID
disabled: true
stylecheck:
checks: #отключаем Id -> ID
- "-ST1000"
- "-ST1016"
- "-ST1020"
- "-ST1021"
- "-ST1022"
testifylint:
disable:
- compares
- 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 -1
View File
@@ -1 +1 @@
5.2.0
5.4.0
+32
View File
@@ -1,3 +1,35 @@
### v5.4.0
* Добавлена настройка `forwardReqIdClientSettings` для разрешения прокидывания `requestId` определённым приложениям по их идентификаторам (`requestId` клиента прокидывается если в `forwardReqIdClientSettings` для приложения включено прокидывание или включен глобальный флаг `enableClientRequestIdForwarding`)
* Обновлена версия go до 1.25
### v5.3.0
* обновлены зависимости
### v5.2.10
* добавлен контекст ошибки для grpc
### v5.2.9
* взаимодействие напрямую с `redis` заменено на взаимодействие с `isp-lock-service`
### v5.2.8
* добавлена обработка эндпоинта в двух форматах: с `/` в начале и без
* обновлены зависимости
### 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
-1
View File
@@ -1 +0,0 @@
test2
+25 -54
View File
@@ -3,18 +3,17 @@ package assembly
import (
"context"
"github.com/redis/go-redis/v9"
"isp-gate-service/conf"
"isp-gate-service/routes"
"github.com/integration-system/isp-kit/app"
"github.com/integration-system/isp-kit/bootstrap"
"github.com/integration-system/isp-kit/cluster"
"github.com/integration-system/isp-kit/grpc/client"
"github.com/integration-system/isp-kit/http"
"github.com/integration-system/isp-kit/lb"
"github.com/integration-system/isp-kit/log"
"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 {
@@ -22,9 +21,9 @@ type Assembly struct {
server *http.Server
logger *log.Adapter
routes *routes.Routes
redisCli redis.UniversalClient
systemCli *client.Client
adminCli *client.Client
lockerCli *client.Client
locations []conf.Location
grpcClientByModuleName map[string]*client.Client
@@ -62,11 +61,14 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
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")
}
lockerCli, err := client.Default()
if err != nil {
return nil, errors.WithMessage(err, "create isp-lock-service client")
}
return &Assembly{
boot: boot,
@@ -78,6 +80,7 @@ func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
httpHostManagerByModuleName: httpHostManagerByModuleName,
systemCli: systemCli,
adminCli: adminCli,
lockerCli: lockerCli,
}, nil
}
@@ -90,32 +93,24 @@ func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error
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)
locator := NewLocator(
a.logger,
a.grpcClientByModuleName,
a.httpHostManagerByModuleName,
a.routes,
a.systemCli,
a.adminCli,
a.lockerCli,
)
handler, err := locator.Handler(newCfg, a.locations)
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
}
@@ -130,9 +125,9 @@ func (a *Assembly) Runners() []app.Runner {
for moduleName, upgrader := range a.httpHostManagerByModuleName {
eventHandler.RequireModule(moduleName, upgrader)
}
eventHandler.RequireModule("isp-system-service", a.systemCli)
eventHandler.RequireModule("msp-admin-service", a.adminCli)
eventHandler.RequireModule("isp-lock-service", a.lockerCli)
return []app.Runner{
app.RunnerFunc(func(ctx context.Context) error {
@@ -154,31 +149,7 @@ func (a *Assembly) Closers() []app.Closer {
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
}))
closers = append(closers, a.systemCli, a.adminCli, a.lockerCli)
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,
})
}
+32 -19
View File
@@ -4,8 +4,6 @@ import (
"net/http"
"time"
mux2 "github.com/gorilla/mux"
"github.com/redis/go-redis/v9"
"isp-gate-service/conf"
"isp-gate-service/middleware"
"isp-gate-service/proxy"
@@ -13,10 +11,11 @@ import (
"isp-gate-service/routes"
"isp-gate-service/service"
"github.com/integration-system/isp-kit/grpc/client"
"github.com/integration-system/isp-kit/lb"
"github.com/integration-system/isp-kit/log"
mux2 "github.com/gorilla/mux"
"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 {
@@ -26,6 +25,7 @@ type Locator struct {
routes *routes.Routes
systemCli *client.Client
adminCli *client.Client
lockerCli *client.Client
}
func NewLocator(
@@ -35,6 +35,7 @@ func NewLocator(
routes *routes.Routes,
systemCli *client.Client,
adminCli *client.Client,
lockerCli *client.Client,
) Locator {
return Locator{
logger: logger,
@@ -43,10 +44,11 @@ func NewLocator(
routes: routes,
systemCli: systemCli,
adminCli: adminCli,
lockerCli: lockerCli,
}
}
func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli redis.UniversalClient) (http.Handler, error) {
func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Handler, error) { // nolint:funlen
systemRepo := repository.NewSystem(l.systemCli)
adminRepo := repository.NewAdmin(l.adminCli)
@@ -63,11 +65,9 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
systemRepo,
)
dailyLimitRepo := repository.NewDailyLimit(redisCli)
dailyLimitService := service.NewDailyLimit(dailyLimitRepo, config.DailyLimits)
throttlingRepo := repository.NewThrottling(redisCli)
throttlingService := service.NewThrottling(throttlingRepo, config.Throttling)
lockRepo := repository.NewLocker(l.lockerCli)
dailyLimitService := service.NewDailyLimit(lockRepo, config.DailyLimits)
throttlingService := service.NewThrottling(lockRepo, config.Throttling)
mux := mux2.NewRouter()
for _, location := range locations {
@@ -89,11 +89,19 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
return nil, errors.Errorf("not supported protocol %s", location.Protocol)
}
forwardReqIdByAppId := make(map[int]bool, len(config.ForwardReqIdClientSettings))
for _, setting := range config.ForwardReqIdClientSettings {
forwardReqIdByAppId[setting.ApplicationId] = setting.ForwardRequestId
}
handler := middleware.Chain(
proxyFunc,
middleware.RequestId(),
middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog,
config.Logging.SkipBodyLoggingEndpointPrefixes),
middleware.Logger(
l.logger, config.Logging.RequestLogEnable,
enableBodyLog,
config.Logging.SkipBodyLoggingEndpointPrefixes,
config.Logging.EnableForceUnescapingUnicode,
),
middleware.ErrorHandler(l.logger),
middleware.Authenticate(authentication),
middleware.AdminAuthenticate(adminService),
@@ -101,24 +109,29 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
middleware.AdminAuthorize(l.routes, adminService),
middleware.Throttling(throttlingService),
middleware.DailyLimit(dailyLimitService),
middleware.RequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
)
if location.SkipAuth {
handler = middleware.Chain(
proxyFunc,
middleware.RequestId(),
middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog,
config.Logging.SkipBodyLoggingEndpointPrefixes),
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
enableBodyLog,
config.Logging.SkipBodyLoggingEndpointPrefixes,
config.Logging.EnableForceUnescapingUnicode,
),
middleware.ErrorHandler(l.logger),
middleware.RequestId(config.EnableClientRequestIdForwarding, forwardReqIdByAppId),
)
}
entrypoint := middleware.Entrypoint(
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd,gomnd
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd
handler,
l.logger,
middleware.EntryPointConfig{
WithPrefix: location.WithPrefix,
PathPrefix: location.PathPrefix,
},
l.routes,
l.logger,
)
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
}
+8
View File
@@ -24,6 +24,14 @@ locations:
- 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
+2 -1
View File
@@ -3,7 +3,8 @@
"logLevel": "debug",
"requestLogEnable": true,
"bodyLogEnable": false,
"skipBodyLoggingEndpointPrefixes": []
"skipBodyLoggingEndpointPrefixes": [],
"enableForceUnescapingUnicode": false
},
"caching": {
"authenticationDataInSec": 60,
+16 -34
View File
@@ -4,10 +4,9 @@ package conf
import (
"reflect"
"github.com/integration-system/isp-kit/log"
"github.com/integration-system/isp-kit/rc/schema"
"github.com/integration-system/jsonschema"
"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() {
@@ -18,12 +17,18 @@ func init() {
}
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:"Настройки пропускной способности"`
Http Http `schema:"Настройки HTTP"`
Logging Logging `schema:"Настройки логирования"`
Caching Caching `schema:"Настройки кеширования"`
DailyLimits []DailyLimit `schema:"Настройки суточных ограничений,сбрасываются раз в сутки в 00:00"`
Throttling []Throttling `schema:"Настройки пропускной способности"`
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
ForwardReqIdClientSettings []ForwardReqIdClientSettings `schema:"Настройки проброcа requestId для приложений"`
}
type ForwardReqIdClientSettings struct {
ApplicationId int `schema:"Идентификатор приложения"`
ForwardRequestId bool `schema:"Включить проброс requestId из заголовка запроса"`
}
type Http struct {
@@ -36,6 +41,7 @@ type Logging struct {
RequestLogEnable bool `schema:"Включить логирование запросов"`
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
EnableForceUnescapingUnicode bool `schema:"Включить перевод тел запроса из unicode в utf-8, должно быть включено логирование тел запросов и ответов"`
}
type Caching struct {
@@ -52,27 +58,3 @@ 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
}
+1 -1
View File
@@ -3,7 +3,7 @@ package conf_test
import (
"testing"
"github.com/integration-system/isp-kit/test/rct"
"github.com/txix-open/isp-kit/test/rct"
"isp-gate-service/conf"
)
+25
View File
@@ -0,0 +1,25 @@
package entity
import (
"time"
)
type IncrementRequest struct {
Key string
Today time.Time
}
type IncrementResponse struct {
Value uint64
}
type RateLimiterRequest struct {
Key string
MaxRps int
}
type RateLimiterResponse struct {
Allow bool
Remaining int
RetryAfter time.Duration
}
+46 -44
View File
@@ -1,77 +1,79 @@
module isp-gate-service
go 1.21
go 1.25
require (
github.com/go-redis/redis_rate/v10 v10.0.1
github.com/google/uuid v1.4.0
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.1
github.com/integration-system/isp-etp-go/v2 v2.1.3
github.com/integration-system/isp-kit v1.27.0
github.com/integration-system/jsonschema v1.1.0
github.com/gorilla/websocket v1.5.3
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.3.0
github.com/stretchr/testify v1.9.0
github.com/redis/go-redis/v9 v9.11.0
github.com/stretchr/testify v1.11.1
github.com/tomakado/websocketproxy v0.1.0
golang.org/x/net v0.26.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4
google.golang.org/grpc v1.59.0
github.com/txix-open/isp-kit v1.57.1
github.com/txix-open/jsonschema v1.3.0
golang.org/x/net v0.44.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090
google.golang.org/grpc v1.75.1
)
require (
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/txix-open/etp/v4 v4.0.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // 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.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coder/websocket v1.8.14 // 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.2 // indirect
github.com/getsentry/sentry-go v0.25.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/getsentry/sentry-go v0.35.2 // indirect
github.com/go-logr/logr v1.4.3 // 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/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/integration-system/bellows v1.0.1 // indirect
github.com/integration-system/validator/v10 v10.0.0-20231205122740-49807820d98b // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mailru/easyjson v0.7.7 // 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.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.17.0 // 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.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.opentelemetry.io/proto/otlp v1.8.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/protobuf v1.34.2 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 // indirect
google.golang.org/protobuf v1.36.9 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.10 // indirect
)
+114 -155
View File
@@ -10,10 +10,14 @@ github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -21,98 +25,59 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX1eOyI=
github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/gabriel-vasile/mimetype v1.4.10 h1:zyueNbySn/z8mJZHLt6IPw0KoZsiQNszIpU+bX4+ZK0=
github.com/gabriel-vasile/mimetype v1.4.10/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/getsentry/sentry-go v0.35.2 h1:jKuujpRwa8FFRYMIwwZpu83Xh0voll9bmvyc6310WBM=
github.com/getsentry/sentry-go v0.35.2/go.mod h1:mdL49ixwT2yi57k5eh7mpnDyPybixPzlzEJFu0Z76QA=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
github.com/go-redis/redis_rate/v10 v10.0.1 h1:calPxi7tVlxojKunJwQ72kwfozdy25RjA0bCj1h0MUo=
github.com/go-redis/redis_rate/v10 v10.0.1/go.mod h1:EMiuO9+cjRkR7UvdvwMO7vbgqJkltQHtwbdIQvaBKIU=
github.com/go-resty/resty/v2 v2.10.0 h1:Qla4W/+TMmv0fOeeRqzEpXPLfTUnR5HZ1+lGs+CkiCo=
github.com/go-resty/resty/v2 v2.10.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/integration-system/bellows v1.0.1 h1:7g1lhD/6EcvsSo9iuiFqw98XGS78Sko6kUKPzfte/SY=
github.com/integration-system/bellows v1.0.1/go.mod h1:qHPg1ptN3AHHr0f/wvoicfA2LOCprOyrbXnIa5QIRe0=
github.com/integration-system/grmq v1.4.2 h1:BFO9ahqnb3SpMCt5zxaRAh1iiILkC8tqmNcxRHHpmh8=
github.com/integration-system/grmq v1.4.2/go.mod h1:DeE6Ceo/A+MuvzdPkuZzqajy0VJhOyH7rRxksQqhEYk=
github.com/integration-system/isp-etp-go/v2 v2.1.3 h1:vcHP/PE7p1G3rxqoVKrKtXzoSxFA4ryxigd+zPkAb3w=
github.com/integration-system/isp-etp-go/v2 v2.1.3/go.mod h1:ZpB+FIH3hy7md+f8ylVSQx5zwZVjczhkc45f1B2z9nw=
github.com/integration-system/isp-kit v1.27.0 h1:NgxEUBrL+1Rv4C1nyfFb5TKu9M7DO3WmTYx5Mk1Vc00=
github.com/integration-system/isp-kit v1.27.0/go.mod h1:/2CMMhgRnNehijkUcJLePZGTgTTIiotg2NiUm7rM30o=
github.com/integration-system/jsonschema v1.1.0 h1:l9jshYRkImMHfHTPWaUEhP37gX9yW5l7cRHOcIH4g8k=
github.com/integration-system/jsonschema v1.1.0/go.mod h1:vrRpWq+l1NFXffXnodH4fYWyt9sLtlx+UJ39S3b/jsA=
github.com/integration-system/validator/v10 v10.0.0-20231205122740-49807820d98b h1:/N1rgICVeP04g3+2ATmILUfD2clpHCJ9bzmwqeBw21s=
github.com/integration-system/validator/v10 v10.0.0-20231205122740-49807820d98b/go.mod h1:vLdiU06b11Kfto2J+XD6o76cIkGtwQmCBNj65fRuQl4=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnVTyacbefKhmbLhIhU=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
@@ -123,35 +88,47 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc=
github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rabbitmq/amqp091-go v1.9.0 h1:qrQtyzB4H8BQgEuJwhmVQqVHB9O4+MNDJCCAcpc3Aoo=
github.com/rabbitmq/amqp091-go v1.9.0/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
github.com/redis/go-redis/v9 v9.3.0 h1:RiVDjmig62jIWp7Kk4XVLs0hzV6pI3PyTnnL0cnn0u0=
github.com/redis/go-redis/v9 v9.3.0/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9ZoGs=
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
github.com/redis/go-redis/v9 v9.11.0 h1:E3S08Gl/nJNn5vkxd2i78wZxWAPNZgUNTp8WIJUAiIs=
github.com/redis/go-redis/v9 v9.11.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tomakado/websocketproxy v0.1.0 h1:e037TLXDvEYYHlxHE5pqmj/DytFKm2NRn7i4wbVzIyE=
github.com/tomakado/websocketproxy v0.1.0/go.mod h1:EXg/3jcTJYZ04Hsf93RpY90FYA9lj1Sl+VM7lZI6xpM=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgjeY=
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
github.com/txix-open/etp/v3 v3.2.0 h1:EgTchT8VtCYV1iEo/y4jII3/NybrXiQDE0y6pmS350M=
github.com/txix-open/etp/v3 v3.2.0/go.mod h1:lgen0TJmiturgBhvlxH1/PQ7iLL/OebKbxPAQYkuKI0=
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
github.com/txix-open/grmq v1.9.0 h1:ArDbJJcFX9zXKEcPf49rp9nYiRyGMJxGKJAxdbSsfaM=
github.com/txix-open/grmq v1.9.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
github.com/txix-open/isp-kit v1.57.1 h1:EltTEs9VZT8eqUrrRt5EqWAPdXFvw1XL2/EDN8xfdUU=
github.com/txix-open/isp-kit v1.57.1/go.mod h1:Mbprn7ExedjRg4yUPa9xShYx1oMJIU+a19x6ksVubaw=
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
@@ -161,79 +138,61 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 h1:gbhw/u49SS3gkPWiYweQNJGm/uJN5GkI/FrosxSHT7A=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1/go.mod h1:GnOaBaFQ2we3b9AGWJpsBa7v1S5RlQzlC3O7dRMxZhM=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo=
go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc=
go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 h1:digkEZCJWobwBqMwC0cwCq8/wkkRy/OowZg5OArWZrM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0/go.mod h1:/OpE/y70qVkndM0TrxT4KBoN3RsFZP0QaofcfYrj76I=
go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4=
go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM=
go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8=
go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E=
go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc=
go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ=
go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I=
go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.opentelemetry.io/auto/sdk v1.2.0 h1:YpRtUFjvhSymycLS2T81lT6IGhcUP+LUPtv0iv1N8bM=
go.opentelemetry.io/auto/sdk v1.2.0/go.mod h1:1deq2zL7rwjwC8mR7XgY2N+tlIl6pjmEUoLDENMEzwk=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0 h1:2pn7OzMewmYRiNtv1doZnLo3gONcnMHlFnmOR8Vgt+8=
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.63.0/go.mod h1:rjbQTDEPQymPE0YnRQp9/NuPwwtL0sesz/fnqRW/v84=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 h1:aTL7F04bJHUlztTsNGJ2l+6he8c+y/b//eR0jjjemT4=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0/go.mod h1:kldtb7jDTeol0l3ewcmd8SDvx3EmIE7lyvqbasU3QC4=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE=
go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f h1:Vn+VyHU5guc9KjB5KrjI2q0wCOWEOIh0OEsleqakHJg=
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f/go.mod h1:nWSwAFPb+qfNJXsoeO3Io7zf4tMSfN8EA8RlDA04GhY=
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 h1:ZcOkrmX74HbKFYnpPY8Qsw93fC29TbJXspYKaBkSXDQ=
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4/go.mod h1:k2dtGpRrbsSyKcNPKKI5sstZkrNCZwpU/ns96JoHbGg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 h1:d8Nakh1G+ur7+P3GcMjpRDEkoLUcLW2iU92XVqR+XMQ=
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090/go.mod h1:U8EXRNSd8sUYyDfs/It7KVWodQr+Hf9xtxyxWudSwEw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 h1:/OQuEa4YWtDt7uQWHd3q3sUMb+QOLQUg1xa8CEsRv5w=
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090/go.mod h1:GmFNa4BdJZ2a8G+wCe9Bg3wwThLrJun751XstdJt5Og=
google.golang.org/grpc v1.75.1 h1:/ODCNEuf9VghjgO3rqLcfg8fiOP0nSluljWFlDxELLI=
google.golang.org/grpc v1.75.1/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q=
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
+7 -7
View File
@@ -3,29 +3,29 @@ package httperrors
import (
"net/http"
"github.com/integration-system/isp-kit/json"
"github.com/txix-open/isp-kit/json"
)
type HttpError struct {
statusCode int
userMessage string
details []interface{}
details []any
err error
}
func New(statusCode int, userMessage string, internalError error) HttpError {
return HttpError{
func New(statusCode int, userMessage string, internalError error) *HttpError {
return &HttpError{
statusCode: statusCode,
userMessage: userMessage,
err: internalError,
}
}
func (e HttpError) Error() string {
func (e *HttpError) Error() string {
return e.err.Error()
}
func (e HttpError) WriteError(w http.ResponseWriter) error {
func (e *HttpError) WriteError(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(e.statusCode)
data := map[string]interface{}{
@@ -36,6 +36,6 @@ func (e HttpError) WriteError(w http.ResponseWriter) error {
return json.NewEncoder(w).Encode(data)
}
func (e *HttpError) WithDetails(details ...interface{}) {
func (e *HttpError) WithDetails(details ...any) {
e.details = details
}
+2 -2
View File
@@ -1,8 +1,8 @@
package main
import (
"github.com/integration-system/isp-kit/bootstrap"
"github.com/integration-system/isp-kit/shutdown"
"github.com/txix-open/isp-kit/bootstrap"
"github.com/txix-open/isp-kit/shutdown"
"isp-gate-service/assembly"
"isp-gate-service/conf"
)
+2 -2
View File
@@ -10,8 +10,8 @@ import (
)
type AdminMethodStore interface {
IsInnerEndpoint(path string) bool
RequiredAdminPermission(path string) (string, bool)
IsInnerEndpoint(endpoint string) bool
RequiredAdminPermission(endpoint string) (string, bool)
}
type AdminAuthorizer interface {
+1 -1
View File
@@ -4,8 +4,8 @@ import (
"context"
"net/http"
"github.com/integration-system/isp-kit/log"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/log"
"isp-gate-service/httperrors"
"isp-gate-service/request"
)
+14 -11
View File
@@ -1,13 +1,10 @@
package middleware
import (
"fmt"
"net/http"
"strings"
"github.com/integration-system/isp-kit/log"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/log"
"isp-gate-service/request"
"net/http"
)
type EntryPointConfig struct {
@@ -15,15 +12,21 @@ type EntryPointConfig struct {
WithPrefix bool
}
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, cfg EntryPointConfig) http.Handler {
type EndpointResolver interface {
ResolveEndpoint(path string, cfg EntryPointConfig) string
}
func Entrypoint(
maxReqBodySize int64,
next Handler,
cfg EntryPointConfig,
entryPointResolver EndpointResolver,
logger log.Logger,
) http.Handler {
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
endpoint := req.URL.Path
if !cfg.WithPrefix {
prefix := fmt.Sprintf("%s/", cfg.PathPrefix)
endpoint = strings.TrimPrefix(req.URL.Path, prefix)
}
endpoint := entryPointResolver.ResolveEndpoint(req.URL.Path, cfg)
ctx := request.NewContext(req, writer, endpoint)
err := next.Handle(ctx)
+1 -1
View File
@@ -3,7 +3,7 @@ package middleware
import (
"net/http"
"github.com/integration-system/isp-kit/log"
"github.com/txix-open/isp-kit/log"
"isp-gate-service/httperrors"
"isp-gate-service/request"
)
+32 -7
View File
@@ -3,23 +3,29 @@ package middleware
import (
"bufio"
"bytes"
"github.com/txix-open/isp-kit/json"
"io"
"net"
"net/http"
"strings"
"github.com/integration-system/isp-kit/http/endpoint/buffer"
"github.com/integration-system/isp-kit/log"
"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
}
@@ -43,11 +49,12 @@ func (w *writerWrapper) WriteHeader(statusCode int) {
w.ResponseWriter.WriteHeader(statusCode)
}
func Logger(
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 {
@@ -108,10 +115,13 @@ func Logger(
}
if logBodyFromCurrenRequest {
fields = append(fields,
log.ByteString("request", buf.RequestBody()),
log.ByteString("response", buf.ResponseBody()),
)
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...)
@@ -119,3 +129,18 @@ func Logger(
})
}
}
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
}
+17 -8
View File
@@ -3,28 +3,37 @@ package middleware
import (
"strings"
"github.com/integration-system/isp-kit/log"
"github.com/integration-system/isp-kit/requestid"
"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() Middleware {
func RequestId(forwardClientRequestId bool, forwardReqIdByApp map[int]bool) Middleware {
return func(next Handler) Handler {
return HandlerFunc(func(ctx *request.Context) error {
requestId := strings.TrimSpace(ctx.Request().Header.Get(requestIdHeader))
if requestId == "" {
requestId = requestid.Next()
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))
authData, _ := ctx.GetAuthData()
if forwardClientRequestId || forwardReqIdByApp[authData.ApplicationId] {
requestId = clientRequestId
}
}
logFields = append(logFields, log.String("requestId", requestId))
context := requestid.ToContext(ctx.Context(), requestId)
context = log.ToContext(context, log.String("requestId", requestId))
context = log.ToContext(context, logFields...)
ctx.SetContext(context)
return next.Handle(ctx)
})
}
+18 -13
View File
@@ -11,12 +11,12 @@ import (
"isp-gate-service/httperrors"
"isp-gate-service/request"
"github.com/integration-system/isp-kit/grpc"
"github.com/integration-system/isp-kit/grpc/client"
"github.com/integration-system/isp-kit/grpc/isp"
"github.com/integration-system/isp-kit/json"
"github.com/integration-system/isp-kit/requestid"
"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"
@@ -68,10 +68,12 @@ func (p Grpc) Handle(ctx *request.Context) error {
return errors.WithMessage(err, "grpc: read body")
}
requestId := requestid.FromContext(ctx.Context())
md := metadata.MD{
grpc.ProxyMethodNameHeader: {ctx.Endpoint()},
grpc.RequestIdHeader: {requestid.FromContext(ctx.Context())},
requestid.Header: {requestId},
}
if !p.skipAuth {
authData, err := ctx.GetAuthData()
if err != nil {
@@ -93,13 +95,13 @@ func (p Grpc) Handle(ctx *request.Context) error {
Body: &isp.Message_BytesBody{BytesBody: body},
})
if err != nil {
return p.handleError(err, ctx.ResponseWriter())
return p.handleError(err, ctx.ResponseWriter(), ctx.Endpoint())
}
return p.writeResponse(http.StatusOK, result.GetBytesBody(), ctx.ResponseWriter())
return p.writeResponse(http.StatusOK, result.GetBytesBody(), requestId, ctx.ResponseWriter())
}
func (p Grpc) handleError(err error, w http.ResponseWriter) error {
func (p Grpc) handleError(err error, w http.ResponseWriter, endpoint string) error {
status, ok := status.FromError(err)
if !ok {
return httperrors.New(
@@ -115,7 +117,7 @@ func (p Grpc) handleError(err error, w http.ResponseWriter) error {
case *isp.Message:
switch {
case typeOfDetail.GetBytesBody() != nil:
return p.writeResponse(statusCode, typeOfDetail.GetBytesBody(), w)
return p.writeResponse(statusCode, typeOfDetail.GetBytesBody(), "", w)
case typeOfDetail.GetListBody() != nil:
return p.writeProto(statusCode, typeOfDetail.GetListBody(), w)
case typeOfDetail.GetStructBody() != nil:
@@ -129,7 +131,7 @@ func (p Grpc) handleError(err error, w http.ResponseWriter) error {
return httperrors.New(
statusCode,
status.Message(),
status.Err(),
errors.WithMessagef(err, "isp-routing-service: proxy '%s'", endpoint),
)
}
@@ -138,11 +140,14 @@ func (p Grpc) writeProto(statusCode int, proto interface{}, w http.ResponseWrite
if err != nil {
return errors.WithMessage(err, "marshal grpc details to json")
}
return p.writeResponse(statusCode, data, w)
return p.writeResponse(statusCode, data, "", w)
}
func (p Grpc) writeResponse(statusCode int, data []byte, w http.ResponseWriter) error {
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 {
+5 -6
View File
@@ -12,13 +12,12 @@ import (
"isp-gate-service/httperrors"
"isp-gate-service/request"
"github.com/integration-system/isp-kit/grpc"
"github.com/integration-system/isp-kit/requestid"
"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,
@@ -91,7 +90,7 @@ func (p Http) Handle(ctx *request.Context) error {
}
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) error {
header.Set(grpc.RequestIdHeader, requestid.FromContext(ctx.Context()))
header.Set(requestid.Header, requestid.FromContext(ctx.Context()))
if !skipAuth {
authData, err := ctx.GetAuthData()
if err != nil {
@@ -102,9 +101,9 @@ func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) err
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()))
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId())) //nolint:canonicalheader
} else {
header.Del(xAdminIdHeader)
header.Del(xAdminIdHeader) //nolint:canonicalheader
}
}
return nil
-1
View File
@@ -25,7 +25,6 @@ func NewWs(hostManager HttpHostManager, skipAuth bool) Ws {
}
}
//nolint:gomnd
func (ws Ws) Handle(ctx *request.Context) error {
host, err := ws.hostManager.Next()
if err != nil {
+1 -1
View File
@@ -6,8 +6,8 @@ import (
"isp-gate-service/domain"
"github.com/integration-system/isp-kit/grpc/client"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/client"
)
const (
+1 -1
View File
@@ -4,8 +4,8 @@ import (
"context"
"time"
"github.com/integration-system/isp-kit/json"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/json"
"isp-gate-service/cache"
"isp-gate-service/domain"
)
-42
View File
@@ -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)
}
+58
View File
@@ -0,0 +1,58 @@
package repository
import (
"context"
"time"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/client"
"isp-gate-service/entity"
)
const (
incrementEndpoint = "isp-lock-service/daily_limit/increment"
rateLimitEndpoint = "isp-lock-service/rate_limit"
)
type Locker struct {
cli *client.Client
}
func NewLocker(cli *client.Client) Locker {
return Locker{
cli: cli,
}
}
func (r Locker) Increment(ctx context.Context, key string, today time.Time) (int64, error) {
resp := new(entity.IncrementResponse)
err := r.cli.Invoke(incrementEndpoint).
JsonRequestBody(entity.IncrementRequest{
Key: key,
Today: today,
}).
JsonResponseBody(resp).
Do(ctx)
switch {
case err != nil:
return 0, errors.WithMessagef(err, "invoke isp-lock-service: '%s'", incrementEndpoint)
default:
return int64(resp.Value), nil //nolint:gosec
}
}
func (r Locker) IsAllowRequestPerSecond(ctx context.Context, key string, rate int) (*entity.RateLimiterResponse, error) {
resp := new(entity.RateLimiterResponse)
err := r.cli.Invoke(rateLimitEndpoint).
JsonRequestBody(entity.RateLimiterRequest{
Key: key,
MaxRps: rate,
}).
JsonResponseBody(resp).
Do(ctx)
if err != nil {
return nil, errors.WithMessagef(err, "invoke isp-lock-service: '%s'", rateLimitEndpoint)
}
return resp, nil
}
+1 -1
View File
@@ -4,8 +4,8 @@ package repository
import (
"context"
"github.com/integration-system/isp-kit/grpc/client"
"github.com/pkg/errors"
"github.com/txix-open/isp-kit/grpc/client"
"isp-gate-service/domain"
)
-37
View File
@@ -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)
}
+4 -3
View File
@@ -4,10 +4,11 @@ import (
"context"
"time"
"github.com/integration-system/isp-kit/json"
"isp-gate-service/domain"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
"isp-gate-service/domain"
"github.com/txix-open/isp-kit/json"
)
type RedisAuthCache struct {
@@ -34,7 +35,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
return nil, errors.WithMessage(err, "pipelined")
}
data, err := results[1].(*redis.StringCmd).Result()
data, err := results[1].(*redis.StringCmd).Result() // nolint: forcetypeassert
if errors.Is(err, redis.Nil) {
return nil, domain.ErrAuthenticationCacheMiss
}
+1 -1
View File
@@ -33,7 +33,7 @@ func (r RedisAuthzCache) Get(ctx context.Context, applicationId int, endpoint st
return false, errors.WithMessage(err, "pipelined")
}
_, err = result[1].(*redis.StringCmd).Result()
_, err = result[1].(*redis.StringCmd).Result() // nolint: forcetypeassert
if errors.Is(err, redis.Nil) {
return false, nil
}
+42 -5
View File
@@ -2,27 +2,34 @@ package routes
import (
"context"
"fmt"
"isp-gate-service/middleware"
"strings"
"github.com/integration-system/isp-kit/cluster"
"github.com/txix-open/isp-kit/cluster"
)
type Routes struct {
allEndpoints map[string]bool
innerEndpoints map[string]bool
requiredPermissions map[string]string
}
func NewRoutes() *Routes {
return &Routes{
allEndpoints: make(map[string]bool),
innerEndpoints: make(map[string]bool),
requiredPermissions: make(map[string]string),
}
}
func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig) error {
newAllEndpoints := make(map[string]bool)
newInnerMethods := make(map[string]bool)
newRequiredPermissions := make(map[string]string)
for _, backend := range routes {
for _, v := range backend.Endpoints {
newAllEndpoints[v.Path] = true
if v.Inner {
newInnerMethods[v.Path] = true
}
@@ -33,17 +40,47 @@ func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig
}
}
s.allEndpoints = newAllEndpoints
s.innerEndpoints = newInnerMethods
s.requiredPermissions = newRequiredPermissions
return nil
}
func (s *Routes) IsInnerEndpoint(path string) bool {
return s.innerEndpoints[path]
func (s *Routes) ResolveEndpoint(path string, cfg middleware.EntryPointConfig) string {
if cfg.WithPrefix {
return path
}
prefix := fmt.Sprintf("%s/", cfg.PathPrefix)
noPrefixPath := strings.TrimPrefix(path, prefix)
ok := s.allEndpoints[noPrefixPath]
if ok {
return noPrefixPath
}
invertedLeadingSlash := invertLeadingSlash(noPrefixPath)
ok = s.allEndpoints[invertedLeadingSlash]
if ok {
return invertedLeadingSlash
}
return noPrefixPath // pdp-webapi-service(анонсирует вот такой ендпоинт GET /api/:token/profile/me/:blocks) hack =(
}
func (s *Routes) RequiredAdminPermission(path string) (string, bool) {
perm, ok := s.requiredPermissions[path]
func (s *Routes) IsInnerEndpoint(endpoint string) bool {
return s.innerEndpoints[endpoint]
}
func (s *Routes) RequiredAdminPermission(endpoint string) (string, bool) {
perm, ok := s.requiredPermissions[endpoint]
return perm, ok
}
func invertLeadingSlash(path string) string {
path, withoutSlash := strings.CutPrefix(path, "/")
if withoutSlash {
return path
}
return "/" + path
}
+11 -4
View File
@@ -2,6 +2,7 @@ package service
import (
"context"
"fmt"
"time"
"github.com/pkg/errors"
@@ -9,7 +10,7 @@ import (
)
type DailyLimitRepo interface {
Increment(ctx context.Context, applicationId int, today time.Time) (int64, error)
Increment(ctx context.Context, key string, today time.Time) (int64, error)
}
type DailyLimit struct {
@@ -29,15 +30,21 @@ func NewDailyLimit(repo DailyLimitRepo, configs []conf.DailyLimit) DailyLimit {
}
func (s DailyLimit) IncrementAndCheck(ctx context.Context, applicationId int) (bool, error) {
max, ok := s.limits[applicationId]
limit, ok := s.limits[applicationId]
if !ok {
return true, nil
}
newValue, err := s.repo.Increment(ctx, applicationId, time.Now())
key := s.key(applicationId, time.Now())
newValue, err := s.repo.Increment(ctx, key, time.Now())
if err != nil {
return false, errors.WithMessage(err, "increment")
}
return newValue <= max, nil
return newValue <= limit, nil
}
func (s DailyLimit) key(applicationId int, today time.Time) string {
y, m, d := today.Date()
return fmt.Sprintf("isp-gate-service::daily-limit::%d:%d-%d-%d", applicationId, y, m, d)
}
+17 -6
View File
@@ -2,22 +2,24 @@ package service
import (
"context"
"fmt"
"github.com/pkg/errors"
"isp-gate-service/conf"
"isp-gate-service/domain"
"isp-gate-service/entity"
)
type ThrottlingRepo interface {
IsAllowRequestPerSecond(ctx context.Context, applicationId int, rate int) (*domain.RateLimitResult, error)
type LockRepo interface {
IsAllowRequestPerSecond(ctx context.Context, key string, rate int) (*entity.RateLimiterResponse, error)
}
type Throttling struct {
repo ThrottlingRepo
repo LockRepo
limits map[int]int
}
func NewThrottling(repo ThrottlingRepo, configs []conf.Throttling) Throttling {
func NewThrottling(repo LockRepo, configs []conf.Throttling) Throttling {
limits := make(map[int]int)
for _, config := range configs {
limits[config.ApplicationId] = config.RequestsPerSeconds
@@ -38,10 +40,19 @@ func (s Throttling) AllowRateLimit(ctx context.Context, applicationId int) (*dom
}, nil
}
result, err := s.repo.IsAllowRequestPerSecond(ctx, applicationId, rate)
key := s.key(applicationId)
result, err := s.repo.IsAllowRequestPerSecond(ctx, key, rate)
if err != nil {
return nil, errors.WithMessage(err, "is allow request per second")
}
return result, nil
return &domain.RateLimitResult{
Allow: result.Allow,
Remaining: result.Remaining,
RetryAfter: result.RetryAfter,
}, nil
}
func (s Throttling) key(applicationId int) string {
return fmt.Sprintf("isp-gate-service::rate-limit::%d", applicationId)
}
+91 -69
View File
@@ -8,28 +8,29 @@ import (
"net/url"
"strconv"
"testing"
"time"
etp "github.com/integration-system/isp-etp-go/v2"
etpcli "github.com/integration-system/isp-etp-go/v2/client"
"github.com/integration-system/isp-kit/cluster"
"github.com/integration-system/isp-kit/http/httpcli"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/require"
"isp-gate-service/assembly"
"isp-gate-service/conf"
"isp-gate-service/domain"
"isp-gate-service/routes"
"github.com/stretchr/testify/require"
"github.com/txix-open/etp/v3"
"github.com/txix-open/etp/v3/msg"
"github.com/txix-open/isp-kit/cluster"
"github.com/txix-open/isp-kit/http/httpcli"
"github.com/google/uuid"
"github.com/integration-system/isp-kit/grpc"
"github.com/integration-system/isp-kit/grpc/client"
"github.com/integration-system/isp-kit/lb"
"github.com/integration-system/isp-kit/log"
"github.com/integration-system/isp-kit/requestid"
"github.com/integration-system/isp-kit/test"
"github.com/integration-system/isp-kit/test/grpct"
"github.com/integration-system/isp-kit/test/httpt"
"github.com/stretchr/testify/suite"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/client"
"github.com/txix-open/isp-kit/lb"
"github.com/txix-open/isp-kit/log"
"github.com/txix-open/isp-kit/requestid"
"github.com/txix-open/isp-kit/test"
"github.com/txix-open/isp-kit/test/grpct"
"github.com/txix-open/isp-kit/test/httpt"
"google.golang.org/grpc/metadata"
)
@@ -47,7 +48,7 @@ type HappyPathTestSuite struct {
func (s *HappyPathTestSuite) TestGrpcProxy() {
test, require := test.New(s.T())
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
config, systemCli, adminCli := s.commonDependencies(test)
requestId := requestid.Next()
targetService, targetCli := grpct.NewMock(test)
@@ -70,12 +71,21 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
require.NoError(err)
require.EqualValues("1", adminId)
return response{Id: req.Id} //nolint:gosimple
return response{Id: req.Id}
})
targetClients := map[string]*client.Client{"target": targetCli}
logger, err := log.New(log.WithLevel(log.DebugLevel))
require.NoError(err)
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(), systemCli, adminCli)
routes := routes.NewRoutes()
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
Endpoints: []cluster.EndpointDescriptor{{
Path: "endpoint",
}},
}})
require.NoError(err)
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil)
locations := []conf.Location{{
SkipAuth: false,
@@ -83,7 +93,7 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
Protocol: "grpc",
TargetModule: "target",
}}
handler, err := locator.Handler(config, locations, redisCli)
handler, err := locator.Handler(config, locations)
require.NoError(err)
srv := httptest.NewServer(handler)
@@ -104,26 +114,35 @@ func (s *HappyPathTestSuite) TestGrpcProxy() {
func (s *HappyPathTestSuite) TestHttpProxy() {
test, require := test.New(s.T())
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
config, systemCli, adminCli := s.commonDependencies(test)
requestId := requestid.Next()
targetService := httpt.NewMock(test)
targetService.POST("/endpoint", func(ctx context.Context, httpReq *http.Request, req request) response {
assertHeaders(require, requestId, ctx, httpReq.Header)
return response{Id: req.Id} //nolint:gosimple
return response{Id: req.Id}
})
targetUrl, err := url.Parse(targetService.BaseURL())
require.NoError(err)
rr := lb.NewRoundRobin([]string{targetUrl.Host})
targetClients := map[string]*lb.RoundRobin{"target": rr}
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes.NewRoutes(), systemCli, adminCli)
routes := routes.NewRoutes()
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
Endpoints: []cluster.EndpointDescriptor{{
Path: "/endpoint",
}},
}})
require.NoError(err)
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil)
locations := []conf.Location{{
SkipAuth: false,
PathPrefix: "/api",
Protocol: "http",
TargetModule: "target",
}}
handler, err := locator.Handler(config, locations, redisCli)
handler, err := locator.Handler(config, locations)
require.NoError(err)
srv := httptest.NewServer(handler)
@@ -144,46 +163,50 @@ func (s *HappyPathTestSuite) TestHttpProxy() {
func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
test, require := test.New(s.T())
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
config, systemCli, adminCli := s.commonDependencies(test)
requestId := requestid.Next()
wsServer := etp.NewServer(context.Background(), etp.ServerConfig{
ConnectionReadLimit: 2048,
InsecureSkipVerify: true,
})
wsServer.OnWithAck("hello", func(conn etp.Conn, data []byte) []byte {
headers := conn.RemoteHeader()
ctx := requestid.ToContext(context.Background(), headers.Get("x-request-id"))
assertHeaders(require, requestId, ctx, headers)
require.EqualValues("data", string(data))
return []byte("world")
wsServer := etp.NewServer(etp.WithServerReadLimit(2048))
wsServer.On("hello", wsEventHandlerMock{
requestId: requestId,
require: require,
t: test.T(),
})
wsMux := http.NewServeMux()
wsMux.Handle("/service", http.HandlerFunc(func(writer http.ResponseWriter, r *http.Request) {
wsServer.ServeHttp(writer, r)
wsServer.ServeHTTP(writer, r)
}))
targetService := httptest.NewServer(wsMux)
targetUrl, err := url.Parse(targetService.URL)
require.NoError(err)
rr := lb.NewRoundRobin([]string{targetUrl.Host})
targetClients := map[string]*lb.RoundRobin{"target": rr}
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes.NewRoutes(), systemCli, adminCli)
routes := routes.NewRoutes()
err = routes.ReceiveRoutes(s.T().Context(), cluster.RoutingConfig{{
Endpoints: []cluster.EndpointDescriptor{{
Path: "/service",
}},
}})
require.NoError(err)
locator := assembly.NewLocator(test.Logger(), nil, targetClients, routes, systemCli, adminCli, nil)
locations := []conf.Location{{
SkipAuth: false,
PathPrefix: "/ws",
Protocol: "ws",
TargetModule: "target",
}}
handler, err := locator.Handler(config, locations, redisCli)
handler, err := locator.Handler(config, locations)
require.NoError(err)
srv := httptest.NewServer(handler)
cli := etpcli.NewClient(etpcli.Config{
HttpHeaders: map[string][]string{
cli := etp.NewClient(etp.WithClientDialOptions(&etp.DialOptions{
HTTPHeader: map[string][]string{
"x-request-id": {requestId},
},
})
}))
requestUrl, err := url.Parse(srv.URL)
require.NoError(err)
requestUrl.Path = "ws/service"
@@ -193,26 +216,42 @@ func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
}.Encode()
err = cli.Dial(context.Background(), requestUrl.String())
require.NoError(err)
resp, err := cli.EmitWithAck(context.Background(), "hello", []byte("data"))
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
defer cancel()
resp, err := cli.EmitWithAck(ctx, "hello", []byte("data"))
require.NoError(err)
require.EqualValues("world", string(resp))
err = cli.Close()
require.NoError(err)
}
type wsEventHandlerMock struct {
requestId string
require *require.Assertions
t require.TestingT
}
func (s wsEventHandlerMock) Handle(_ context.Context, conn *etp.Conn, event msg.Event) []byte {
headers := conn.HttpRequest().Header
ctx := requestid.ToContext(context.Background(), headers.Get("x-request-id"))
assertHeaders(s.require, s.requestId, ctx, headers)
require.EqualValues(s.t, "data", event.Data)
return []byte("world")
}
func (s *HappyPathTestSuite) TestAdminAuthorization() {
test, require := test.New(s.T())
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
config, systemCli, adminCli := s.commonDependencies(test)
targetService, targetCli := grpct.NewMock(test)
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
return response{Id: req.Id} //nolint:gosimple
return response{Id: req.Id}
})
targetClients := map[string]*client.Client{"target": targetCli}
logger, err := log.New(log.WithLevel(log.DebugLevel))
require.NoError(err)
routes := routes.NewRoutes()
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli)
locator := assembly.NewLocator(logger, targetClients, nil, routes, systemCli, adminCli, nil)
locations := []conf.Location{{
SkipAuth: false,
@@ -220,7 +259,7 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
Protocol: "grpc",
TargetModule: "target",
}}
handler, err := locator.Handler(config, locations, redisCli)
handler, err := locator.Handler(config, locations)
require.NoError(err)
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
@@ -264,32 +303,15 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
}
// nolint:ireturn
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, redis.UniversalClient, *client.Client, *client.Client) {
require := test.Assert()
redisCli := NewRedis(test)
ctx := context.Background()
s.T().Cleanup(func() {
_, err := redisCli.Pipelined(ctx, func(p redis.Pipeliner) error {
p.Select(ctx, 0)
p.FlushDB(ctx)
p.Select(ctx, 1)
p.FlushDB(ctx)
p.Select(ctx, 2)
p.FlushDB(ctx)
return nil
})
require.NoError(err)
})
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, *client.Client, *client.Client) {
config := conf.Remote{
Redis: &conf.Redis{Address: redisCli.address},
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true,
SkipBodyLoggingEndpointPrefixes: []string{"endpoint"}},
Caching: conf.Caching{AuthorizationDataInSec: 1, AuthenticationDataInSec: 1},
DailyLimits: []conf.DailyLimit{{ApplicationId: 1, RequestsPerDay: 100}},
Throttling: []conf.Throttling{{ApplicationId: 1, RequestsPerSeconds: 100}},
Caching: conf.Caching{AuthorizationDataInSec: 1, AuthenticationDataInSec: 1},
DailyLimits: []conf.DailyLimit{{ApplicationId: 1, RequestsPerDay: 100}},
Throttling: []conf.Throttling{{ApplicationId: 1, RequestsPerSeconds: 100}},
EnableClientRequestIdForwarding: true,
}
systemService, systemCli := grpct.NewMock(test)
@@ -322,7 +344,7 @@ func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, r
return domain.AdminAuthorizeResponse{Authorized: false}
})
return config, redisCli, systemCli, adminCli
return config, systemCli, adminCli
}
func TestHappyPathTestSuite(t *testing.T) {
+9 -10
View File
@@ -11,11 +11,11 @@ import (
"isp-gate-service/domain"
"isp-gate-service/routes"
"github.com/integration-system/isp-kit/grpc"
"github.com/integration-system/isp-kit/grpc/client"
endpoint2 "github.com/integration-system/isp-kit/grpc/endpoint"
"github.com/integration-system/isp-kit/grpc/isp"
"github.com/integration-system/isp-kit/log"
"github.com/txix-open/isp-kit/grpc"
"github.com/txix-open/isp-kit/grpc/client"
endpoint2 "github.com/txix-open/isp-kit/grpc/endpoint"
"github.com/txix-open/isp-kit/grpc/isp"
"github.com/txix-open/isp-kit/log"
)
type request struct {
@@ -46,7 +46,6 @@ func main() {
})
}()
config := conf.Remote{
Redis: &conf.Redis{Address: "localhost:6379"},
Http: conf.Http{MaxRequestBodySizeInMb: 1, ProxyTimeoutInSec: 15},
Logging: conf.Logging{LogLevel: log.DebugLevel, RequestLogEnable: true, BodyLogEnable: true},
Caching: conf.Caching{AuthorizationDataInSec: 15, AuthenticationDataInSec: 15},
@@ -85,14 +84,14 @@ func main() {
})
targetClients := map[string]*client.Client{"target": targetCli}
logger, _ = log.New(log.WithLevel(log.DebugLevel))
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(), systemCli, adminCli)
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(), systemCli, adminCli, nil)
locations := []conf.Location{{
SkipAuth: false,
PathPrefix: "/api",
Protocol: "grpc",
TargetModule: "target",
}}
handler, _ := locator.Handler(config, locations, redisCli)
handler, _ := locator.Handler(config, locations)
srv := &http.Server{
Addr: "localhost:8000",
@@ -102,7 +101,7 @@ func main() {
}
func TestServer(service isp.BackendServiceServer) (*grpc.Server, *client.Client, *client.Client) {
listener, _ := net.Listen("tcp", "127.0.0.1:")
listener, _ := net.Listen("tcp", "127.0.0.1:") // nolint:noctx
srv := grpc.NewServer()
sysCli, _ := client.Default()
adminCli, _ := client.Default()
@@ -119,7 +118,7 @@ func TestServer(service isp.BackendServiceServer) (*grpc.Server, *client.Client,
type MockServer struct {
srv *grpc.Server
logger log.Logger
mockEndpoints map[string]interface{}
mockEndpoints map[string]any
}
func NewMock(logger log.Logger) (*MockServer, *client.Client, *client.Client) {
-25
View File
@@ -1,25 +0,0 @@
package tests
import (
"fmt"
"github.com/integration-system/isp-kit/test"
"github.com/redis/go-redis/v9"
)
type Redis struct {
address string
redis.UniversalClient
}
func NewRedis(test *test.Test) Redis {
redisHost := test.Config().Optional().String("REDIS_HOST", "localhost")
redisPort := test.Config().Optional().String("REDIS_PORT", "6379")
addr := fmt.Sprintf("%s:%s", redisHost, redisPort)
cli := redis.NewClient(&redis.Options{Addr: addr})
return Redis{UniversalClient: cli, address: addr}
}
func (r Redis) Address() string {
return r.address
}