Compare commits
111
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4c76d33ef | ||
|
|
c1410dfef1 | ||
|
|
e2d8bd206c | ||
|
|
e47db8325c | ||
|
|
115aa7ffb7 | ||
|
|
6bb28160c8 | ||
|
|
aa3bed6ff8 | ||
|
|
447d719a16 | ||
|
|
e6bdec3f1e | ||
|
|
2d45f210db | ||
|
|
2aff6210b5 | ||
|
|
8d8369b4cc | ||
|
|
b1c16e4901 | ||
|
|
48cbb5c25d | ||
|
|
037c5f3fcd | ||
|
|
8c732a15e2 | ||
|
|
896dd36025 | ||
|
|
f0b8407479 | ||
|
|
c31c6aaf81 | ||
|
|
478b1ce5d7 | ||
|
|
453aa44148 | ||
|
|
9cd697a40d | ||
|
|
97d971fe14 | ||
|
|
68259fa369 | ||
|
|
1794041802 | ||
|
|
72e6bbe6d7 | ||
|
|
665641c88b | ||
|
|
b8d0c8e6d0 | ||
|
|
9a9e941580 | ||
|
|
675a917c0c | ||
|
|
7e10fb5217 | ||
|
|
6d67d3a331 | ||
|
|
e2d45ecdd2 | ||
|
|
61ca62db75 | ||
|
|
e0ab3236d4 | ||
|
|
910fb81a0e | ||
|
|
f1c597bde9 | ||
|
|
f25ded3015 | ||
|
|
3f8e03eda4 | ||
|
|
50a7e32b48 | ||
|
|
df31719324 | ||
|
|
cc5da31e59 | ||
|
|
2d936e543c | ||
|
|
91a14f9f23 | ||
|
|
08c4fb9bee | ||
|
|
dbaa347162 | ||
|
|
78f1fe43b9 | ||
|
|
ab95347767 | ||
|
|
7dd989bac2 | ||
|
|
b9dc101141 | ||
|
|
b3452ef5f6 | ||
|
|
41357efef0 | ||
|
|
b0cac278d2 | ||
|
|
75abb294c0 | ||
|
|
3d02fa550d | ||
|
|
8a9accbdeb | ||
|
|
88bff98d25 | ||
|
|
bdb0c50a22 | ||
|
|
0cf2b61ce3 | ||
|
|
6ec99e8d1f | ||
|
|
a6c1fcb972 | ||
|
|
ed91071557 | ||
|
|
6e1770273e | ||
|
|
5a462ef158 | ||
|
|
a3415470f7 | ||
|
|
909a26eace | ||
|
|
1ffe9e4a62 | ||
|
|
909ff91b2b | ||
|
|
4c7e96813c | ||
|
|
244d8fbdc2 | ||
|
|
745a4ae1e2 | ||
|
|
38806190e7 | ||
|
|
3e593f759d | ||
|
|
0672da8e9c | ||
|
|
bc53089fce | ||
|
|
7a22e3558e | ||
|
|
3c801a4c09 | ||
|
|
b4541f6c1b | ||
|
|
7acc4ebbd6 | ||
|
|
1665cc78cf | ||
|
|
8dcb8eef68 | ||
|
|
37c08f4500 | ||
|
|
8af97e56d7 | ||
|
|
f9138cbbfe | ||
|
|
4d81fe7a26 | ||
|
|
3d2cee1ae8 | ||
|
|
9eb5a3030b | ||
|
|
bad913e339 | ||
|
|
0e3c14d099 | ||
|
|
23ede62f24 | ||
|
|
fc80638b76 | ||
|
|
8f57203d96 | ||
|
|
422bdb9831 | ||
|
|
8c68ffea8c | ||
|
|
f802b2000d | ||
|
|
1a46b678ef | ||
|
|
3d97f3789a | ||
|
|
2a81e83b2e | ||
|
|
1a8ed4e8ea | ||
|
|
e3c3b86b04 | ||
|
|
a9e03750ab | ||
|
|
0edf80ffed | ||
|
|
5b115440f1 | ||
|
|
4fdf7c0ca2 | ||
|
|
f3934e038e | ||
|
|
3461f20510 | ||
|
|
b6baa9e5e7 | ||
|
|
3a4931ca8c | ||
|
|
70f5ebeb4b | ||
|
|
b29f3c6dcd | ||
|
|
fe6f1f5e5a |
No files matched your search
+1
-3
@@ -71,6 +71,4 @@ fabric.properties
|
||||
/vendor/
|
||||
google/
|
||||
package.json
|
||||
yarn.lock
|
||||
|
||||
conf/config_dev.yml
|
||||
yarn.lock
|
||||
+32
-60
@@ -1,66 +1,38 @@
|
||||
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
|
||||
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 #мнимая производительность в угоду читаемости
|
||||
- testpackage
|
||||
- goimports
|
||||
- depguard # не используется
|
||||
- gochecknoinits
|
||||
- gochecknoglobals
|
||||
- wsl
|
||||
- gocognit
|
||||
- godox # находит тудушки, не нужно
|
||||
- golint # подумать, может вернуть
|
||||
- stylecheck # подумать, может вернуть
|
||||
- goerr113
|
||||
|
||||
linters-settings:
|
||||
maligned:
|
||||
suggest-new: true
|
||||
lll:
|
||||
line-length: 140
|
||||
tab-width: 1
|
||||
funlen:
|
||||
lines: 80
|
||||
lll:
|
||||
line-length: 150
|
||||
cyclop:
|
||||
max-complexity: 15 #по умолчанию 10 мало
|
||||
revive:
|
||||
rules:
|
||||
- name: var-naming #отключаем Id -> ID
|
||||
disabled: true
|
||||
stylecheck:
|
||||
checks: #отключаем Id -> ID
|
||||
- "-ST1000"
|
||||
- "-ST1016"
|
||||
- "-ST1020"
|
||||
- "-ST1021"
|
||||
- "-ST1022"
|
||||
testifylint:
|
||||
disable:
|
||||
- compares
|
||||
statements: 40
|
||||
prealloc:
|
||||
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
|
||||
# True by default.
|
||||
simple: true
|
||||
range-loops: true # Report preallocation suggestions on range loops, true by default
|
||||
for-loops: true # Report preallocation suggestions on for loops, false by default
|
||||
gocritic:
|
||||
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
|
||||
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
|
||||
enabled-tags:
|
||||
- diagnostic
|
||||
- performance
|
||||
settings:
|
||||
hugeParam:
|
||||
sizeThreshold: 90
|
||||
@@ -1,64 +1,3 @@
|
||||
### v5.2.1
|
||||
* добавлен параметр для настройки проброса `requestId` из заголовка запроса
|
||||
* добавлено логирование содержимого заголовка `requestId` из заголовка запроса (поле `clientRequestId`)
|
||||
* обновлены зависимости
|
||||
* обновлена версия go до 1.23
|
||||
### v5.2.0
|
||||
* изменён формат логов с `snake_case` на `camelCase`
|
||||
### v5.1.1
|
||||
* добавлен параметр `withPrefix` в локальном конфиге для `location`, чтобы не обрезать путь при проксировании запроса
|
||||
### v5.1.0
|
||||
* обновлены зависимости (увеличены лимиты по семплированию логов, добавлена возможность конфигурировать семплирование)
|
||||
### v5.0.0
|
||||
* добавлена авторизация ендпоинтов администратора
|
||||
### v4.3.0
|
||||
* обновлены зависимости
|
||||
### v4.2.1
|
||||
* исправлено поведение `skipBodyLoggingEndpointPrefixes`
|
||||
### v4.2.0
|
||||
* новый параметр в remote_config: `skipBodyLoggingEndpointPrefixes`. Массив re. Если они есть в пути, то запрос не будет логироваться
|
||||
### v4.1.2
|
||||
* исправлена опция логирования тела запроса (при настройке ws могла отключаться)
|
||||
### v4.1.1
|
||||
* исправлена маршрутизация запросов
|
||||
### v4.1.0
|
||||
* обновлены зависимости
|
||||
* добавлена поддержка проксирования WebSocket `ws`
|
||||
### v4.0.0
|
||||
* реализована аутентификация токена администратора через msp-admin-service
|
||||
### v3.0.3
|
||||
* исправлено тело ответа grpc ошибок валидации
|
||||
* обновлены зависимости
|
||||
### v3.0.2
|
||||
* добавлен charset=utf-8 в заголовок ответа для grpc
|
||||
### v3.0.1
|
||||
* исправлено проксирование http с GET параметрами
|
||||
* исправлено логирование пути при проксировании HTTP
|
||||
### v3.0.0
|
||||
* реализация новой схемы аутентификации/авторизации
|
||||
### v2.8.3
|
||||
* use isp-kit logger instead local logger
|
||||
* use log string instead log any (common log type)
|
||||
* add replace grpc (isp-lib and isp-kit conflict)
|
||||
### v2.8.2
|
||||
* add file rotation
|
||||
### v2.8.1
|
||||
* add xml format support for new logger
|
||||
### v2.8.0
|
||||
* add new logger
|
||||
* remove journal
|
||||
* add identities to requests log
|
||||
### v2.7.6
|
||||
* updated dependencies
|
||||
* migrated to common local config
|
||||
### v2.7.5
|
||||
* updated dependencies
|
||||
### v2.7.4
|
||||
* updated isp-lib
|
||||
* updated isp-lib-test
|
||||
### v2.7.3
|
||||
* updated isp-lib
|
||||
* updated isp-event-lib
|
||||
## 2.7.2
|
||||
* fix accounting
|
||||
## 2.7.1
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package accounting
|
||||
|
||||
import (
|
||||
"isp-gate-service/accounting/state"
|
||||
"isp-gate-service/service/matcher"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type accountant struct {
|
||||
mx sync.Mutex
|
||||
matcher matcher.Matcher
|
||||
limitStates map[string]state.LimitState
|
||||
version int64
|
||||
}
|
||||
|
||||
func (app *accountant) Accept(method string) bool {
|
||||
patternArray := app.matcher.Match(method)
|
||||
stateStorage := make([]state.LimitState, len(patternArray))
|
||||
for i, pattern := range patternArray {
|
||||
stateStorage[i] = app.limitStates[pattern]
|
||||
}
|
||||
|
||||
app.mx.Lock()
|
||||
resp := state.Update(stateStorage)
|
||||
if resp {
|
||||
app.version++
|
||||
}
|
||||
app.mx.Unlock()
|
||||
return resp
|
||||
}
|
||||
|
||||
func (app *accountant) Snapshot() (map[string]state.Snapshot, int64) {
|
||||
app.mx.Lock()
|
||||
version := app.version
|
||||
snapshotLimitState := make(map[string]state.Snapshot, len(app.limitStates))
|
||||
for method, limitState := range app.limitStates {
|
||||
snapshotLimitState[method] = limitState.Export()
|
||||
}
|
||||
app.mx.Unlock()
|
||||
return snapshotLimitState, version
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package accounting
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"isp-gate-service/accounting/state"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/log_code"
|
||||
"isp-gate-service/model"
|
||||
"isp-gate-service/service/matcher"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var worker = &accountingWorker{
|
||||
accountingStorage: make(map[int32]Accounting),
|
||||
requestsStoring: make(map[int32]bool),
|
||||
}
|
||||
|
||||
type (
|
||||
Accounting interface {
|
||||
Accept(string) bool
|
||||
Snapshot() (map[string]state.Snapshot, int64)
|
||||
}
|
||||
|
||||
accountingWorker struct {
|
||||
accountingStorage map[int32]Accounting
|
||||
requestsStoring map[int32]bool
|
||||
}
|
||||
)
|
||||
|
||||
func NewConnectionConsumer(list []structure.AddressConfiguration) bool {
|
||||
accountingSetting := config.GetRemote().(*conf.RemoteConfig).AccountingSetting
|
||||
worker.init(accountingSetting)
|
||||
return true
|
||||
}
|
||||
|
||||
func ReceiveConfiguration(accountingSetting conf.Accounting) {
|
||||
worker.init(accountingSetting)
|
||||
}
|
||||
|
||||
func AcceptRequest(appId int32, path string) bool {
|
||||
if accouter, ok := worker.accountingStorage[appId]; ok {
|
||||
ok := accouter.Accept(path)
|
||||
if ok && worker.requestsStoring[appId] {
|
||||
storage.TakeRequest(appId, path, time.Now())
|
||||
}
|
||||
return ok
|
||||
} else {
|
||||
if worker.requestsStoring[appId] {
|
||||
storage.TakeRequest(appId, path, time.Now())
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func Close() {
|
||||
if snapshot != nil {
|
||||
snapshot.Stop()
|
||||
}
|
||||
if storage != nil {
|
||||
storage.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
func (w *accountingWorker) init(accountingSetting conf.Accounting) {
|
||||
Close()
|
||||
|
||||
newAccountingStorage := make(map[int32]Accounting)
|
||||
newRequestsStoringStorage := make(map[int32]bool)
|
||||
|
||||
if accountingSetting.Enable {
|
||||
for _, s := range accountingSetting.Setting {
|
||||
limitStates, patternArray := state.InitLimitState(s.Limits)
|
||||
accounting := w.recoveryAccounting(s.ApplicationId, limitStates, patternArray)
|
||||
|
||||
newAccountingStorage[s.ApplicationId] = accounting
|
||||
newRequestsStoringStorage[s.ApplicationId] = s.EnableStoring
|
||||
}
|
||||
w.requestsStoring = newRequestsStoringStorage
|
||||
w.accountingStorage = newAccountingStorage
|
||||
InitStoringTask(accountingSetting.Storing)
|
||||
InitSnapshotTask(accountingSetting.SnapshotTimeout)
|
||||
} else {
|
||||
w.requestsStoring = newRequestsStoringStorage
|
||||
w.accountingStorage = newAccountingStorage
|
||||
}
|
||||
}
|
||||
|
||||
func (w *accountingWorker) takeSnapshot() []entity.Snapshot {
|
||||
lastStorage := w.accountingStorage
|
||||
|
||||
response := make([]entity.Snapshot, 0, len(lastStorage))
|
||||
for appId, account := range lastStorage {
|
||||
limitState, version := account.Snapshot()
|
||||
response = append(response, entity.Snapshot{
|
||||
AppId: appId,
|
||||
LimitState: limitState,
|
||||
Version: version,
|
||||
})
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
func (w *accountingWorker) recoveryAccounting(appId int32, limitStates map[string]state.LimitState, patternArray []string) *accountant {
|
||||
var (
|
||||
version = int64(0)
|
||||
importNotComplete = true
|
||||
)
|
||||
|
||||
dbSnapshot, err := model.SnapshotRep.GetByApplication(appId)
|
||||
if err != nil {
|
||||
log.Warn(log_code.ErrorSnapshotAccounting, err)
|
||||
}
|
||||
|
||||
if cache, ok := w.accountingStorage[appId]; ok {
|
||||
cashLimitState, cashVersion := cache.Snapshot()
|
||||
|
||||
if dbSnapshot == nil || dbSnapshot.Version < cashVersion {
|
||||
version = cashVersion
|
||||
w.importLimitState(limitStates, cashLimitState)
|
||||
importNotComplete = false
|
||||
}
|
||||
}
|
||||
|
||||
if dbSnapshot != nil && importNotComplete {
|
||||
version = dbSnapshot.Version
|
||||
w.importLimitState(limitStates, dbSnapshot.LimitState)
|
||||
}
|
||||
|
||||
return &accountant{
|
||||
mx: sync.Mutex{},
|
||||
matcher: matcher.NewCacheableMatcher(patternArray),
|
||||
limitStates: limitStates,
|
||||
version: version,
|
||||
}
|
||||
}
|
||||
|
||||
func (w *accountingWorker) importLimitState(limitStates map[string]state.LimitState, snapshot map[string]state.Snapshot) {
|
||||
for method, limitState := range limitStates {
|
||||
if oldState, ok := snapshot[method]; ok {
|
||||
limitState.Import(oldState)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
//nolint
|
||||
package accounting
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/model"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
accountingSetting = conf.Accounting{
|
||||
Enable: true,
|
||||
SnapshotTimeout: "290ms",
|
||||
Setting: []conf.AccountingSetting{
|
||||
{ApplicationId: 1, Limits: []conf.LimitSetting{
|
||||
{Pattern: "mdm-master/group/method", MaxCount: 1, Timeout: "90ms"},
|
||||
{Pattern: "mdm-master/group3/method", MaxCount: 10, Timeout: "10s"},
|
||||
{Pattern: "mdm-master/group3/*", MaxCount: 5, Timeout: "10s"},
|
||||
{Pattern: "mdm-master/group4/method", MaxCount: 2, Timeout: "0s"},
|
||||
{Pattern: "mdm-master/group5/method", MaxCount: 3, Timeout: "10s"},
|
||||
{Pattern: "mdm-master/group6/method", MaxCount: 5, Timeout: "10s"},
|
||||
}},
|
||||
{ApplicationId: 2, Limits: []conf.LimitSetting{
|
||||
{Pattern: "mdm-master/group/method", MaxCount: 0, Timeout: "10s"},
|
||||
}},
|
||||
},
|
||||
Storing: conf.StoringSetting{
|
||||
Size: 100,
|
||||
Timeout: "1h",
|
||||
},
|
||||
}
|
||||
|
||||
reqExample = []struct {
|
||||
appId int32
|
||||
path []string
|
||||
}{
|
||||
0: {appId: 1, path: []string{
|
||||
"mdm-master/group/method", "mdm-master/group/method", "mdm-master/group/method",
|
||||
"mdm-master/group/method", "mdm-master/group/method", "mdm-master/group/method",
|
||||
}},
|
||||
|
||||
1: {appId: 2, path: []string{
|
||||
"mdm-master/group3/method", "mdm-master/group/method", "mdm-master/group3/method",
|
||||
"mdm-master/group/method", "mdm-master/group3/method", "mdm-master/group/method",
|
||||
}},
|
||||
|
||||
2: {appId: 1, path: []string{
|
||||
"mdm-master/group3/method", "mdm-master/group3/method", "mdm-master/group3/method",
|
||||
"mdm-master/group3/method", "mdm-master/group3/method", "mdm-master/group3/method",
|
||||
}},
|
||||
3: {appId: 1, path: []string{
|
||||
"mdm-master/group4/method", "mdm-master/group4/method", "mdm-master/group4/method",
|
||||
"mdm-master/group4/method", "mdm-master/group4/method", "mdm-master/group4/method",
|
||||
}},
|
||||
4: {appId: 1, path: []string{
|
||||
"mdm-master/group5/method", "mdm-master/group5/method", "mdm-master/group5/method",
|
||||
}},
|
||||
}
|
||||
)
|
||||
|
||||
func TestAccounting(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
snapshotRep := newSnapshotRepository(false)
|
||||
model.SnapshotRep = snapshotRep
|
||||
worker = &accountingWorker{
|
||||
accountingStorage: make(map[int32]Accounting),
|
||||
requestsStoring: make(map[int32]bool),
|
||||
}
|
||||
worker.init(accountingSetting)
|
||||
|
||||
req := reqExample[4]
|
||||
for _, path := range req.path {
|
||||
a.True(AcceptRequest(req.appId, path))
|
||||
}
|
||||
|
||||
expected := true
|
||||
req = reqExample[0]
|
||||
for _, path := range req.path {
|
||||
a.Equal(expected, AcceptRequest(req.appId, path))
|
||||
expected = !expected
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
|
||||
//expected == true
|
||||
req = reqExample[1]
|
||||
for _, path := range req.path {
|
||||
a.Equal(expected, AcceptRequest(req.appId, path))
|
||||
expected = !expected
|
||||
}
|
||||
|
||||
req = reqExample[2]
|
||||
expectedArray := []bool{true, true, true, true, true, false}
|
||||
for key, path := range req.path {
|
||||
a.Equal(expectedArray[key], AcceptRequest(req.appId, path))
|
||||
}
|
||||
|
||||
//expected == true
|
||||
req = reqExample[3]
|
||||
for _, path := range req.path {
|
||||
a.Equal(expected, AcceptRequest(req.appId, path))
|
||||
}
|
||||
|
||||
worker.init(accountingSetting)
|
||||
|
||||
req = reqExample[4]
|
||||
for _, path := range req.path {
|
||||
a.False(AcceptRequest(req.appId, path))
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorker_recoveryAccounting(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
snapshotRep := newSnapshotRepository(true)
|
||||
model.SnapshotRep = snapshotRep
|
||||
|
||||
worker = &accountingWorker{
|
||||
accountingStorage: make(map[int32]Accounting),
|
||||
requestsStoring: make(map[int32]bool),
|
||||
}
|
||||
secondWorker := &accountingWorker{
|
||||
accountingStorage: make(map[int32]Accounting),
|
||||
requestsStoring: make(map[int32]bool),
|
||||
}
|
||||
|
||||
worker.init(accountingSetting)
|
||||
secondWorker.init(accountingSetting)
|
||||
|
||||
appId := int32(1)
|
||||
request := "1_3_5"
|
||||
for range request {
|
||||
a.True(AcceptRequest(appId, "mdm-master/group6/method"))
|
||||
}
|
||||
a.False(AcceptRequest(appId, "mdm-master/group6/method"))
|
||||
|
||||
time.Sleep(time.Millisecond * 300)
|
||||
a.True(snapshotRep.Wait())
|
||||
snapshot, err := model.SnapshotRep.GetByApplication(appId)
|
||||
a.NoError(err)
|
||||
a.NotNil(snapshot)
|
||||
a.Equal(len(request), int(snapshot.Version))
|
||||
|
||||
Close()
|
||||
worker = secondWorker
|
||||
worker.init(accountingSetting)
|
||||
a.False(AcceptRequest(appId, "mdm-master/group6/method"))
|
||||
}
|
||||
|
||||
type snapshotRepository struct {
|
||||
enableWaitGroup bool
|
||||
wg sync.WaitGroup
|
||||
mx sync.Mutex
|
||||
cache map[int32]entity.Snapshot
|
||||
}
|
||||
|
||||
func newSnapshotRepository(enableWaitGroup bool) *snapshotRepository {
|
||||
return &snapshotRepository{
|
||||
enableWaitGroup: enableWaitGroup,
|
||||
wg: sync.WaitGroup{},
|
||||
cache: make(map[int32]entity.Snapshot),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *snapshotRepository) Wait() bool {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
r.wg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
select {
|
||||
case <-done:
|
||||
return true
|
||||
case <-time.After(time.Second):
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (r *snapshotRepository) GetByApplication(appId int32) (*entity.Snapshot, error) {
|
||||
r.mx.Lock()
|
||||
defer r.mx.Unlock()
|
||||
|
||||
if snapshot, ok := r.cache[appId]; ok {
|
||||
return &snapshot, nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r *snapshotRepository) Update(list []entity.Snapshot) error {
|
||||
r.mx.Lock()
|
||||
defer r.mx.Unlock()
|
||||
|
||||
if r.enableWaitGroup {
|
||||
r.wg.Add(1)
|
||||
defer r.wg.Done()
|
||||
}
|
||||
|
||||
for _, s := range list {
|
||||
r.cache[s.AppId] = s
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package accounting
|
||||
|
||||
import (
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/integration-system/isp-log/stdcodes"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/log_code"
|
||||
"isp-gate-service/model"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var snapshot *snapshotTask
|
||||
|
||||
type snapshotTask struct {
|
||||
mx sync.Mutex
|
||||
wg sync.WaitGroup
|
||||
|
||||
process bool
|
||||
timeout <-chan time.Time
|
||||
close chan bool
|
||||
}
|
||||
|
||||
func InitSnapshotTask(snapshotTimeout string) {
|
||||
timeout, err := time.ParseDuration(snapshotTimeout)
|
||||
if err != nil {
|
||||
log.Fatal(stdcodes.ModuleInvalidRemoteConfig, err)
|
||||
}
|
||||
|
||||
snapshot = newSnapshotTask(timeout)
|
||||
}
|
||||
|
||||
func (t *snapshotTask) Stop() {
|
||||
t.mx.Lock()
|
||||
if t.process {
|
||||
snapshotList := worker.takeSnapshot()
|
||||
if len(snapshotList) != 0 {
|
||||
defer func() {
|
||||
t.wg.Add(1)
|
||||
t.unload(snapshotList)
|
||||
t.wg.Wait()
|
||||
}()
|
||||
}
|
||||
t.process = false
|
||||
t.close <- true
|
||||
}
|
||||
t.mx.Unlock()
|
||||
}
|
||||
|
||||
func (t *snapshotTask) run(timeout time.Duration) {
|
||||
defer t.wg.Done()
|
||||
t.timeout = time.After(timeout)
|
||||
for {
|
||||
select {
|
||||
case <-t.close:
|
||||
return
|
||||
case <-t.timeout:
|
||||
list := worker.takeSnapshot()
|
||||
if len(list) > 0 {
|
||||
t.wg.Add(1)
|
||||
go t.unload(list)
|
||||
}
|
||||
t.timeout = time.After(timeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *snapshotTask) unload(list []entity.Snapshot) {
|
||||
if err := model.SnapshotRep.Update(list); err != nil {
|
||||
log.Error(log_code.ErrorSnapshotAccounting, err)
|
||||
}
|
||||
t.wg.Done()
|
||||
}
|
||||
|
||||
func newSnapshotTask(timeout time.Duration) *snapshotTask {
|
||||
task := &snapshotTask{
|
||||
process: true,
|
||||
timeout: make(chan time.Time),
|
||||
close: make(chan bool),
|
||||
}
|
||||
task.wg.Add(1)
|
||||
go task.run(timeout)
|
||||
return task
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/integration-system/isp-log/stdcodes"
|
||||
"isp-gate-service/conf"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
LimitState interface {
|
||||
Import(Snapshot)
|
||||
Export() Snapshot
|
||||
check() (bool, int, time.Time)
|
||||
update(int, time.Time)
|
||||
}
|
||||
|
||||
Snapshot struct {
|
||||
Timeout time.Duration
|
||||
Datetime []time.Time
|
||||
Pattern string
|
||||
Pointer int
|
||||
}
|
||||
|
||||
updateRequest struct {
|
||||
pointer int
|
||||
requestTime time.Time
|
||||
}
|
||||
)
|
||||
|
||||
func InitLimitState(limits []conf.LimitSetting) (map[string]LimitState, []string) {
|
||||
limitStates := make(map[string]LimitState)
|
||||
patternArray := make([]string, len(limits))
|
||||
|
||||
for i, limit := range limits {
|
||||
timeout, err := time.ParseDuration(limit.Timeout)
|
||||
if err != nil {
|
||||
log.Fatal(stdcodes.ModuleInvalidRemoteConfig, err)
|
||||
}
|
||||
|
||||
if timeout == 0 && limit.MaxCount != 0 {
|
||||
limit.MaxCount = 1
|
||||
}
|
||||
patternArray[i] = limit.Pattern
|
||||
limitStates[limit.Pattern] = &limiter{
|
||||
timeout: timeout,
|
||||
datetime: make([]time.Time, limit.MaxCount),
|
||||
pattern: limit.Pattern,
|
||||
pointer: -1,
|
||||
}
|
||||
}
|
||||
return limitStates, patternArray
|
||||
}
|
||||
|
||||
func Update(states []LimitState) bool {
|
||||
update := make([]updateRequest, len(states))
|
||||
for i, st := range states {
|
||||
if ok, point, requestTime := st.check(); ok {
|
||||
update[i] = updateRequest{pointer: point, requestTime: requestTime}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for i, st := range states {
|
||||
u := update[i]
|
||||
st.update(u.pointer, u.requestTime)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type limiter struct {
|
||||
timeout time.Duration
|
||||
datetime []time.Time
|
||||
pattern string
|
||||
pointer int
|
||||
}
|
||||
|
||||
func (lim *limiter) Export() Snapshot {
|
||||
ls := *lim
|
||||
return Snapshot{
|
||||
Timeout: ls.timeout,
|
||||
Datetime: ls.datetime,
|
||||
Pattern: ls.pattern,
|
||||
Pointer: ls.pointer,
|
||||
}
|
||||
}
|
||||
|
||||
func (lim *limiter) Import(oldState Snapshot) {
|
||||
oldLim := limiter{
|
||||
timeout: oldState.Timeout,
|
||||
datetime: oldState.Datetime,
|
||||
pattern: oldState.Pattern,
|
||||
pointer: oldState.Pointer,
|
||||
}
|
||||
|
||||
lenOldDatetime := len(oldLim.datetime)
|
||||
lenNewDatetime := len(lim.datetime)
|
||||
|
||||
switch {
|
||||
case lenOldDatetime == lenNewDatetime:
|
||||
lim.datetime = oldLim.datetime
|
||||
lim.pointer = oldLim.pointer
|
||||
|
||||
case lenOldDatetime < lenNewDatetime:
|
||||
oldPointer := oldLim.pointer
|
||||
for i := range lim.datetime {
|
||||
oldLim.pointer++
|
||||
if oldLim.pointer >= len(oldLim.datetime) {
|
||||
oldLim.pointer = 0
|
||||
}
|
||||
|
||||
lim.datetime[i] = oldLim.datetime[oldLim.pointer]
|
||||
|
||||
if oldPointer == oldLim.pointer {
|
||||
lim.pointer = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
case lenOldDatetime > lenNewDatetime:
|
||||
for i := range lim.datetime {
|
||||
oldLim.pointer++
|
||||
if oldLim.pointer >= len(oldLim.datetime) {
|
||||
oldLim.pointer = 0
|
||||
}
|
||||
lim.datetime[i] = oldLim.datetime[oldLim.pointer]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (lim *limiter) check() (bool, int, time.Time) {
|
||||
if len(lim.datetime) == 0 {
|
||||
return false, 0, time.Time{}
|
||||
}
|
||||
if lim.timeout == 0 {
|
||||
return true, 0, time.Now()
|
||||
}
|
||||
|
||||
pointer := lim.pointer + 1
|
||||
if pointer >= len(lim.datetime) {
|
||||
pointer = 0
|
||||
}
|
||||
date := lim.datetime[pointer]
|
||||
requestTime := time.Now()
|
||||
account := requestTime.Sub(date) > lim.timeout
|
||||
|
||||
return account, pointer, requestTime
|
||||
}
|
||||
|
||||
func (lim *limiter) update(point int, requestTime time.Time) {
|
||||
lim.pointer = point
|
||||
lim.datetime[point] = requestTime
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//nolint
|
||||
package state
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLimiter(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
newLimiter := func(count int) *limiter {
|
||||
return &limiter{timeout: 5 * time.Second, pattern: "example", pointer: -1, datetime: make([]time.Time, count)}
|
||||
}
|
||||
|
||||
store12 := newLimiter(12)
|
||||
store10 := newLimiter(10)
|
||||
store7 := newLimiter(7)
|
||||
store5 := newLimiter(5)
|
||||
|
||||
for i := 0; i < 7; i++ {
|
||||
expectedTrue, pointer, reqTime := store10.check()
|
||||
a.True(expectedTrue)
|
||||
store10.update(pointer, reqTime)
|
||||
|
||||
expectedTrue, pointer, reqTime = store7.check()
|
||||
a.True(expectedTrue)
|
||||
store7.update(pointer, reqTime)
|
||||
}
|
||||
|
||||
expectedFalse, _, _ := store7.check()
|
||||
a.False(expectedFalse)
|
||||
|
||||
store12.Import(store7.Export())
|
||||
store5.Import(store10.Export())
|
||||
|
||||
a.Equal(store5.datetime[0], store10.datetime[store10.pointer+1])
|
||||
a.Equal(store12.datetime[0], store7.datetime[0])
|
||||
a.Equal(store12.datetime[store7.pointer], store7.datetime[store7.pointer])
|
||||
a.Equal(store12.datetime[store7.pointer+1], time.Time{})
|
||||
|
||||
expectedTrue, _, _ := store12.check()
|
||||
a.True(expectedTrue)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
expectedTrue, pointer, reqTime := store5.check()
|
||||
a.True(expectedTrue)
|
||||
store5.update(pointer, reqTime)
|
||||
}
|
||||
expectedFalse, _, _ = store5.check()
|
||||
a.False(expectedFalse)
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package accounting
|
||||
|
||||
import (
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/integration-system/isp-log/stdcodes"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/log_code"
|
||||
"isp-gate-service/model"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var storage *storingTask
|
||||
|
||||
type storingTask struct {
|
||||
buffer []entity.Request
|
||||
counter int
|
||||
|
||||
chanTimeout <-chan time.Time
|
||||
chanCounter chan []entity.Request
|
||||
chanClose chan bool
|
||||
|
||||
mx sync.Mutex
|
||||
wg sync.WaitGroup
|
||||
|
||||
process bool
|
||||
}
|
||||
|
||||
func InitStoringTask(setting conf.StoringSetting) {
|
||||
timeout, err := time.ParseDuration(setting.Timeout)
|
||||
if err != nil {
|
||||
log.Fatal(stdcodes.ModuleInvalidRemoteConfig, err)
|
||||
}
|
||||
|
||||
storage = newStoringTask(timeout, setting.Size)
|
||||
}
|
||||
|
||||
func (t *storingTask) TakeRequest(appId int32, method string, date time.Time) {
|
||||
t.mx.Lock()
|
||||
if !t.process {
|
||||
t.mx.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
t.buffer[t.counter] = entity.Request{
|
||||
AppId: appId,
|
||||
Method: method,
|
||||
CreatedAt: date,
|
||||
}
|
||||
|
||||
t.counter++
|
||||
if t.counter == len(t.buffer) {
|
||||
t.chanCounter <- t.buffer
|
||||
t.clearBuffer()
|
||||
}
|
||||
|
||||
t.mx.Unlock()
|
||||
}
|
||||
|
||||
func (t *storingTask) Stop() {
|
||||
t.mx.Lock()
|
||||
if t.process {
|
||||
if t.counter != 0 {
|
||||
buffer := t.clearBuffer()
|
||||
defer func() {
|
||||
t.wg.Add(1)
|
||||
t.unload(buffer)
|
||||
t.wg.Wait()
|
||||
}()
|
||||
}
|
||||
t.chanClose <- true
|
||||
t.process = false
|
||||
}
|
||||
t.mx.Unlock()
|
||||
}
|
||||
|
||||
func (t *storingTask) run(timeout time.Duration) {
|
||||
defer t.wg.Done()
|
||||
t.chanTimeout = time.After(timeout)
|
||||
for {
|
||||
select {
|
||||
case <-t.chanClose:
|
||||
return
|
||||
case cache := <-t.chanCounter:
|
||||
t.wg.Add(1)
|
||||
go t.unload(cache)
|
||||
t.chanTimeout = time.After(timeout)
|
||||
case <-t.chanTimeout:
|
||||
t.mx.Lock()
|
||||
if t.counter != 0 {
|
||||
buffer := t.clearBuffer()
|
||||
t.wg.Add(1)
|
||||
go t.unload(buffer)
|
||||
}
|
||||
t.mx.Unlock()
|
||||
t.chanTimeout = time.After(timeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *storingTask) unload(cache []entity.Request) {
|
||||
if err := model.RequestsRep.Insert(cache); err != nil {
|
||||
log.Error(log_code.ErrorUnloadAccounting, err)
|
||||
}
|
||||
t.wg.Done()
|
||||
}
|
||||
|
||||
func (t *storingTask) clearBuffer() []entity.Request {
|
||||
oldBuffer := t.buffer[:t.counter]
|
||||
oldLen := len(t.buffer)
|
||||
t.counter = 0
|
||||
t.buffer = make([]entity.Request, oldLen)
|
||||
return oldBuffer
|
||||
}
|
||||
|
||||
func newStoringTask(timeout time.Duration, bufSize int) *storingTask {
|
||||
task := &storingTask{
|
||||
mx: sync.Mutex{},
|
||||
counter: 0,
|
||||
buffer: make([]entity.Request, bufSize),
|
||||
process: true,
|
||||
chanTimeout: make(chan time.Time),
|
||||
chanCounter: make(chan []entity.Request),
|
||||
chanClose: make(chan bool),
|
||||
}
|
||||
task.wg.Add(1)
|
||||
go task.run(timeout)
|
||||
|
||||
return task
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
//nolint
|
||||
package accounting
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/entity"
|
||||
"isp-gate-service/model"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
timeoutSetting = conf.StoringSetting{
|
||||
Size: 3,
|
||||
Timeout: "30ms",
|
||||
}
|
||||
|
||||
bufferSetting = conf.StoringSetting{
|
||||
Size: 3,
|
||||
Timeout: "2s",
|
||||
}
|
||||
|
||||
unloadSetting = conf.StoringSetting{
|
||||
Size: 3,
|
||||
Timeout: "100ms",
|
||||
}
|
||||
)
|
||||
|
||||
func initStoring(setting conf.StoringSetting) *requestsRepository {
|
||||
repository := &requestsRepository{cache: make([]entity.Request, 0), wg: &sync.WaitGroup{}}
|
||||
model.RequestsRep = repository
|
||||
InitStoringTask(setting)
|
||||
return repository
|
||||
}
|
||||
|
||||
func wait(wg *sync.WaitGroup) bool {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
select {
|
||||
case <-done:
|
||||
return true
|
||||
case <-time.After(time.Second):
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoringTask_Stop(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
rep := initStoring(bufferSetting)
|
||||
|
||||
rep.wg.Add(2)
|
||||
for i, j := range []string{"Stop_1", "Stop_2", "Stop_3", "Stop_4", "Stop_5"} {
|
||||
storage.TakeRequest(int32(i), j, time.Now())
|
||||
}
|
||||
storage.Stop()
|
||||
a.Len(rep.cache, 5)
|
||||
}
|
||||
|
||||
func TestStoringTask_Buffer(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
rep := initStoring(bufferSetting)
|
||||
|
||||
rep.wg.Add(1)
|
||||
for i, j := range []string{"Buffer_1", "Buffer_2", "Buffer_3", "Buffer_4", "Buffer_5"} {
|
||||
storage.TakeRequest(int32(i), j, time.Now())
|
||||
}
|
||||
a.True(wait(rep.wg))
|
||||
a.Len(rep.cache, 3)
|
||||
}
|
||||
|
||||
func TestStoringTask_Timeout(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
rep := initStoring(timeoutSetting)
|
||||
|
||||
rep.wg.Add(1)
|
||||
for i, j := range []string{"Timeout_1", "Timeout_2"} {
|
||||
storage.TakeRequest(int32(i), j, time.Now())
|
||||
}
|
||||
a.True(wait(rep.wg))
|
||||
a.Len(rep.cache, 2)
|
||||
}
|
||||
|
||||
func TestStoringTask_Unload(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
rep := initStoring(unloadSetting)
|
||||
|
||||
rep.wg.Add(2)
|
||||
for i, j := range []string{"Unload_1", "Unload_2", "Unload_3", "Unload_4", "Unload_5"} {
|
||||
storage.TakeRequest(int32(i), j, time.Now())
|
||||
}
|
||||
a.True(wait(rep.wg))
|
||||
a.Len(rep.cache, 5)
|
||||
}
|
||||
|
||||
type requestsRepository struct {
|
||||
cache []entity.Request
|
||||
mx sync.Mutex
|
||||
wg *sync.WaitGroup
|
||||
}
|
||||
|
||||
func (r *requestsRepository) Insert(model []entity.Request) error {
|
||||
r.mx.Lock()
|
||||
r.cache = append(r.cache, model...)
|
||||
r.mx.Unlock()
|
||||
r.wg.Done()
|
||||
return nil
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
package assembly
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/http"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
type Assembly struct {
|
||||
boot *bootstrap.Bootstrap
|
||||
server *http.Server
|
||||
logger *log.Adapter
|
||||
routes *routes.Routes
|
||||
redisCli redis.UniversalClient
|
||||
systemCli *client.Client
|
||||
adminCli *client.Client
|
||||
|
||||
locations []conf.Location
|
||||
grpcClientByModuleName map[string]*client.Client
|
||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
||||
}
|
||||
|
||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||
server := http.NewServer(boot.App.Logger())
|
||||
|
||||
localConfig := conf.Local{}
|
||||
err := boot.App.Config().Read(&localConfig)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "read local config")
|
||||
}
|
||||
|
||||
grpcClientByModuleName := make(map[string]*client.Client)
|
||||
httpHostManagerByModuleName := make(map[string]*lb.RoundRobin)
|
||||
for _, location := range localConfig.Locations {
|
||||
switch location.Protocol {
|
||||
case conf.GrpcProtocol:
|
||||
cli, err := client.Default()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "new grpc client")
|
||||
}
|
||||
grpcClientByModuleName[location.TargetModule] = cli
|
||||
case conf.HttpProtocol, conf.WsProtocol:
|
||||
rb := lb.NewRoundRobin(nil)
|
||||
httpHostManagerByModuleName[location.TargetModule] = rb
|
||||
default:
|
||||
return nil, errors.Errorf("unexpected location protocol: %s", location.Protocol)
|
||||
}
|
||||
}
|
||||
|
||||
systemCli, err := client.Default()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create system cli")
|
||||
}
|
||||
|
||||
adminCli, err := client.Default()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create admin cli")
|
||||
}
|
||||
|
||||
return &Assembly{
|
||||
boot: boot,
|
||||
server: server,
|
||||
logger: boot.App.Logger(),
|
||||
routes: routes.NewRoutes(),
|
||||
locations: localConfig.Locations,
|
||||
grpcClientByModuleName: grpcClientByModuleName,
|
||||
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
||||
systemCli: systemCli,
|
||||
adminCli: adminCli,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *Assembly) ReceiveConfig(ctx context.Context, remoteConfig []byte) error {
|
||||
var (
|
||||
newCfg conf.Remote
|
||||
prevCfg conf.Remote
|
||||
)
|
||||
err := a.boot.RemoteConfig.Upgrade(remoteConfig, &newCfg, &prevCfg)
|
||||
if err != nil {
|
||||
a.logger.Fatal(ctx, errors.WithMessage(err, "upgrade remote config"))
|
||||
}
|
||||
err = newCfg.Validate()
|
||||
if err != nil {
|
||||
a.logger.Fatal(ctx, errors.WithMessage(err, "invalid remote config"))
|
||||
}
|
||||
|
||||
a.logger.SetLevel(newCfg.Logging.LogLevel)
|
||||
|
||||
var newRedisCli redis.UniversalClient
|
||||
if newCfg.Redis != nil {
|
||||
newRedisCli = a.redisClient(*newCfg.Redis)
|
||||
}
|
||||
|
||||
locator := NewLocator(a.logger, a.grpcClientByModuleName, a.httpHostManagerByModuleName, a.routes, a.systemCli, a.adminCli)
|
||||
|
||||
handler, err := locator.Handler(newCfg, a.locations, newRedisCli)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "locator handler")
|
||||
}
|
||||
|
||||
a.server.Upgrade(handler)
|
||||
|
||||
if a.redisCli != nil {
|
||||
_ = a.redisCli.Close()
|
||||
a.redisCli = newRedisCli
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Assembly) Runners() []app.Runner {
|
||||
eventHandler := cluster.NewEventHandler().
|
||||
RoutesReceiver(a.routes).
|
||||
RemoteConfigReceiver(a)
|
||||
|
||||
for moduleName, upgrader := range a.grpcClientByModuleName {
|
||||
eventHandler.RequireModule(moduleName, upgrader)
|
||||
}
|
||||
for moduleName, upgrader := range a.httpHostManagerByModuleName {
|
||||
eventHandler.RequireModule(moduleName, upgrader)
|
||||
}
|
||||
|
||||
eventHandler.RequireModule("isp-system-service", a.systemCli)
|
||||
eventHandler.RequireModule("msp-admin-service", a.adminCli)
|
||||
|
||||
return []app.Runner{
|
||||
app.RunnerFunc(func(ctx context.Context) error {
|
||||
return a.server.ListenAndServe(a.boot.BindingAddress)
|
||||
}),
|
||||
app.RunnerFunc(func(ctx context.Context) error {
|
||||
return a.boot.ClusterCli.Run(ctx, eventHandler)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Assembly) Closers() []app.Closer {
|
||||
closers := []app.Closer{
|
||||
a.boot.ClusterCli,
|
||||
app.CloserFunc(func() error {
|
||||
return a.server.Shutdown(context.Background())
|
||||
}),
|
||||
}
|
||||
for _, cliCloser := range a.grpcClientByModuleName {
|
||||
closers = append(closers, cliCloser)
|
||||
}
|
||||
closers = append(closers, a.systemCli, a.adminCli, app.CloserFunc(func() error {
|
||||
if a.redisCli != nil {
|
||||
return a.redisCli.Close()
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
|
||||
return closers
|
||||
}
|
||||
|
||||
// nolint:ireturn
|
||||
func (a *Assembly) redisClient(config conf.Redis) redis.UniversalClient {
|
||||
if config.Sentinel != nil {
|
||||
return redis.NewFailoverClient(&redis.FailoverOptions{
|
||||
MasterName: config.Sentinel.MasterName,
|
||||
SentinelAddrs: config.Sentinel.Addresses,
|
||||
SentinelUsername: config.Sentinel.Username,
|
||||
SentinelPassword: config.Sentinel.Password,
|
||||
Username: config.Username,
|
||||
Password: config.Password,
|
||||
})
|
||||
}
|
||||
return redis.NewClient(&redis.Options{
|
||||
Addr: config.Address,
|
||||
Username: config.Username,
|
||||
Password: config.Password,
|
||||
})
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package assembly
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/middleware"
|
||||
"isp-gate-service/proxy"
|
||||
"isp-gate-service/repository"
|
||||
"isp-gate-service/routes"
|
||||
"isp-gate-service/service"
|
||||
|
||||
mux2 "github.com/gorilla/mux"
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/lb"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
)
|
||||
|
||||
type Locator struct {
|
||||
logger log.Logger
|
||||
grpcClientByModuleName map[string]*client.Client
|
||||
httpHostManagerByModuleName map[string]*lb.RoundRobin
|
||||
routes *routes.Routes
|
||||
systemCli *client.Client
|
||||
adminCli *client.Client
|
||||
}
|
||||
|
||||
func NewLocator(
|
||||
logger log.Logger,
|
||||
grpcClientByModuleName map[string]*client.Client,
|
||||
httpHostManagerByModuleName map[string]*lb.RoundRobin,
|
||||
routes *routes.Routes,
|
||||
systemCli *client.Client,
|
||||
adminCli *client.Client,
|
||||
) Locator {
|
||||
return Locator{
|
||||
logger: logger,
|
||||
grpcClientByModuleName: grpcClientByModuleName,
|
||||
httpHostManagerByModuleName: httpHostManagerByModuleName,
|
||||
routes: routes,
|
||||
systemCli: systemCli,
|
||||
adminCli: adminCli,
|
||||
}
|
||||
}
|
||||
|
||||
func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli redis.UniversalClient) (http.Handler, error) {
|
||||
systemRepo := repository.NewSystem(l.systemCli)
|
||||
adminRepo := repository.NewAdmin(l.adminCli)
|
||||
|
||||
authenticationCache := repository.NewAuthenticationCache(time.Duration(config.Caching.AuthenticationDataInSec) * time.Second)
|
||||
authentication := service.NewAuthentication(authenticationCache, systemRepo)
|
||||
|
||||
adminService := service.NewAdmin(
|
||||
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
||||
adminRepo,
|
||||
)
|
||||
|
||||
authorization := service.NewAuthorization(
|
||||
repository.NewAuthorizationCache(time.Duration(config.Caching.AuthorizationDataInSec)*time.Second),
|
||||
systemRepo,
|
||||
)
|
||||
|
||||
dailyLimitRepo := repository.NewDailyLimit(redisCli)
|
||||
dailyLimitService := service.NewDailyLimit(dailyLimitRepo, config.DailyLimits)
|
||||
|
||||
throttlingRepo := repository.NewThrottling(redisCli)
|
||||
throttlingService := service.NewThrottling(throttlingRepo, config.Throttling)
|
||||
|
||||
mux := mux2.NewRouter()
|
||||
for _, location := range locations {
|
||||
var proxyFunc middleware.Handler
|
||||
enableBodyLog := config.Logging.BodyLogEnable
|
||||
|
||||
switch location.Protocol {
|
||||
case conf.GrpcProtocol:
|
||||
cli := l.grpcClientByModuleName[location.TargetModule]
|
||||
proxyFunc = proxy.NewGrpc(cli, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
||||
case conf.HttpProtocol:
|
||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
||||
proxyFunc = proxy.NewHttp(hostManager, location.SkipAuth, time.Duration(config.Http.ProxyTimeoutInSec)*time.Second)
|
||||
case conf.WsProtocol:
|
||||
hostManager := l.httpHostManagerByModuleName[location.TargetModule]
|
||||
proxyFunc = proxy.NewWs(hostManager, location.SkipAuth)
|
||||
enableBodyLog = false
|
||||
default:
|
||||
return nil, errors.Errorf("not supported protocol %s", location.Protocol)
|
||||
}
|
||||
|
||||
handler := middleware.Chain(
|
||||
proxyFunc,
|
||||
middleware.RequestId(config.EnableClientRequestIdForwarding),
|
||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog,
|
||||
config.Logging.SkipBodyLoggingEndpointPrefixes),
|
||||
middleware.ErrorHandler(l.logger),
|
||||
middleware.Authenticate(authentication),
|
||||
middleware.AdminAuthenticate(adminService),
|
||||
middleware.Authorize(authorization, l.logger),
|
||||
middleware.AdminAuthorize(l.routes, adminService),
|
||||
middleware.Throttling(throttlingService),
|
||||
middleware.DailyLimit(dailyLimitService),
|
||||
)
|
||||
if location.SkipAuth {
|
||||
handler = middleware.Chain(
|
||||
proxyFunc,
|
||||
middleware.RequestId(config.EnableClientRequestIdForwarding),
|
||||
middleware.Logger(l.logger, config.Logging.RequestLogEnable, enableBodyLog,
|
||||
config.Logging.SkipBodyLoggingEndpointPrefixes),
|
||||
middleware.ErrorHandler(l.logger),
|
||||
)
|
||||
}
|
||||
entrypoint := middleware.Entrypoint(
|
||||
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd,gomnd
|
||||
handler,
|
||||
l.logger,
|
||||
middleware.EntryPointConfig{
|
||||
WithPrefix: location.WithPrefix,
|
||||
PathPrefix: location.PathPrefix,
|
||||
},
|
||||
)
|
||||
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
|
||||
}
|
||||
|
||||
return mux, nil
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package authenticate
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/integration-system/isp-lib/v2/utils"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/integration-system/isp-log/stdcodes"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/log_code"
|
||||
"isp-gate-service/routing"
|
||||
"isp-gate-service/service/veritification"
|
||||
)
|
||||
|
||||
const (
|
||||
// TODO move to isp-lib
|
||||
AdminTokenHeader = "x-auth-admin" //nolint
|
||||
|
||||
awaitLengthVerifiableHeaders = 4
|
||||
)
|
||||
|
||||
var notExpectedHeaders = []string{
|
||||
utils.SystemIdHeader,
|
||||
utils.DomainIdHeader,
|
||||
utils.ServiceIdHeader,
|
||||
utils.ApplicationIdHeader,
|
||||
utils.UserIdHeader,
|
||||
utils.DeviceIdHeader,
|
||||
}
|
||||
|
||||
var auth = authenticate{}
|
||||
|
||||
type (
|
||||
authenticate struct {
|
||||
verify veritification.Verify
|
||||
}
|
||||
|
||||
verifiable struct {
|
||||
appId int32
|
||||
ctx *fasthttp.RequestCtx
|
||||
path string
|
||||
headers map[string]string
|
||||
}
|
||||
)
|
||||
|
||||
func ReceiveConfiguration(conf conf.Cache) {
|
||||
if conf.EnableCache {
|
||||
if timeout, err := time.ParseDuration(conf.EvictTimeout); err != nil {
|
||||
log.Fatalf(stdcodes.ModuleInvalidRemoteConfig, "invalid timeout '%s'", timeout)
|
||||
} else {
|
||||
auth.verify = veritification.NewCacheablesVerify(timeout)
|
||||
}
|
||||
} else {
|
||||
auth.verify = veritification.NewRuntimeVerify()
|
||||
}
|
||||
}
|
||||
|
||||
func Do(ctx *fasthttp.RequestCtx, path string) (int32, error) {
|
||||
for _, notExpectedHeader := range notExpectedHeaders {
|
||||
ctx.Request.Header.Del(notExpectedHeader)
|
||||
}
|
||||
|
||||
verifiable := newVerifiable(ctx, path)
|
||||
err := verifiable.verifyAppToken()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
err = verifiable.verifyUserToken()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
verifiable.setHeaders()
|
||||
|
||||
err = verifiable.checkInnerMethods()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
err = verifiable.checkUserMethods()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
//TODO backward capability for isp-config-service 1.x.x
|
||||
uuid := config.Get().(*conf.Configuration).InstanceUuid
|
||||
ctx.Request.Header.Set(utils.InstanceIdHeader, uuid)
|
||||
|
||||
return verifiable.appId, nil
|
||||
}
|
||||
|
||||
func newVerifiable(ctx *fasthttp.RequestCtx, path string) *verifiable {
|
||||
return &verifiable{
|
||||
ctx: ctx,
|
||||
path: path,
|
||||
appId: -1,
|
||||
headers: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
func (v *verifiable) verifyAppToken() error {
|
||||
appToken := v.getParam(utils.ApplicationTokenHeader)
|
||||
var err error
|
||||
|
||||
if len(appToken) == 0 {
|
||||
return createError("unauthorized", codes.Unauthenticated, "application token required")
|
||||
} else if config.GetRemote().(*conf.RemoteConfig).TokensSetting.ApplicationVerify {
|
||||
if v.appId, err = verifyToken.Application(string(appToken)); err != nil || v.appId == 0 {
|
||||
return createError("unauthorized", codes.Unauthenticated, "received invalid application token")
|
||||
}
|
||||
}
|
||||
|
||||
verifiableHeaders, err := auth.verify.ApplicationToken(string(appToken))
|
||||
if err != nil {
|
||||
log.Error(log_code.ErrorAuthenticate, err)
|
||||
return createError("internal Server error", codes.Internal)
|
||||
}
|
||||
if len(verifiableHeaders) != awaitLengthVerifiableHeaders {
|
||||
return createError("unauthorized", codes.Unauthenticated, "received unexpected identities")
|
||||
}
|
||||
|
||||
applicationId, err := strconv.ParseInt(verifiableHeaders[utils.ApplicationIdHeader], 10, 32)
|
||||
if err != nil {
|
||||
log.Error(log_code.ErrorAuthenticate, errors.WithMessagef(err, "parse appId from redis"))
|
||||
return createError("internal Server error", codes.Internal)
|
||||
}
|
||||
//nolint
|
||||
if v.appId != -1 && int32(applicationId) != v.appId {
|
||||
return createError("unauthorized", codes.Unauthenticated, "received unexpected application identity")
|
||||
}
|
||||
|
||||
v.appId = int32(applicationId)
|
||||
v.headers = verifiableHeaders
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *verifiable) verifyUserToken() error {
|
||||
userToken := string(v.getParam(utils.UserTokenHeader))
|
||||
if userToken != "" {
|
||||
userId, err := verifyToken.User(userToken)
|
||||
if err != nil {
|
||||
return createError("unauthorized", codes.Unauthenticated, "received invalid user token")
|
||||
}
|
||||
v.headers[utils.UserIdHeader] = userId
|
||||
}
|
||||
v.headers[utils.UserTokenHeader] = userToken
|
||||
|
||||
v.headers[utils.DeviceTokenHeader] = string(v.getParam(utils.DeviceTokenHeader))
|
||||
|
||||
var err error
|
||||
v.headers, err = auth.verify.Identity(v.headers, v.path)
|
||||
if err != nil {
|
||||
switch err {
|
||||
case veritification.ErrorInvalidUserId:
|
||||
return createError("unauthorized", codes.Unauthenticated, err.Error())
|
||||
case veritification.ErrorPermittedToCallUser, veritification.ErrorPermittedToCallApplication:
|
||||
return createError("forbidden", codes.PermissionDenied, err.Error())
|
||||
default:
|
||||
return createError("internal server error", codes.Internal)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *verifiable) setHeaders() {
|
||||
for key, value := range v.headers {
|
||||
if value != "" {
|
||||
v.ctx.Request.Header.Set(key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (v *verifiable) checkInnerMethods() error {
|
||||
_, ok := routing.InnerMethods[v.path]
|
||||
if ok {
|
||||
adminToken := string(v.getParam(AdminTokenHeader))
|
||||
if adminToken == "" {
|
||||
return createError("unauthorized", codes.Unauthenticated, "admin token required")
|
||||
}
|
||||
if verifyToken.Admin(adminToken) != nil {
|
||||
return createError("unauthorized", codes.Unauthenticated, "received invalid admin token")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *verifiable) checkUserMethods() error {
|
||||
if v.headers[utils.UserIdHeader] == "" {
|
||||
if _, ok := routing.AuthUserMethods[v.path]; ok {
|
||||
return createError("unauthorized", codes.Unauthenticated, "user token required")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *verifiable) getParam(key string) []byte {
|
||||
val := v.ctx.Request.Header.Peek(key)
|
||||
if len(val) != 0 {
|
||||
return val
|
||||
}
|
||||
return v.ctx.Request.URI().QueryArgs().Peek(key)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package authenticate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"google.golang.org/grpc/codes"
|
||||
)
|
||||
|
||||
func createError(msg string, status codes.Code, details ...interface{}) error {
|
||||
return ErrorDescription{message: msg, grpcStatus: status, details: details}
|
||||
}
|
||||
|
||||
type ErrorDescription struct {
|
||||
message string
|
||||
grpcStatus codes.Code
|
||||
details []interface{}
|
||||
}
|
||||
|
||||
func (e ErrorDescription) Error() string {
|
||||
return fmt.Sprintf("code: %v, message: %s, details: %v", e.grpcStatus, e.message, e.details)
|
||||
}
|
||||
|
||||
func (e ErrorDescription) Message() string {
|
||||
return e.message
|
||||
}
|
||||
|
||||
func (e ErrorDescription) ConvertToGrpcStatus() codes.Code {
|
||||
return e.grpcStatus
|
||||
}
|
||||
|
||||
func (e ErrorDescription) Details() []interface{} {
|
||||
return e.details
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package authenticate
|
||||
|
||||
import (
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cast"
|
||||
"isp-gate-service/conf"
|
||||
)
|
||||
|
||||
var (
|
||||
errInvalidToken = errors.New("invalid token")
|
||||
verifyToken token
|
||||
)
|
||||
|
||||
type appClaims struct {
|
||||
*jwt.StandardClaims
|
||||
AppId int32
|
||||
}
|
||||
|
||||
type userClaims struct {
|
||||
*jwt.StandardClaims
|
||||
UserId int64
|
||||
}
|
||||
|
||||
type token struct{}
|
||||
|
||||
func (t token) Admin(token string) error {
|
||||
secret := config.GetRemote().(*conf.RemoteConfig).TokensSetting.AdminSecret
|
||||
_, err := t.parse(token, secret, jwt.MapClaims{})
|
||||
return err
|
||||
}
|
||||
|
||||
func (t token) Application(token string) (int32, error) {
|
||||
secret := config.GetRemote().(*conf.RemoteConfig).TokensSetting.ApplicationSecret
|
||||
|
||||
parsed, err := t.parse(token, secret, &appClaims{StandardClaims: &jwt.StandardClaims{}})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
claims, ok := parsed.Claims.(*appClaims)
|
||||
if !ok {
|
||||
return 0, errInvalidToken
|
||||
}
|
||||
return claims.AppId, nil
|
||||
}
|
||||
|
||||
func (t token) User(token string) (string, error) {
|
||||
secret := config.GetRemote().(*conf.RemoteConfig).TokensSetting.UserSecret
|
||||
|
||||
parsed, err := t.parse(token, secret, &userClaims{StandardClaims: &jwt.StandardClaims{}})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
claims, ok := parsed.Claims.(*userClaims)
|
||||
if !ok {
|
||||
return "", errInvalidToken
|
||||
}
|
||||
|
||||
return cast.ToString(claims.UserId), nil
|
||||
}
|
||||
|
||||
func (token) parse(token, secret string, claims jwt.Claims) (*jwt.Token, error) {
|
||||
parsed, err := jwt.ParseWithClaims(token, claims, func(token *jwt.Token) (interface{}, error) {
|
||||
_, ok := token.Method.(*jwt.SigningMethodHMAC)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||
}
|
||||
return []byte(secret), nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !parsed.Valid {
|
||||
return nil, errInvalidToken
|
||||
}
|
||||
return parsed, nil
|
||||
}
|
||||
Vendored
-53
@@ -1,53 +0,0 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
data []byte
|
||||
expiredAt time.Time
|
||||
}
|
||||
|
||||
type Cache struct {
|
||||
store map[string]Item
|
||||
lock *sync.RWMutex
|
||||
}
|
||||
|
||||
func New() *Cache {
|
||||
return &Cache{
|
||||
store: map[string]Item{},
|
||||
lock: &sync.RWMutex{},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) Get(key string) ([]byte, bool) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
|
||||
item, ok := c.store[key]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if c.now().After(item.expiredAt) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return item.data, true
|
||||
}
|
||||
|
||||
func (c *Cache) Set(key string, data []byte, lifeTime time.Duration) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
c.store[key] = Item{
|
||||
data: data,
|
||||
expiredAt: c.now().Add(lifeTime),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cache) now() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
Vendored
-50
@@ -1,50 +0,0 @@
|
||||
package cache_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"isp-gate-service/cache"
|
||||
)
|
||||
|
||||
func TestGetBasic(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
cache := cache.New()
|
||||
cache.Set("key", []byte("data"), 24*time.Hour)
|
||||
|
||||
data, ok := cache.Get("key")
|
||||
require.True(ok)
|
||||
require.EqualValues("data", data)
|
||||
|
||||
_, ok = cache.Get("key2")
|
||||
require.False(ok)
|
||||
}
|
||||
|
||||
func TestGetExpired(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
cache := cache.New()
|
||||
cache.Set("key", []byte("data"), 500*time.Millisecond)
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
data, ok := cache.Get("key")
|
||||
require.False(ok)
|
||||
require.Nil(data)
|
||||
}
|
||||
|
||||
func TestNilValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
cache := cache.New()
|
||||
cache.Set("key", nil, 24*time.Hour)
|
||||
|
||||
data, ok := cache.Get("key")
|
||||
require.True(ok)
|
||||
require.Nil(data)
|
||||
}
|
||||
+10
-18
@@ -1,24 +1,16 @@
|
||||
configServiceAddress:
|
||||
ip: 127.0.0.1
|
||||
port: 9001
|
||||
grpcOuterAddress:
|
||||
#ip: 127.0.0.1
|
||||
httpOuterAddress:
|
||||
ip: 127.0.0.1
|
||||
port: 9003
|
||||
grpcInnerAddress:
|
||||
httpInnerAddress:
|
||||
ip: 0.0.0.0
|
||||
port: 9003
|
||||
moduleName: isp-gate-service
|
||||
|
||||
infraServerPort: 9553
|
||||
|
||||
logfile:
|
||||
path: /var/log/isp-gate-service/runtime.log
|
||||
maxSizeMb: 512
|
||||
maxBackups: 4
|
||||
compress: true
|
||||
|
||||
|
||||
locations:
|
||||
- pathPrefix: /api
|
||||
protocol: grpc
|
||||
targetModule: router
|
||||
moduleName: isp-gate
|
||||
instanceUuid: 9d89354b-c728-4b48-b002-a7d3b229f151
|
||||
routerConfig:
|
||||
routerModuleName: router
|
||||
pathPrefix: /api
|
||||
skipAuth: false
|
||||
skipExistCheck: false
|
||||
@@ -1,38 +0,0 @@
|
||||
configServiceAddress:
|
||||
ip: 127.0.0.1
|
||||
port: 9001
|
||||
grpcOuterAddress:
|
||||
#ip: 127.0.0.1
|
||||
port: 9003
|
||||
grpcInnerAddress:
|
||||
ip: 0.0.0.0
|
||||
port: 9003
|
||||
moduleName: isp-gate-service
|
||||
|
||||
infraServerPort: 9553
|
||||
|
||||
logfile:
|
||||
path: /var/log/isp-gate-service/runtime.log
|
||||
maxSizeMb: 512
|
||||
maxBackups: 4
|
||||
compress: true
|
||||
|
||||
locations:
|
||||
- pathPrefix: /ws/kkd-configuration-service
|
||||
protocol: ws
|
||||
targetModule: kkd-configuration-service
|
||||
- pathPrefix: /api/kkd-configuration-service
|
||||
protocol: http
|
||||
targetModule: kkd-configuration-service
|
||||
- withPrefix: false
|
||||
pathPrefix: /api/kkd-storage-service/report/download
|
||||
protocol: http
|
||||
targetModule: kkd-storage-service
|
||||
skipAuth: true
|
||||
- pathPrefix: /api/kkd-storage-service
|
||||
protocol: http
|
||||
targetModule: kkd-storage-service
|
||||
- pathPrefix: /api
|
||||
protocol: grpc
|
||||
skipAuth: false
|
||||
targetModule: router
|
||||
@@ -1,16 +1,65 @@
|
||||
{
|
||||
"logging": {
|
||||
"logLevel": "debug",
|
||||
"requestLogEnable": true,
|
||||
"bodyLogEnable": false,
|
||||
"skipBodyLoggingEndpointPrefixes": []
|
||||
},
|
||||
"caching": {
|
||||
"authenticationDataInSec": 60,
|
||||
"authorizationDataInSec": 60
|
||||
},
|
||||
"http": {
|
||||
"maxRequestBodySizeInMb": 64,
|
||||
"proxyTimeoutInSec": 60
|
||||
"database": {
|
||||
"address": "{{ msp_pgsql_address }}",
|
||||
"port": "{{ msp_pgsql_port }}",
|
||||
"schema": "gate_service",
|
||||
"database": "{{ msp_pgsql_name }}",
|
||||
"username": "{{ msp_pgsql_user }}",
|
||||
"password": "{{ msp_pgsql_password }}",
|
||||
"createSchema": true
|
||||
},
|
||||
"grpcSetting": {
|
||||
"proxyGrpcErrorDetails": true,
|
||||
"enableOriginalProtoErrors": false
|
||||
},
|
||||
"httpSetting": {
|
||||
"maxRequestBodySizeBytes": 0
|
||||
},
|
||||
"accountingSetting": {
|
||||
"enable": false,
|
||||
"snapshotTimeout": "15m",
|
||||
"setting": [
|
||||
],
|
||||
"storing": {
|
||||
"size": 10000,
|
||||
"timeout": "10m"
|
||||
}
|
||||
},
|
||||
"journalSetting": {
|
||||
"journal": {
|
||||
"filename": "/var/log/isp-gate-service/runtime.log",
|
||||
"maxSizeMb": 512,
|
||||
"bufferSize": 4096,
|
||||
"rotateTimeoutMs": 86400000,
|
||||
"enableRemoteTransfer": true,
|
||||
"enable": false,
|
||||
"compress": true
|
||||
}
|
||||
},
|
||||
"redis": {
|
||||
"password": "{{ msp_redis_password }}",
|
||||
"defaultDB": 0,
|
||||
"address": {
|
||||
"ip": "{{ msp_redis_address }}",
|
||||
"port": "{{ msp_redis_port }}"
|
||||
}
|
||||
},
|
||||
"metrics": {
|
||||
"gc": true,
|
||||
"memory": true,
|
||||
"address": {
|
||||
"path": "/metrics",
|
||||
"port": "9553",
|
||||
"ip": "0.0.0.0"
|
||||
}
|
||||
},
|
||||
"tokensSetting": {
|
||||
"applicationSecret": "{{ msp_app_secret }}",
|
||||
"applicationVerify": false,
|
||||
"adminSecret": "{{ msp_admin_secret }}"
|
||||
},
|
||||
"authCacheSetting": {
|
||||
"enableCache": false,
|
||||
"evictTimeout": "1m"
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package conf
|
||||
|
||||
const (
|
||||
HttpProtocol = "http"
|
||||
GrpcProtocol = "grpc"
|
||||
WsProtocol = "ws"
|
||||
)
|
||||
|
||||
type Local struct {
|
||||
Locations []Location
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
WithPrefix bool
|
||||
SkipAuth bool
|
||||
PathPrefix string `validate:"required"`
|
||||
Protocol string `validate:"required,oneof=http grpc ws"`
|
||||
TargetModule string `validate:"required"`
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
)
|
||||
|
||||
type (
|
||||
Configuration struct {
|
||||
InstanceUuid string `valid:"required~Required"`
|
||||
ModuleName string `valid:"required~Required"`
|
||||
ConfigServiceAddress structure.AddressConfiguration `valid:"required~Required"`
|
||||
HttpOuterAddress structure.AddressConfiguration `valid:"required~Required" json:"httpOuterAddress"`
|
||||
HttpInnerAddress structure.AddressConfiguration `valid:"required~Required" json:"httpInnerAddress"`
|
||||
RouterConfig RouterConfig `valid:"required~Required" json:"routerConfig"`
|
||||
}
|
||||
|
||||
RouterConfig struct {
|
||||
RouterModuleName string `valid:"required~Required"`
|
||||
PathPrefix string `valid:"required~Required"`
|
||||
SkipAuth bool
|
||||
SkipExistCheck bool
|
||||
}
|
||||
)
|
||||
@@ -1,79 +0,0 @@
|
||||
// nolint:gochecknoinits,lll
|
||||
package conf
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/txix-open/isp-kit/rc/schema"
|
||||
"github.com/txix-open/jsonschema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
schema.CustomGenerators.Register("logLevel", func(field reflect.StructField, t *jsonschema.Schema) {
|
||||
t.Type = "string"
|
||||
t.Enum = []interface{}{"debug", "info", "warn", "error", "fatal"}
|
||||
})
|
||||
}
|
||||
|
||||
type Remote struct {
|
||||
Redis *Redis `schema:"Настройки Redis,обязательно, если используется механизм суточных ограничений или ограничений пропускной способности"`
|
||||
Http Http `schema:"Настройки HTTP"`
|
||||
Logging Logging `schema:"Настройки логирования"`
|
||||
Caching Caching `schema:"Настройки кеширования"`
|
||||
DailyLimits []DailyLimit `schema:"Настройки суточных ограничений,сбрасываются раз в сутки в 00:00"`
|
||||
Throttling []Throttling `schema:"Настройки пропускной способности"`
|
||||
EnableClientRequestIdForwarding bool `schema:"Включить проброс requestId из заголовка запроса"`
|
||||
}
|
||||
|
||||
type Http struct {
|
||||
MaxRequestBodySizeInMb int64 `validate:"required" schema:"Максимальная длинна тела запроса,в мегабайтах"`
|
||||
ProxyTimeoutInSec int `validate:"required" schema:"Таймаут на проксирование,в секундах"`
|
||||
}
|
||||
|
||||
type Logging struct {
|
||||
LogLevel log.Level `schemaGen:"logLevel" schema:"Уровень логирования,логирование запросов осуществляется на уровне debug"`
|
||||
RequestLogEnable bool `schema:"Включить логирование запросов"`
|
||||
BodyLogEnable bool `schema:"Включить логирование тел запросов и ответов,должно быть включено логирование запросов"`
|
||||
SkipBodyLoggingEndpointPrefixes []string `schema:"регулярные выражения для отключения логирования"`
|
||||
}
|
||||
|
||||
type Caching struct {
|
||||
AuthenticationDataInSec int `validate:"required" schema:"Время кеширования данных аутентификации,в секундах"`
|
||||
AuthorizationDataInSec int `validate:"required" schema:"Время кеширования данных авторизации,в секундах"`
|
||||
}
|
||||
|
||||
type DailyLimit struct {
|
||||
ApplicationId int `validate:"required" schema:"ID приложения"`
|
||||
RequestsPerDay int64 `validate:"required" schema:"Запросов в сутки"`
|
||||
}
|
||||
|
||||
type Throttling struct {
|
||||
ApplicationId int `validate:"required" schema:"ID приложения"`
|
||||
RequestsPerSeconds int `validate:"required,min=1,max=1000" schema:"Запросов в секунду,не конфликтует с суточными ограничениями, алгоритм не работает на значениях больше 1000"`
|
||||
}
|
||||
|
||||
type Redis struct {
|
||||
Address string `schema:"Адрес,обязателено, если sentinel не указан"`
|
||||
Username string `schema:"Имя пользовтаеля"`
|
||||
Password string `schema:"Пароль"`
|
||||
Sentinel *RedisSentinel `schema:"Настройки sentinel,обязательно, если address не указан"`
|
||||
}
|
||||
|
||||
type RedisSentinel struct {
|
||||
Addresses []string `validate:"required" schema:"Адреса нод в кластере"`
|
||||
MasterName string `validate:"required" schema:"Имя мастера"`
|
||||
Username string `schema:"Имя пользовтаеля в sentinel"`
|
||||
Password string `schema:"Пароль в sentinel"`
|
||||
}
|
||||
|
||||
func (r Remote) Validate() error {
|
||||
if (len(r.Throttling) > 0 || len(r.DailyLimits) > 0) && r.Redis == nil {
|
||||
return errors.New("redis is required if dailyLimits or throttling were specified")
|
||||
}
|
||||
if r.Redis != nil && r.Redis.Sentinel == nil && r.Redis.Address == "" {
|
||||
return errors.New("invalid redis config. sentinel or address are required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
//nolint
|
||||
package conf
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-journal/rx"
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
KB = int64(1024)
|
||||
MB = int64(1 << 20)
|
||||
|
||||
defaultSyncTimeout = 30 * time.Second
|
||||
defaultStreamTimeout = 60 * time.Second
|
||||
|
||||
defaultBufferSize = 4 * KB
|
||||
defaultMaxRequestBodySize = 512 * MB
|
||||
DefaultMaxResponseBodySize = 32 * MB
|
||||
)
|
||||
|
||||
type (
|
||||
RemoteConfig struct {
|
||||
Database structure.DBConfiguration `schema:"Настройка подключения к базе данных"`
|
||||
TokensSetting TokensSetting `schema:"Настройка секретов"`
|
||||
HttpSetting HttpSetting `schema:"Настройка сервера"`
|
||||
GrpcSetting GrpcSetting `schema:"Настройка grpc соединения"`
|
||||
Metrics structure.MetricConfiguration `schema:"Настройка метрик"`
|
||||
JournalSetting Journal `schema:"Настройка журалирования"`
|
||||
Redis structure.RedisConfiguration `schema:"Настройка Redis" valid:"required~Required"`
|
||||
AccountingSetting Accounting `schema:"Настройка учета запросов"`
|
||||
AuthCacheSetting Cache `schema:"Настройка кеширования данных аутентификации приложений" valid:"required~Required"`
|
||||
}
|
||||
|
||||
Cache struct {
|
||||
EnableCache bool `schema:"Кеширование,включает кеширования для токена приложения"`
|
||||
EvictTimeout string `schema:"Время жизни записи в кеше"`
|
||||
}
|
||||
|
||||
Journal struct {
|
||||
Journal rx.Config `schema:"Настройка конфигурации"`
|
||||
MethodsPatterns []string `schema:"Список методов для логирования,список строк вида: 'module/group/method'(* - для частичного совпадения). При обработке запроса, если вызываемый метод совпадает со строкой из списка, тела запроса и ответа записываются в лог"`
|
||||
}
|
||||
|
||||
TokensSetting struct {
|
||||
AdminSecret string `schema:"Секрет для проверки токена администратора"`
|
||||
ApplicationSecret string `schema:"Секрет для проверки токена приложений"`
|
||||
ApplicationVerify bool `schema:"Проверка подписи токена приложений"`
|
||||
UserSecret string `schema:"Секрет для проверки токена пользователя"`
|
||||
}
|
||||
|
||||
Accounting struct {
|
||||
Enable bool `schema:"Учет запросов,включает/отключает учет запросов"`
|
||||
SnapshotTimeout string `schema:"Частота выгрузки ограничений для приложений" valid:"required~Required"`
|
||||
Setting []AccountingSetting `schema:"Настройка учета для приложений"`
|
||||
Storing StoringSetting `schema:"Настройка хранения всех запросов"`
|
||||
}
|
||||
|
||||
AccountingSetting struct {
|
||||
ApplicationId int32 `valid:"required~Required" schema:"Идентификатор приложения"`
|
||||
EnableStoring bool `schema:"Хранение запросов,если включено, каждый факт обработки запроса будет фиксироваться в БД"`
|
||||
Limits []LimitSetting `schema:"Настройка ограничений на запросы"`
|
||||
}
|
||||
|
||||
LimitSetting struct {
|
||||
Pattern string `valid:"required~Required" schema:"Шаблон пути,указывается путь для которого будут применяется ограничения; поддерживается '/*' для неполного совпадения"`
|
||||
MaxCount int `schema:"Количество запросов"`
|
||||
Timeout string `schema:"Время жизни одного запроса"`
|
||||
}
|
||||
|
||||
StoringSetting struct {
|
||||
Size int `schema:"Размер буфера,размер буфера,при достижении которого данные сбрасываются в БД" valid:"required,range(1|1000000)"`
|
||||
Timeout string `schema:"Частота выгрузки всех учтенных запросов,периодичность сброса данных в БД" valid:"required~Required"`
|
||||
}
|
||||
|
||||
HttpSetting struct {
|
||||
MaxRequestBodySizeBytes int64 `schema:"Максимальный размер тела запроса,в байтайх, по умолчанию: 512 MB"`
|
||||
}
|
||||
|
||||
GrpcSetting struct {
|
||||
EnableOriginalProtoErrors bool `schema:"Проксирование ошибок в протобаф,включение/отключение проксирования, по умолчанию отключено"`
|
||||
ProxyGrpcErrorDetails bool `schema:"Проксирование первого элемента из details GRPC ошибки,включение/отключение проксирования, по умолчанию отключено"`
|
||||
MultipartDataTransferBufferSizeBytes int64 `schema:"Размер буфера для передачи бинарных файлов,по умолчанию 4 KB"`
|
||||
SyncInvokeMethodTimeoutMs int64 `schema:"Время ожидания вызова метода,значение в миллисекундах, по умолчанию: 30000"`
|
||||
StreamInvokeMethodTimeoutMs int64 `schema:"Время ожидания передачи и обработки файла,значение в миллисекундах, по умолчанию: 60000"`
|
||||
}
|
||||
)
|
||||
|
||||
func (cfg GrpcSetting) GetSyncInvokeTimeout() time.Duration {
|
||||
if cfg.SyncInvokeMethodTimeoutMs <= 0 {
|
||||
return defaultSyncTimeout
|
||||
}
|
||||
return time.Duration(cfg.SyncInvokeMethodTimeoutMs) * time.Millisecond
|
||||
}
|
||||
|
||||
func (cfg GrpcSetting) GetStreamInvokeTimeout() time.Duration {
|
||||
if cfg.StreamInvokeMethodTimeoutMs <= 0 {
|
||||
return defaultStreamTimeout
|
||||
}
|
||||
return time.Duration(cfg.StreamInvokeMethodTimeoutMs) * time.Millisecond
|
||||
}
|
||||
|
||||
func (cfg GrpcSetting) GetTransferFileBufferSize() int64 {
|
||||
if cfg.MultipartDataTransferBufferSizeBytes <= 0 {
|
||||
return defaultBufferSize
|
||||
}
|
||||
return cfg.MultipartDataTransferBufferSizeBytes
|
||||
}
|
||||
|
||||
func (cfg HttpSetting) GetMaxRequestBodySize() int64 {
|
||||
if cfg.MaxRequestBodySizeBytes <= 0 {
|
||||
return defaultMaxRequestBodySize
|
||||
}
|
||||
return cfg.MaxRequestBodySizeBytes
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package conf_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/txix-open/isp-kit/test/rct"
|
||||
"isp-gate-service/conf"
|
||||
)
|
||||
|
||||
func TestDefaultRemoteConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
rct.Test(t, "default_remote_config.json", conf.Remote{})
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package domain
|
||||
|
||||
type AdminAuthenticateResponse struct {
|
||||
Authenticated bool
|
||||
ErrorReason string
|
||||
AdminId int
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package domain
|
||||
|
||||
type AuthData struct {
|
||||
SystemId int
|
||||
DomainId int
|
||||
ServiceId int
|
||||
ApplicationId int
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrAuthenticationCacheMiss = errors.New("authentication not found in cache")
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
package domain
|
||||
|
||||
type ProxyResponse struct {
|
||||
requestBody []byte
|
||||
responseBody []byte
|
||||
error error
|
||||
}
|
||||
|
||||
func Create() ProxyResponse {
|
||||
return ProxyResponse{requestBody: nil, responseBody: nil, error: nil}
|
||||
}
|
||||
|
||||
func (p ProxyResponse) SetRequestBody(requestBody []byte) ProxyResponse {
|
||||
p.requestBody = requestBody
|
||||
return p
|
||||
}
|
||||
|
||||
func (p ProxyResponse) SetResponseBody(responseBody []byte) ProxyResponse {
|
||||
p.responseBody = responseBody
|
||||
return p
|
||||
}
|
||||
|
||||
func (p ProxyResponse) SetError(err error) ProxyResponse {
|
||||
p.error = err
|
||||
return p
|
||||
}
|
||||
|
||||
func (p ProxyResponse) Get() (requestBody, responseBody []byte, err error) {
|
||||
return p.requestBody, p.responseBody, p.error
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package domain
|
||||
|
||||
type AuthenticateRequest struct {
|
||||
Token string
|
||||
}
|
||||
|
||||
type AuthenticateResponse struct {
|
||||
Authenticated bool
|
||||
ErrorReason string
|
||||
AuthData *AuthData
|
||||
}
|
||||
|
||||
type AuthorizeRequest struct {
|
||||
ApplicationId int
|
||||
Endpoint string
|
||||
}
|
||||
|
||||
type AuthorizeResponse struct {
|
||||
Authorized bool
|
||||
}
|
||||
|
||||
type AdminAuthorizeRequest struct {
|
||||
AdminId int
|
||||
Permission string
|
||||
}
|
||||
|
||||
type AdminAuthorizeResponse struct {
|
||||
Authorized bool
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type RateLimitResult struct {
|
||||
Allow bool
|
||||
Remaining int
|
||||
RetryAfter time.Duration
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"isp-gate-service/accounting/state"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Snapshot struct {
|
||||
TableName string `sql:"?db_schema.snapshot" json:"-"`
|
||||
AppId int32 `sql:",pk"`
|
||||
LimitState map[string]state.Snapshot
|
||||
Version int64
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
TableName string `sql:"?db_schema.requests" json:"-"`
|
||||
Id int `sql:",pk"`
|
||||
AppId int32
|
||||
Method string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -1,74 +1,23 @@
|
||||
module isp-gate-service
|
||||
|
||||
go 1.23
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/go-redis/redis_rate/v10 v10.0.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/websocket v1.5.1
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/fasthttp/websocket v1.4.1
|
||||
github.com/go-pg/pg/v9 v9.1.7
|
||||
github.com/go-redis/redis/v8 v8.0.0-beta.2
|
||||
github.com/golang/protobuf v1.3.5
|
||||
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f
|
||||
github.com/integration-system/isp-journal v1.5.0
|
||||
github.com/integration-system/isp-lib/v2 v2.6.3
|
||||
github.com/integration-system/isp-log v1.1.5
|
||||
github.com/json-iterator/go v1.1.10
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/redis/go-redis/v9 v9.3.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/tomakado/websocketproxy v0.1.0
|
||||
github.com/txix-open/isp-kit v1.38.1
|
||||
github.com/txix-open/jsonschema v1.2.0
|
||||
golang.org/x/net v0.28.0
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988
|
||||
google.golang.org/grpc v1.65.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/coder/websocket v1.8.12 // 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.5 // indirect
|
||||
github.com/getsentry/sentry-go v0.28.1 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/julienschmidt/httprouter v1.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // 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/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-20240401163703-e83541b40f99 // 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.53.0 // indirect
|
||||
go.opentelemetry.io/otel v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.28.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
golang.org/x/crypto v0.26.0 // indirect
|
||||
golang.org/x/sys v0.24.0 // indirect
|
||||
golang.org/x/text v0.17.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
|
||||
github.com/spf13/cast v1.3.1
|
||||
github.com/stretchr/testify v1.6.1
|
||||
github.com/valyala/fasthttp v1.16.0
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202
|
||||
google.golang.org/grpc v1.29.1
|
||||
)
|
||||
@@ -1,182 +1,602 @@
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7 h1:qELHH0AWCvf98Yf+CNIJx9vOZOfHFDDzgDRYsnNk/vs=
|
||||
github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
|
||||
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f h1:y2hSFdXeA1y5z5f0vfNO0Dg5qVY036qzlz3Pds0B92o=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180315120708-ccb8e960c48f/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/aws/aws-sdk-go v1.29.9/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg=
|
||||
github.com/benbjohnson/clock v1.0.0 h1:78Jk/r6m4wCi6sndMpty7A//t4dw/RW5fV4ZgDVfX1w=
|
||||
github.com/benbjohnson/clock v1.0.0/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
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.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
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.12 h1:5bUXkEPPIbewrnkU8LTCLVaxi4N4J8ahufH2vlo4NAo=
|
||||
github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/buaazp/fasthttprouter v0.1.1 h1:4oAnN0C3xZjylvZJdP35cxfclyn4TYkW6Y+DSvS+h8Q=
|
||||
github.com/buaazp/fasthttprouter v0.1.1/go.mod h1:h/Ap5oRVLeItGKTVBb+heQPks+HdIUtGmI4H5WCYijM=
|
||||
github.com/cenkalti/backoff/v4 v4.0.0 h1:6VeaLF9aI+MAUQ95106HwWzYZgJJpZ4stumjj6RFYAU=
|
||||
github.com/cenkalti/backoff/v4 v4.0.0/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
|
||||
github.com/cenkalti/backoff/v4 v4.0.2 h1:JIufpQLbh4DkbQoii76ItQIUFzevQSqOLZca4eamEDs=
|
||||
github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
|
||||
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/codemodus/kace v0.5.1 h1:4OCsBlE2c/rSJo375ggfnucv9eRzge/U5LrrOZd47HA=
|
||||
github.com/codemodus/kace v0.5.1/go.mod h1:coddaHoX1ku1YFSe4Ip0mL9kQjJvKkzb9CfIdG1YR04=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/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.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
|
||||
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
|
||||
github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k=
|
||||
github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg=
|
||||
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.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-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.14.0 h1:/rhkzsAqGQkozwfKS5aFAbb6TyKd3zyFRWcdRXLPCAU=
|
||||
github.com/go-resty/resty/v2 v2.14.0/go.mod h1:IW6mekUOsElt9C7oWr0XRt9BNSD6D5rr9mhk6NjmNHg=
|
||||
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/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fasthttp/websocket v1.4.1 h1:fisgNMCNCbIPM5GRRRTAckRrynbSzf76fevcJYJYnSM=
|
||||
github.com/fasthttp/websocket v1.4.1/go.mod h1:toetUvZ3KISxtZERe0wzPPpnaN8GZCKHCowWctwA50o=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w=
|
||||
github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
|
||||
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
|
||||
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
|
||||
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
|
||||
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
|
||||
github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||
github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
|
||||
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
|
||||
github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8=
|
||||
github.com/go-openapi/jsonreference v0.19.4 h1:3Vw+rh13uq2JFNxgnMTGE1rnoieU9FmyE1gvnyylsYg=
|
||||
github.com/go-openapi/jsonreference v0.19.4/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg=
|
||||
github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
|
||||
github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
|
||||
github.com/go-openapi/spec v0.19.9 h1:9z9cbFuZJ7AcvOHKIY+f6Aevb4vObNDkTEyoMfO7rAc=
|
||||
github.com/go-openapi/spec v0.19.9/go.mod h1:vqK/dIdLGCosfvYsQV3WfC7N3TiZSnGY2RZKoFK7X28=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
|
||||
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.9 h1:1IxuqvBUU3S2Bi4YC7tlP9SJF1gVpCvqN0T2Qof4azE=
|
||||
github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY=
|
||||
github.com/go-pg/pg/v9 v9.0.0-beta.14/go.mod h1:T2Sr6bpTCOr2lUqOUMiXLMJqZHSUBKk1LdgSqjwhZfA=
|
||||
github.com/go-pg/pg/v9 v9.0.3/go.mod h1:Tm/Q3Vt6gdQOH6TTN1H/xLlIXc+Qrka7TZ6uREtu/eA=
|
||||
github.com/go-pg/pg/v9 v9.1.4/go.mod h1:QM13HBLkdml4zcKOfUfGLymM6hb72aKTJLrmaH8rsFg=
|
||||
github.com/go-pg/pg/v9 v9.1.7 h1:JSAszC/xbOHmvS86fPnvxCQ288lR0ecX7yqxiPnBoNo=
|
||||
github.com/go-pg/pg/v9 v9.1.7/go.mod h1:QM13HBLkdml4zcKOfUfGLymM6hb72aKTJLrmaH8rsFg=
|
||||
github.com/go-pg/urlstruct v0.1.0/go.mod h1:2Nag+BIny6G/KYCkdt++ZnqU/VinzimGapKfs4kwlN0=
|
||||
github.com/go-pg/urlstruct v0.2.6/go.mod h1:dxENwVISWSOX+k87hDt0ueEJadD+gZWv3tHzwfmZPu8=
|
||||
github.com/go-pg/urlstruct v0.3.0 h1:ORiTb205uT7v7lvq4VUOQ4ddJ5TjFRlVRWqWsMBgek4=
|
||||
github.com/go-pg/urlstruct v0.3.0/go.mod h1:/XKyiUOUUS3onjF+LJxbfmSywYAdl6qMfVbX33Q8rgg=
|
||||
github.com/go-pg/zerochecker v0.1.1 h1:av77Qe7Gs+1oYGGh51k0sbZ0bUaxJEdeP0r8YE64Dco=
|
||||
github.com/go-pg/zerochecker v0.1.1/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo=
|
||||
github.com/go-redis/redis v6.15.6+incompatible h1:H9evprGPLI8+ci7fxQx6WNZHJSb7be8FqJQRhdQZ5Sg=
|
||||
github.com/go-redis/redis v6.15.6+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v8 v8.0.0-beta.2 h1:9S28J9QMBotgI3tGgXbX1Wk9i8QYC3Orw4bTLoPrQeI=
|
||||
github.com/go-redis/redis/v8 v8.0.0-beta.2/go.mod h1:o1M7JtsgfDYyv3o+gBn/jJ1LkqpnCrmil7PSppZGBak=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
||||
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
|
||||
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
|
||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/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.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.21.0 h1:CWyXh/jylQWp2dtiV33mY4iSSp6yf4lmn+c7/tN+ObI=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.21.0/go.mod h1:nCLIt0w3Ept2NwF8ThLmrppXsfT07oC8k0XNDxd8sVU=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
|
||||
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea/go.mod h1:pNv7Wc3ycL6F5oOWn+tPGo2gWD4a5X+yp/ntwdKLjRk=
|
||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c h1:yyIH4qCFf5LD5PKhXoX4BZh3wRjd59xBV4eAQTBwS6k=
|
||||
github.com/integration-system/bellows v0.0.0-20190821124023-244325e8836c/go.mod h1:6cf4ZNvtzZ/KMiuc+d5Y7rSHjzlYBWEqbVyDfUDhqIE=
|
||||
github.com/integration-system/bellows v1.0.0 h1:fVFBYo7Oty4IiIWukjSgBoaCi+0EmPz7LMO8ACs+gDc=
|
||||
github.com/integration-system/bellows v1.0.0/go.mod h1:qHPg1ptN3AHHr0f/wvoicfA2LOCprOyrbXnIa5QIRe0=
|
||||
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f h1:52UOJguw5yqe1y2JjmyVxGcZf3kv2BQeUodR363MkiQ=
|
||||
github.com/integration-system/go-cmp v0.0.0-20190131081942-ac5582987a2f/go.mod h1:w+dmaWojuIwNujSYg6qt1wKHhSdorLOivCEl/XuLzbM=
|
||||
github.com/integration-system/gowsdl v1.0.0 h1:rDv5HrzNUs6aWTj9roSDS9ZdIf58FzF0YVP2nusvbto=
|
||||
github.com/integration-system/gowsdl v1.0.0/go.mod h1:ZwTCE+Av5aQLnPj2/3PIop6mzCs1FY7jXrcWDvSjrBA=
|
||||
github.com/integration-system/isp-etp-go/v2 v2.1.0/go.mod h1:Ndq5DMM3sDJjZn4cyKKvZrVED0FMeoXMRWHZTq+2Z1o=
|
||||
github.com/integration-system/isp-etp-go/v2 v2.1.1 h1:6LU9eE1cGVpp8HNRYu83K4hY49YlNPFd/uj3+Iog4ro=
|
||||
github.com/integration-system/isp-etp-go/v2 v2.1.1/go.mod h1:Ndq5DMM3sDJjZn4cyKKvZrVED0FMeoXMRWHZTq+2Z1o=
|
||||
github.com/integration-system/isp-io v0.0.0-20190723122940-3daf588d878f h1:nJGOobuawo5d3QgoLl1i2SJVDIHkxMl0bhH1+iqZmnk=
|
||||
github.com/integration-system/isp-io v0.0.0-20190723122940-3daf588d878f/go.mod h1:1cjy4g5F8WXrOB3l/bL3mw+TCWDppOL1pz08wOAMi9Y=
|
||||
github.com/integration-system/isp-journal v1.5.0 h1:7Lpt7dHhpq1zRY4qRRYUMiEnaQZbxyPHRcy/ik/Vm8I=
|
||||
github.com/integration-system/isp-journal v1.5.0/go.mod h1:B6cLJqjNL+XHWv4IzKt5aIZ7AjbHX2tQFXgRSaWNNIo=
|
||||
github.com/integration-system/isp-lib/v2 v2.3.1/go.mod h1:eRSmS3+S8WXTUKu7YtSimFJDrLF+/esM/989NBEsP2o=
|
||||
github.com/integration-system/isp-lib/v2 v2.6.3 h1:YbIids+aslyi4ieToYjUuWbPoQ4i4d4Ld4dNC8AVvSU=
|
||||
github.com/integration-system/isp-lib/v2 v2.6.3/go.mod h1:ZGW7qQsCuELBHRBnSSDSEonPx+FxAfHiAfwsGQZzVO4=
|
||||
github.com/integration-system/isp-log v1.1.2 h1:bnWxPjDOC1Y/tEzFxa42aG+xaPRWizuJADAwXgp2i5U=
|
||||
github.com/integration-system/isp-log v1.1.2/go.mod h1:VVMr3cHW+RuFurPUSeVz71KUnOGQxogxO5atV9N8ISs=
|
||||
github.com/integration-system/isp-log v1.1.5 h1:YiMx+hV2YyCTfHu5vIjtqSkRtPjr/WY9xvKsvONDVNU=
|
||||
github.com/integration-system/isp-log v1.1.5/go.mod h1:VVMr3cHW+RuFurPUSeVz71KUnOGQxogxO5atV9N8ISs=
|
||||
github.com/integration-system/jsonschema v1.0.0 h1:Lci4sHGhOX27qCgZo5rvJ37Bjcfm+qCwU0yvw6ImEX4=
|
||||
github.com/integration-system/jsonschema v1.0.0/go.mod h1:EoqDH7RmC8Epg5EgjboIxDo7Udv3WX2exGqtIVB4hI0=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/json-iterator/go v1.1.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/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/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.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
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/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=
|
||||
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.10.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
|
||||
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
|
||||
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
|
||||
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||
github.com/nats-io/nats-server/v2 v2.1.4/go.mod h1:Jw1Z28soD/QasIA2uWjXyM9El1jly3YwyFOuR8tH1rg=
|
||||
github.com/nats-io/nats-streaming-server v0.17.0/go.mod h1:ewPBEsmp62Znl3dcRsYtlcfwudxHEdYMtYqUQSt4fE0=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/nats-io/stan.go v0.6.0/go.mod h1:eIcD5bi3pqbHT/xIIvXMwvzXYElgouBvaVRftaE+eac=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
|
||||
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/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.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.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.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
github.com/pressly/goose v2.6.0+incompatible h1:3f8zIQ8rfgP9tyI0Hmcs2YNAqUCL1c+diLe3iU8Qd/k=
|
||||
github.com/pressly/goose v2.6.0+incompatible/go.mod h1:m+QHWCqxR3k8D9l7qfzuC/djtlfzxr34mozWDYEu1z8=
|
||||
github.com/profefe/profefe v0.0.0-20200307211836-5ab457f7a4d8 h1:9lI6rm0yjyeB6Q5zE/SytxlNDgRQ1thnRZGQChtsLRs=
|
||||
github.com/profefe/profefe v0.0.0-20200307211836-5ab457f7a4d8/go.mod h1:QOlABo1QFtwVrB7Rdl8gwY9pqxmln8lIWOQEW1oj1uI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
|
||||
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/prometheus/procfs v0.0.9/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/xid v1.2.2-0.20200205151950-d13a6085d55c/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/savsgio/gotils v0.0.0-20190714152828-365999d0a274 h1:F52t1X2ziOrMcQMVHo8ZxwOrDTMAq6MrlKtL1Atu2wU=
|
||||
github.com/savsgio/gotils v0.0.0-20190714152828-365999d0a274/go.mod h1:w803/Fg1m0hrp1ZT9KNfQe4E4+WOMMFLcgzPvOcye10=
|
||||
github.com/segmentio/encoding v0.1.10 h1:0b8dva47cSuNQR5ZcU3d0pfi9EnPpSK6q7y5ZGEW36Q=
|
||||
github.com/segmentio/encoding v0.1.10/go.mod h1:RWhr02uzMB9gQC1x+MfYxedtmBibb9cZ6Vv9VxRSSbw=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
|
||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.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/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
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/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/grmq v1.6.0 h1:V4QRb0sI2CMfdMaMsFGvGvUIDGad5vr3khNU7A3LlP8=
|
||||
github.com/txix-open/grmq v1.6.0/go.mod h1:s+NNNv42+32yLpjvl2tpqtyBbMB9e7kKFee3lfa/dyo=
|
||||
github.com/txix-open/isp-kit v1.38.1 h1:IYsiW2xc06//xQsWcHX9A1GXCGTXQRXbUqotcxa6eDY=
|
||||
github.com/txix-open/isp-kit v1.38.1/go.mod h1:uVn5y71Rg8jlFjFK3+QCh9uw1O7mcK+1grCNFZRWhME=
|
||||
github.com/txix-open/jsonschema v1.2.0 h1:B8TrdSsPhDvYv67oi/LVqf7/+PuqFlMsNwUzGeHfl1s=
|
||||
github.com/txix-open/jsonschema v1.2.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99 h1:Z0Sqf+U+Sc6hfIXtRCIZlbJprkCjwMFbS4ZbEPQ44To=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20240401163703-e83541b40f99/go.mod h1:pA0NYmhL0uEkkxj55S+S7MZU4e2QIt46x9XSrzrWc3c=
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc=
|
||||
github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.53.0 h1:IVtyPth4Rs5P8wIf0mP2KVKFNTJ4paX9qQ4Hkh5gFdc=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.53.0/go.mod h1:ImRBLMJv177/pwiLZ7tU7HDGNdBv7rS0HQ99eN/zBl8=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg=
|
||||
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
|
||||
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0/go.mod h1:s75jGIWA9OfCMzF0xr+ZgfrB5FEbbV7UuYo32ahUiFI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk=
|
||||
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
|
||||
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
|
||||
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
|
||||
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
|
||||
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
|
||||
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
|
||||
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
|
||||
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
|
||||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 h1:+/tmTy5zAieooKIXfzDm9KiA3Bv6JBwriRN9LY+yayk=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988/go.mod h1:4+X6GvPs+25wZKbQq9qyAXrwIRExv7w0Ea6MgZLZiDM=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988 h1:V71AcdLZr2p8dC9dbOIMCpqi4EmRl8wUwnJzXXLmbmc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240812133136-8ffd90a71988/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY=
|
||||
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
|
||||
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14 h1:PyYN9JH5jY9j6av01SpfRMb+1DWg/i3MbGOKPxJ2wjM=
|
||||
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E=
|
||||
github.com/swaggo/gin-swagger v1.2.0/go.mod h1:qlH2+W7zXGZkczuL+r2nEBR2JTT+/lX05Nn6vPhc7OI=
|
||||
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba h1:lUPlXKqgbqT2SVg2Y+eT9mu5wbqMnG+i/+Q9nK7C0Rs=
|
||||
github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba/go.mod h1:O1lAbCgAAX/KZ80LM/OXwtWFI/5TvZlwxSg8Cq08PV0=
|
||||
github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y=
|
||||
github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio=
|
||||
github.com/swaggo/swag v1.6.7 h1:e8GC2xDllJZr3omJkm9YfmK0Y56+rMO3cg0JBKNz09s=
|
||||
github.com/swaggo/swag v1.6.7/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc=
|
||||
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3 h1:COy7ekr2jBEd34npP2LvMTqk9UtiLkuvkjiJFHihlTo=
|
||||
github.com/thecodeteam/goodbye v0.0.0-20170927022442-a83968bda2d3/go.mod h1:ehwM4AFY4byYSorQbigh79cKUOUNL3pAOz5eCAQNlGI=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/ugorji/go v1.1.5-pre/go.mod h1:FwP/aQVg39TXzItUBMwnWp9T9gPQnXw4Poh4/oBQZ/0=
|
||||
github.com/ugorji/go/codec v0.0.0-20181022190402-e5e69e061d4f/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2tfCQDUqRd8fI=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.4.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
|
||||
github.com/valyala/fasthttp v1.9.0 h1:hNpmUdy/+ZXYpGy0OBfm7K0UQTzb73W0T0U4iJIVrMw=
|
||||
github.com/valyala/fasthttp v1.9.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
|
||||
github.com/valyala/fasthttp v1.16.0 h1:9zAqOYLl8Tuy3E5R6ckzGDJ1g8+pw15oQp2iL9Jl6gQ=
|
||||
github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
github.com/vmihailenco/bufpool v0.1.5 h1:mEO/biwhAgiY97yPMmAdH4PvaIu63C6uGBdfSdoMo/I=
|
||||
github.com/vmihailenco/bufpool v0.1.5/go.mod h1:fL9i/PRTuS7AELqAHwSU1Zf1c70xhkhGe/cD5ud9pJk=
|
||||
github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94=
|
||||
github.com/vmihailenco/bufpool v0.1.11/go.mod h1:AFf/MOy3l2CFTKbxwt0mp2MwnqjNEs5H/UxrkA5jxTQ=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.5/go.mod h1:DuaveEe48abshDmz5UBKyZ+yDugvaeFk5ayfrewUOaw=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.7 h1:Aj4eMY2qXTRfWRwHKJ2n/CWKVy15pCYN327QMJ/OUVs=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.7/go.mod h1:Ii+PksJlvFT5ZRcB/4YLAInMIp6a0WOCm0L3BU0aNG4=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.11 h1:Q47CePddpNGNhk4GCnAx9DDtASi2rasatE0cd26cZoE=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.11/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||
github.com/vmihailenco/tagparser v0.1.0/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
|
||||
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.opentelemetry.io/otel v0.5.0 h1:tdIR1veg/z+VRJaw/6SIxz+QX3l+m+BDleYLTs+GC1g=
|
||||
go.opentelemetry.io/otel v0.5.0/go.mod h1:jzBIgIzK43Iu1BpDAXwqOd6UPsSAk+ewVZ5ofSXw4Ek=
|
||||
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20191128160524-b544559bb6d1/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
|
||||
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222033325-078779b8f2d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 h1:sfkvUWPNGwSV+8/fNqctR5lS2AqCSqYwXdrjCxp/dXo=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
|
||||
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200220224806-8a925fa4c0df/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200826040757-bc8aaaa29e06 h1:ChBCbOHeLqK+j+znGPlWCcvx/t2PdxmyPBheVZxXbcc=
|
||||
golang.org/x/tools v0.0.0-20200826040757-bc8aaaa29e06/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200211111953-2dc5924e3898 h1:bKX1IGaSj2XD9yfWNts9HKRdQRH0lOZ0S7Nb8meQSlY=
|
||||
google.golang.org/genproto v0.0.0-20200211111953-2dc5924e3898/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36 h1:j7CmVRD4Kec0+f8VuBAc2Ak2MFfXm5Q2/RxuJLL+76E=
|
||||
google.golang.org/genproto v0.0.0-20200413115906-b5235f65be36/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 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/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
|
||||
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.2/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
|
||||
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
|
||||
nhooyr.io/websocket v1.7.4 h1:w/LGB2sZT0RV8lZYR7nfyaYz4PUbYZ5oF7NBon2M0NY=
|
||||
nhooyr.io/websocket v1.7.4/go.mod h1:PxYxCwFdFYQ0yRvtQz3s/dC+VEm7CSuC/4b9t8MQQxw=
|
||||
nhooyr.io/websocket v1.8.4 h1:P43INlkmY2eCxLvHeiMFK/ROUiOm0NdzRGGDtURbe58=
|
||||
nhooyr.io/websocket v1.8.4/go.mod h1:LiqdCg1Cu7TPWxEvPjPa0TGYxCsy4pHNTN9gGluwBpQ=
|
||||
@@ -0,0 +1,125 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
"isp-gate-service/accounting"
|
||||
"isp-gate-service/authenticate"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/invoker"
|
||||
"isp-gate-service/log_code"
|
||||
"isp-gate-service/proxy"
|
||||
"isp-gate-service/routing"
|
||||
"isp-gate-service/service"
|
||||
"isp-gate-service/service/matcher"
|
||||
"isp-gate-service/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
execution = 1e6
|
||||
)
|
||||
|
||||
var (
|
||||
errAccounting = errors.New("accounting error")
|
||||
|
||||
helper handlerHelper
|
||||
)
|
||||
|
||||
type handlerHelper struct{}
|
||||
|
||||
func CompleteRequest(ctx *fasthttp.RequestCtx) {
|
||||
currentTime := time.Now()
|
||||
|
||||
method, resp := helper.AuthenticateAccountingProxy(ctx)
|
||||
|
||||
executionTime := time.Since(currentTime) / execution
|
||||
|
||||
statusCode := ctx.Response.StatusCode()
|
||||
service.Metrics.UpdateStatusCounter(helper.SetMetricStatus(statusCode))
|
||||
if statusCode == http.StatusOK {
|
||||
service.Metrics.UpdateMethodResponseTime(method, executionTime)
|
||||
}
|
||||
|
||||
logEnable := config.GetRemote().(*conf.RemoteConfig).JournalSetting.Journal.Enable
|
||||
//nolint
|
||||
if logEnable && matcher.JournalMethods.Match(method) {
|
||||
requestBody, responseBody, err := resp.Get()
|
||||
if err != nil {
|
||||
if err := invoker.Journal.Error(method, requestBody, responseBody, err); err != nil {
|
||||
log.Warnf(log_code.WarnJournalCouldNotWriteToFile, "could not write to file journal: %v", err)
|
||||
}
|
||||
} else {
|
||||
if err := invoker.Journal.Info(method, requestBody, responseBody); err != nil {
|
||||
log.Warnf(log_code.WarnJournalCouldNotWriteToFile, "could not write to file journal: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (handlerHelper) AuthenticateAccountingProxy(ctx *fasthttp.RequestCtx) (string, domain.ProxyResponse) {
|
||||
initialPath := string(ctx.Path())
|
||||
|
||||
p := proxy.RoutingProxy
|
||||
path := proxy.GetPathWithoutApiPrefix(initialPath)
|
||||
if p == nil {
|
||||
msg := fmt.Sprintf("unknown proxy for '%s'", initialPath)
|
||||
utils.WriteError(ctx, msg, codes.NotFound, nil)
|
||||
return initialPath, domain.Create().SetError(errors.New(msg))
|
||||
}
|
||||
|
||||
if !p.SkipExistCheck() {
|
||||
if _, ok := routing.AllMethods[path]; !ok {
|
||||
msg := "not implemented"
|
||||
utils.WriteError(ctx, msg, codes.Unimplemented, nil)
|
||||
return path, domain.Create().SetError(errors.New(msg))
|
||||
}
|
||||
}
|
||||
|
||||
if !p.SkipAuth() {
|
||||
applicationId, err := authenticate.Do(ctx, path)
|
||||
if err != nil {
|
||||
message := "unknown error"
|
||||
status := codes.Unknown
|
||||
details := make([]interface{}, 0)
|
||||
if e, ok := err.(authenticate.ErrorDescription); ok {
|
||||
message = e.Message()
|
||||
status = e.ConvertToGrpcStatus()
|
||||
details = e.Details()
|
||||
}
|
||||
utils.WriteError(ctx, message, status, details)
|
||||
return path, domain.Create().SetError(err)
|
||||
}
|
||||
if !accounting.AcceptRequest(applicationId, path) {
|
||||
err := errAccounting
|
||||
utils.WriteError(ctx, "too many requests", codes.ResourceExhausted, nil)
|
||||
return path, domain.Create().SetError(err)
|
||||
}
|
||||
}
|
||||
|
||||
return path, p.ProxyRequest(ctx, path)
|
||||
}
|
||||
|
||||
func (handlerHelper) SetMetricStatus(statusCode int) string {
|
||||
metricStatus := "5xx"
|
||||
switch {
|
||||
case statusCode >= 100 && statusCode < 200:
|
||||
metricStatus = "1xx"
|
||||
case statusCode >= 200 && statusCode < 300:
|
||||
metricStatus = "2xx"
|
||||
case statusCode >= 300 && statusCode < 400:
|
||||
metricStatus = "3xx"
|
||||
case statusCode >= 400 && statusCode < 500:
|
||||
metricStatus = "4xx"
|
||||
case statusCode >= 500 && statusCode < 600:
|
||||
metricStatus = "5xx"
|
||||
}
|
||||
return metricStatus
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package httperrors
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
)
|
||||
|
||||
type HttpError struct {
|
||||
statusCode int
|
||||
userMessage string
|
||||
details []interface{}
|
||||
err error
|
||||
}
|
||||
|
||||
func New(statusCode int, userMessage string, internalError error) HttpError {
|
||||
return HttpError{
|
||||
statusCode: statusCode,
|
||||
userMessage: userMessage,
|
||||
err: internalError,
|
||||
}
|
||||
}
|
||||
|
||||
func (e HttpError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
func (e HttpError) WriteError(w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(e.statusCode)
|
||||
data := map[string]interface{}{
|
||||
"errorCode": http.StatusText(e.statusCode),
|
||||
"errorMessage": e.userMessage,
|
||||
"details": e.details,
|
||||
}
|
||||
return json.NewEncoder(w).Encode(data)
|
||||
}
|
||||
|
||||
func (e *HttpError) WithDetails(details ...interface{}) {
|
||||
e.details = details
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package invoker
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-journal/rx"
|
||||
"github.com/integration-system/isp-lib/v2/backend"
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type journalService struct {
|
||||
*rx.RxJournal
|
||||
}
|
||||
|
||||
var (
|
||||
journalClient = backend.NewRxGrpcClient(
|
||||
backend.WithDialOptions(grpc.WithInsecure()),
|
||||
)
|
||||
Journal = &journalService{RxJournal: rx.NewDefaultRxJournal(journalClient)}
|
||||
)
|
||||
|
||||
func (*journalService) ReceiveServiceAddressList(list []structure.AddressConfiguration) bool {
|
||||
if ok := journalClient.ReceiveAddressList(list); !ok {
|
||||
return false
|
||||
}
|
||||
go Journal.CollectAndTransferExistedLogs()
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package log_code
|
||||
|
||||
const (
|
||||
WarnHttpServerShutdown = 602
|
||||
ErrorHttpServerListen = 603
|
||||
|
||||
WarnProxyGrpcHandler = 604 //metadata: {"typeData":"", "method":""}
|
||||
WarnConvertErrorDataMarshalResponse = 605
|
||||
|
||||
ErrorClientGrpc = 606
|
||||
|
||||
WarnJournalCouldNotWriteToFile = 607
|
||||
|
||||
ErrorClientJournal = 608
|
||||
ErrorClientRedis = 609
|
||||
ErrorClientHttp = 611
|
||||
|
||||
ErrorAuthenticate = 612
|
||||
|
||||
ErrorClientDatabase = 615
|
||||
ErrorSnapshotAccounting = 616
|
||||
ErrorUnloadAccounting = 617
|
||||
|
||||
ErrorWebsocketProxy = 618
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
package log_code
|
||||
|
||||
const (
|
||||
MdTypeData = "typeData"
|
||||
MdMethod = "method"
|
||||
)
|
||||
|
||||
var (
|
||||
TypeData = typeData{
|
||||
SendMultipart: "sendMultipart",
|
||||
GetFile: "getFile",
|
||||
JsonContent: "jsonContent",
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
typeData struct {
|
||||
SendMultipart string
|
||||
GetFile string
|
||||
JsonContent string
|
||||
}
|
||||
)
|
||||
@@ -1,37 +1,105 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/shutdown"
|
||||
"isp-gate-service/assembly"
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/bootstrap"
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/integration-system/isp-lib/v2/config/schema"
|
||||
"github.com/integration-system/isp-lib/v2/metric"
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
"isp-gate-service/accounting"
|
||||
"isp-gate-service/authenticate"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/invoker"
|
||||
"isp-gate-service/model"
|
||||
"isp-gate-service/proxy"
|
||||
"isp-gate-service/redis"
|
||||
"isp-gate-service/routing"
|
||||
"isp-gate-service/server"
|
||||
"isp-gate-service/service"
|
||||
"isp-gate-service/service/matcher"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "1.0.0"
|
||||
version = "0.1.0"
|
||||
)
|
||||
|
||||
func main() {
|
||||
boot := bootstrap.New(version, conf.Remote{}, nil)
|
||||
app := boot.App
|
||||
logger := app.Logger()
|
||||
cfg := config.InitConfig(&conf.Configuration{}).(*conf.Configuration)
|
||||
|
||||
assembly, err := assembly.New(boot)
|
||||
if err != nil {
|
||||
logger.Fatal(app.Context(), err)
|
||||
}
|
||||
app.AddRunners(assembly.Runners()...)
|
||||
app.AddClosers(assembly.Closers()...)
|
||||
bs := bootstrap.
|
||||
ServiceBootstrap(&conf.Configuration{}, &conf.RemoteConfig{}).
|
||||
OnLocalConfigLoad(onLocalConfigLoad).
|
||||
DefaultRemoteConfigPath(schema.ResolveDefaultConfigPath("default_remote_config.json")).
|
||||
DeclareMe(makeDeclaration).
|
||||
SocketConfiguration(socketConfiguration).
|
||||
RequireRoutes(handleRouteUpdate).
|
||||
RequireModule("journal", invoker.Journal.ReceiveServiceAddressList, false).
|
||||
SubscribeBroadcastEvent(bootstrap.ListenRestartEvent()).OnShutdown(onShutdown)
|
||||
|
||||
shutdown.On(func() {
|
||||
logger.Info(app.Context(), "starting shutdown")
|
||||
app.Shutdown()
|
||||
logger.Info(app.Context(), "shutdown completed")
|
||||
})
|
||||
proxy.ApiPathPrefix = cfg.RouterConfig.PathPrefix
|
||||
proxyConsumer := proxy.InitRoutingProxy(cfg.RouterConfig.SkipAuth, cfg.RouterConfig.SkipExistCheck)
|
||||
bs.RequireModule(cfg.RouterConfig.RouterModuleName, proxyConsumer, true).
|
||||
OnRemoteConfigReceive(onRemoteConfigReceive).
|
||||
Run()
|
||||
}
|
||||
|
||||
err = app.Run()
|
||||
if err != nil {
|
||||
app.Shutdown()
|
||||
logger.Fatal(app.Context(), err)
|
||||
func onLocalConfigLoad(_ *conf.Configuration) {
|
||||
|
||||
}
|
||||
|
||||
func onRemoteConfigReceive(remoteConfig, oldRemoteConfig *conf.RemoteConfig) {
|
||||
localCfg := config.Get().(*conf.Configuration)
|
||||
|
||||
model.DbClient.ReceiveConfiguration(remoteConfig.Database)
|
||||
invoker.Journal.ReceiveConfiguration(remoteConfig.JournalSetting.Journal, localCfg.ModuleName)
|
||||
matcher.JournalMethods = matcher.NewAtLeastOneMatcher(remoteConfig.JournalSetting.MethodsPatterns)
|
||||
|
||||
redis.Client.ReceiveConfiguration(remoteConfig.Redis)
|
||||
authenticate.ReceiveConfiguration(remoteConfig.AuthCacheSetting)
|
||||
accounting.ReceiveConfiguration(remoteConfig.AccountingSetting)
|
||||
|
||||
metric.InitCollectors(remoteConfig.Metrics, oldRemoteConfig.Metrics)
|
||||
metric.InitHttpServer(remoteConfig.Metrics)
|
||||
service.Metrics.Init()
|
||||
|
||||
server.Http.Init(remoteConfig.HttpSetting, oldRemoteConfig.HttpSetting)
|
||||
}
|
||||
|
||||
func socketConfiguration(cfg interface{}) structure.SocketConfiguration {
|
||||
appConfig := cfg.(*conf.Configuration)
|
||||
return structure.SocketConfiguration{
|
||||
Host: appConfig.ConfigServiceAddress.IP,
|
||||
Port: appConfig.ConfigServiceAddress.Port,
|
||||
Secure: false,
|
||||
UrlParams: map[string]string{
|
||||
"module_name": appConfig.ModuleName,
|
||||
"instance_uuid": appConfig.InstanceUuid,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func onShutdown(_ context.Context, _ os.Signal) {
|
||||
server.Http.Close()
|
||||
accounting.Close()
|
||||
proxy.Close()
|
||||
_ = redis.Client.Close()
|
||||
_ = invoker.Journal.Close()
|
||||
}
|
||||
|
||||
func handleRouteUpdate(configs structure.RoutingConfig) bool {
|
||||
routing.InitRoutes(configs)
|
||||
return true
|
||||
}
|
||||
|
||||
func makeDeclaration(localConfig interface{}) bootstrap.ModuleInfo {
|
||||
cfg := localConfig.(*conf.Configuration)
|
||||
return bootstrap.ModuleInfo{
|
||||
ModuleName: cfg.ModuleName,
|
||||
ModuleVersion: version,
|
||||
GrpcOuterAddress: cfg.HttpOuterAddress,
|
||||
Endpoints: []structure.EndpointDescriptor{},
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
adminAuthHeader = "x-auth-admin"
|
||||
)
|
||||
|
||||
type AdminAuthenticator interface {
|
||||
AdminAuthenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error)
|
||||
}
|
||||
|
||||
func AdminAuthenticate(auth AdminAuthenticator) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
adminToken := ctx.Param(adminAuthHeader)
|
||||
if adminToken == "" {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
resp, err := auth.AdminAuthenticate(ctx.Context(), adminToken)
|
||||
if err != nil {
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"invalid admin token",
|
||||
errors.WithMessage(err, "admin authenticate: authenticate"),
|
||||
)
|
||||
}
|
||||
if !resp.Authenticated {
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"invalid admin token",
|
||||
errors.WithMessage(errors.New(resp.ErrorReason), "admin authenticate: authenticate"),
|
||||
)
|
||||
}
|
||||
ctx.AuthenticateAdmin(resp.AdminId, adminToken)
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type AdminMethodStore interface {
|
||||
IsInnerEndpoint(path string) bool
|
||||
RequiredAdminPermission(path string) (string, bool)
|
||||
}
|
||||
|
||||
type AdminAuthorizer interface {
|
||||
AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error)
|
||||
}
|
||||
|
||||
func AdminAuthorize(store AdminMethodStore, authorizer AdminAuthorizer) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
isInner := store.IsInnerEndpoint(ctx.Endpoint())
|
||||
if !isInner {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
if !ctx.IsAdminAuthenticated() {
|
||||
return httperrors.New(
|
||||
http.StatusForbidden,
|
||||
"admin authentication required",
|
||||
errors.Errorf("admin authorization: admin authentication required for '%s'", ctx.Endpoint()),
|
||||
)
|
||||
}
|
||||
|
||||
requiredPerm, ok := store.RequiredAdminPermission(ctx.Endpoint())
|
||||
if !ok {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
ok, err := authorizer.AdminAuthorize(ctx.Context(), ctx.AdminId(), requiredPerm)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "admin authorization: authorize")
|
||||
}
|
||||
if !ok {
|
||||
return httperrors.New(
|
||||
http.StatusForbidden,
|
||||
"endpoint is not allowed",
|
||||
errors.Errorf(
|
||||
"admin authorization: endpoint '%s' requires '%s' permission, but admin '%d' doesn't have it",
|
||||
ctx.Endpoint(), requiredPerm, ctx.AdminId(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
const (
|
||||
applicationTokenHeader = "x-application-token"
|
||||
)
|
||||
|
||||
type Authenticator interface {
|
||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
||||
}
|
||||
|
||||
func Authenticate(authenticator Authenticator) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
token := ctx.Param(applicationTokenHeader)
|
||||
if token == "" {
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"application token required",
|
||||
errors.New("authenticate: application token required"),
|
||||
)
|
||||
}
|
||||
|
||||
resp, err := authenticator.Authenticate(ctx.Context(), token)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "authenticate: authenticate")
|
||||
}
|
||||
if !resp.Authenticated {
|
||||
return httperrors.New(
|
||||
http.StatusUnauthorized,
|
||||
"invalid application token",
|
||||
errors.WithMessage(errors.New(resp.ErrorReason), "authenticate: authenticate"),
|
||||
)
|
||||
}
|
||||
ctx.Authenticate(request.AuthData(*resp.AuthData))
|
||||
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type Authorizer interface {
|
||||
Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
||||
}
|
||||
|
||||
func Authorize(authorizer Authorizer, logger log.Logger) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "authorize: get auth data")
|
||||
}
|
||||
|
||||
ok, err := authorizer.Authorize(ctx.Context(), authData.ApplicationId, ctx.Endpoint())
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "authorize: authorize")
|
||||
}
|
||||
if !ok && ctx.IsAdminAuthenticated() {
|
||||
logger.Info(
|
||||
ctx.Context(),
|
||||
"bypassing unauthorized request because it has admin privilege",
|
||||
log.Int("applicationId", authData.ApplicationId),
|
||||
log.Int("adminId", ctx.AdminId()),
|
||||
)
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
if !ok {
|
||||
return httperrors.New(
|
||||
http.StatusForbidden,
|
||||
"endpoint is not allowed",
|
||||
errors.Errorf("authorize: endpoint '%s' is not allowed for application '%d'", ctx.Endpoint(), authData.ApplicationId),
|
||||
)
|
||||
}
|
||||
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type DailyLimitChecker interface {
|
||||
IncrementAndCheck(ctx context.Context, applicationId int) (bool, error)
|
||||
}
|
||||
|
||||
func DailyLimit(checker DailyLimitChecker) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "daily limit: get auth data")
|
||||
}
|
||||
|
||||
ok, err := checker.IncrementAndCheck(ctx.Context(), authData.ApplicationId)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "daily limit: increment and check")
|
||||
}
|
||||
if !ok {
|
||||
return httperrors.New(
|
||||
http.StatusTooManyRequests,
|
||||
"daily requests limit has been reached",
|
||||
errors.Errorf("daily limit: daily requests limit has been reached for application '%d'", authData.ApplicationId),
|
||||
)
|
||||
}
|
||||
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type EntryPointConfig struct {
|
||||
PathPrefix string
|
||||
WithPrefix bool
|
||||
}
|
||||
|
||||
func Entrypoint(maxReqBodySize int64, next Handler, logger log.Logger, cfg EntryPointConfig) http.Handler {
|
||||
return http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
|
||||
req.Body = http.MaxBytesReader(writer, req.Body, maxReqBodySize)
|
||||
|
||||
endpoint := req.URL.Path
|
||||
if !cfg.WithPrefix {
|
||||
prefix := fmt.Sprintf("%s/", cfg.PathPrefix)
|
||||
endpoint = strings.TrimPrefix(req.URL.Path, prefix)
|
||||
}
|
||||
ctx := request.NewContext(req, writer, endpoint)
|
||||
|
||||
err := next.Handle(ctx)
|
||||
if err != nil {
|
||||
logger.Error(req.Context(), errors.WithMessage(err, "uncaught error"))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type HttpError interface {
|
||||
WriteError(w http.ResponseWriter) error
|
||||
}
|
||||
|
||||
func ErrorHandler(logger log.Logger) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
err := next.Handle(ctx)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
logger.Error(ctx.Context(), err)
|
||||
|
||||
httpErr, ok := err.(HttpError)
|
||||
if ok {
|
||||
return httpErr.WriteError(ctx.ResponseWriter())
|
||||
}
|
||||
|
||||
return httperrors.
|
||||
New(http.StatusInternalServerError, "internal service error", err).
|
||||
WriteError(ctx.ResponseWriter())
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/http/endpoint/buffer"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type scSource interface {
|
||||
StatusCode() int
|
||||
}
|
||||
|
||||
type writerWrapper struct {
|
||||
http.ResponseWriter
|
||||
statusCode int
|
||||
}
|
||||
|
||||
func (w *writerWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
||||
upstream, ok := w.ResponseWriter.(http.Hijacker)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("writerWrapper: upstream writer doesn't implement Hijack")
|
||||
}
|
||||
return upstream.Hijack()
|
||||
}
|
||||
|
||||
func (w *writerWrapper) StatusCode() int {
|
||||
if w.statusCode == 0 {
|
||||
return http.StatusOK
|
||||
}
|
||||
return w.statusCode
|
||||
}
|
||||
|
||||
func (w *writerWrapper) WriteHeader(statusCode int) {
|
||||
w.statusCode = statusCode
|
||||
w.ResponseWriter.WriteHeader(statusCode)
|
||||
}
|
||||
|
||||
func Logger(
|
||||
logger log.Logger,
|
||||
enableRequestLogging bool,
|
||||
enableBodyLogging bool,
|
||||
skipBodyLoggingEndpointPrefixes []string,
|
||||
) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
if !enableRequestLogging {
|
||||
return next.Handle(ctx)
|
||||
}
|
||||
|
||||
r := ctx.Request()
|
||||
|
||||
logBodyFromCurrenRequest := enableBodyLogging
|
||||
if logBodyFromCurrenRequest {
|
||||
for _, prefix := range skipBodyLoggingEndpointPrefixes {
|
||||
if strings.HasPrefix(ctx.Endpoint(), prefix) {
|
||||
logBodyFromCurrenRequest = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var scSrc scSource
|
||||
var buf *buffer.Buffer
|
||||
if logBodyFromCurrenRequest {
|
||||
buf = buffer.Acquire(ctx.ResponseWriter())
|
||||
defer buffer.Release(buf)
|
||||
|
||||
err := buf.ReadRequestBody(r.Body)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "logger: read request body for logging")
|
||||
}
|
||||
err = r.Body.Close()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "logger: close request reader")
|
||||
}
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf.RequestBody()))
|
||||
|
||||
scSrc = buf
|
||||
ctx.SetResponseWriter(buf)
|
||||
} else {
|
||||
writer := &writerWrapper{ResponseWriter: ctx.ResponseWriter()}
|
||||
scSrc = writer
|
||||
ctx.SetResponseWriter(writer)
|
||||
}
|
||||
|
||||
originalPath := r.URL.Path //
|
||||
// can be changed in http proxy
|
||||
err := next.Handle(ctx)
|
||||
|
||||
authData, _ := ctx.GetAuthData()
|
||||
fields := []log.Field{
|
||||
log.String("httpMethod", r.Method),
|
||||
log.String("remoteAddr", r.RemoteAddr),
|
||||
log.String("xForwardedFor", r.Header.Get("X-Forwarded-For")),
|
||||
log.Int("statusCode", scSrc.StatusCode()),
|
||||
log.String("path", originalPath),
|
||||
log.String("endpoint", ctx.Endpoint()),
|
||||
log.Int("applicationId", authData.ApplicationId),
|
||||
log.Int("adminId", ctx.AdminId()),
|
||||
}
|
||||
|
||||
if logBodyFromCurrenRequest {
|
||||
fields = append(fields,
|
||||
log.ByteString("request", buf.RequestBody()),
|
||||
log.ByteString("response", buf.ResponseBody()),
|
||||
)
|
||||
}
|
||||
logger.Debug(ctx.Context(), "log request", fields...)
|
||||
|
||||
return err
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type Handler interface {
|
||||
Handle(ctx *request.Context) error
|
||||
}
|
||||
|
||||
type HandlerFunc func(ctx *request.Context) error
|
||||
|
||||
func (f HandlerFunc) Handle(ctx *request.Context) error {
|
||||
return f(ctx)
|
||||
}
|
||||
|
||||
type Middleware func(next Handler) Handler
|
||||
|
||||
// nolint:ireturn
|
||||
func Chain(root Handler, middlewares ...Middleware) Handler {
|
||||
for i := len(middlewares) - 1; i >= 0; i-- {
|
||||
root = middlewares[i](root)
|
||||
}
|
||||
return root
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/txix-open/isp-kit/requestid"
|
||||
)
|
||||
|
||||
const (
|
||||
requestIdHeader = "x-request-id"
|
||||
)
|
||||
|
||||
func RequestId(forwardClientRequestId bool) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
requestId := requestid.Next()
|
||||
clientRequestId := strings.TrimSpace(ctx.Request().Header.Get(requestIdHeader))
|
||||
|
||||
logFields := make([]log.Field, 0)
|
||||
if clientRequestId != "" {
|
||||
logFields = append(logFields, log.String("clientRequestId", clientRequestId))
|
||||
if forwardClientRequestId {
|
||||
requestId = clientRequestId
|
||||
}
|
||||
}
|
||||
logFields = append(logFields, log.String("requestId", requestId))
|
||||
|
||||
context := requestid.ToContext(ctx.Context(), requestId)
|
||||
context = log.ToContext(context, logFields...)
|
||||
|
||||
ctx.SetContext(context)
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type Throttler interface {
|
||||
AllowRateLimit(ctx context.Context, applicationId int) (*domain.RateLimitResult, error)
|
||||
}
|
||||
|
||||
func Throttling(throttler Throttler) Middleware {
|
||||
return func(next Handler) Handler {
|
||||
return HandlerFunc(func(ctx *request.Context) error {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "throttling: get auth data")
|
||||
}
|
||||
|
||||
result, err := throttler.AllowRateLimit(ctx.Context(), authData.ApplicationId)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "throttling: allow rate limit")
|
||||
}
|
||||
if !result.Allow {
|
||||
return httperrors.New(
|
||||
http.StatusTooManyRequests,
|
||||
fmt.Sprintf("rate limit has been reached, try after %dms", result.RetryAfter.Milliseconds()),
|
||||
errors.Errorf("throttling: rate limit has been reached for application '%d'", authData.ApplicationId),
|
||||
)
|
||||
}
|
||||
|
||||
return next.Handle(ctx)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
|
||||
CREATE TABLE snapshot(
|
||||
app_id INTEGER PRIMARY KEY,
|
||||
limit_state JSONB
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP SCHEMA IF EXISTS gate_service CASCADE;
|
||||
@@ -0,0 +1,12 @@
|
||||
-- +goose Up
|
||||
|
||||
CREATE TABLE requests
|
||||
(
|
||||
id SERIAL8 PRIMARY KEY,
|
||||
app_id INT4 NOT NULL,
|
||||
method VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE requests;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- +goose Up
|
||||
|
||||
ALTER TABLE snapshot
|
||||
ADD version BIGINT NOT NULL DEFAULT 0;
|
||||
|
||||
-- +goose Down
|
||||
@@ -0,0 +1,20 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"isp-gate-service/log_code"
|
||||
)
|
||||
|
||||
var (
|
||||
DbClient = database.NewRxDbClient(
|
||||
database.WithSchemaEnsuring(),
|
||||
database.WithSchemaAutoInjecting(),
|
||||
database.WithMigrationsEnsuring(),
|
||||
database.WithInitializingErrorHandler(func(err *database.ErrorEvent) {
|
||||
log.Error(log_code.ErrorClientDatabase, err)
|
||||
}))
|
||||
|
||||
SnapshotRep SnapshotRepository = snapshotRepository{rxClient: DbClient}
|
||||
RequestsRep RequestsRepository = requestsRepository{rxClient: DbClient}
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/go-pg/pg/v9/orm"
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
"isp-gate-service/entity"
|
||||
)
|
||||
|
||||
type (
|
||||
RequestsRepository interface {
|
||||
Insert([]entity.Request) error
|
||||
}
|
||||
|
||||
requestsRepository struct {
|
||||
DB orm.DB
|
||||
rxClient *database.RxDbClient
|
||||
}
|
||||
)
|
||||
|
||||
func (r requestsRepository) Insert(model []entity.Request) error {
|
||||
_, err := r.getDb().Model(&model).Insert()
|
||||
return err
|
||||
}
|
||||
|
||||
func (r requestsRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/go-pg/pg/v9"
|
||||
"github.com/integration-system/isp-lib/v2/database"
|
||||
"isp-gate-service/entity"
|
||||
|
||||
"github.com/go-pg/pg/v9/orm"
|
||||
)
|
||||
|
||||
type (
|
||||
SnapshotRepository interface {
|
||||
GetByApplication(int32) (*entity.Snapshot, error)
|
||||
Update([]entity.Snapshot) error
|
||||
}
|
||||
|
||||
snapshotRepository struct {
|
||||
DB orm.DB
|
||||
rxClient *database.RxDbClient
|
||||
}
|
||||
)
|
||||
|
||||
func (r snapshotRepository) Update(list []entity.Snapshot) error {
|
||||
_, err := r.getDb().Model(&list).OnConflict("(app_id) DO UPDATE").
|
||||
Set("version = EXCLUDED.version").
|
||||
Set("app_id = EXCLUDED.app_id").
|
||||
Set("limit_state = EXCLUDED.limit_state").
|
||||
Where("snapshot.version < EXCLUDED.version").
|
||||
Insert()
|
||||
return err
|
||||
}
|
||||
|
||||
func (r snapshotRepository) GetByApplication(appId int32) (*entity.Snapshot, error) {
|
||||
model := new(entity.Snapshot)
|
||||
if err := r.getDb().Model(model).Where("app_id = ?", appId).Select(); err != nil {
|
||||
if err == pg.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
} else {
|
||||
return model, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r snapshotRepository) getDb() orm.DB {
|
||||
if r.DB != nil {
|
||||
return r.DB
|
||||
}
|
||||
return r.rxClient.Unsafe()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package proxy
|
||||
|
||||
const (
|
||||
xAdminIdHeader = "x-admin-id"
|
||||
)
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
// nolint:gochecknoinits
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/grpc/isp"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
"github.com/txix-open/isp-kit/requestid"
|
||||
_ "google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func init() {
|
||||
for httpCode, grpcCode := range codeMap {
|
||||
inverseCodeMap[grpcCode] = httpCode
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
codeMap = map[int]codes.Code{
|
||||
http.StatusOK: codes.OK,
|
||||
http.StatusRequestTimeout: codes.Canceled,
|
||||
http.StatusBadRequest: codes.InvalidArgument,
|
||||
http.StatusGatewayTimeout: codes.DeadlineExceeded,
|
||||
http.StatusNotFound: codes.NotFound,
|
||||
http.StatusConflict: codes.AlreadyExists,
|
||||
http.StatusForbidden: codes.PermissionDenied,
|
||||
http.StatusUnauthorized: codes.Unauthenticated,
|
||||
http.StatusTooManyRequests: codes.ResourceExhausted,
|
||||
http.StatusPreconditionFailed: codes.FailedPrecondition,
|
||||
http.StatusNotImplemented: codes.Unimplemented,
|
||||
http.StatusInternalServerError: codes.Internal,
|
||||
http.StatusServiceUnavailable: codes.Unavailable,
|
||||
}
|
||||
inverseCodeMap = map[codes.Code]int{}
|
||||
)
|
||||
|
||||
type Grpc struct {
|
||||
cli *client.Client
|
||||
skipAuth bool
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func NewGrpc(cli *client.Client, skipAuth bool, timeout time.Duration) Grpc {
|
||||
return Grpc{
|
||||
cli: cli,
|
||||
skipAuth: skipAuth,
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
func (p Grpc) Handle(ctx *request.Context) error {
|
||||
body, err := io.ReadAll(ctx.Request().Body)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "grpc: read body")
|
||||
}
|
||||
|
||||
md := metadata.MD{
|
||||
grpc.ProxyMethodNameHeader: {ctx.Endpoint()},
|
||||
requestid.RequestIdHeader: {requestid.FromContext(ctx.Context())},
|
||||
}
|
||||
if !p.skipAuth {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "get auth data")
|
||||
}
|
||||
md[grpc.SystemIdHeader] = []string{strconv.Itoa(authData.SystemId)}
|
||||
md[grpc.DomainIdHeader] = []string{strconv.Itoa(authData.DomainId)}
|
||||
md[grpc.ServiceIdHeader] = []string{strconv.Itoa(authData.ServiceId)}
|
||||
md[grpc.ApplicationIdHeader] = []string{strconv.Itoa(authData.ApplicationId)}
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
md[xAdminIdHeader] = []string{strconv.Itoa(ctx.AdminId())}
|
||||
}
|
||||
}
|
||||
requestContext := metadata.NewOutgoingContext(ctx.Context(), md)
|
||||
|
||||
requestContext, cancel := context.WithTimeout(requestContext, p.timeout)
|
||||
defer cancel()
|
||||
result, err := p.cli.BackendClient().Request(requestContext, &isp.Message{
|
||||
Body: &isp.Message_BytesBody{BytesBody: body},
|
||||
})
|
||||
if err != nil {
|
||||
return p.handleError(err, ctx.ResponseWriter())
|
||||
}
|
||||
|
||||
return p.writeResponse(http.StatusOK, result.GetBytesBody(), ctx.ResponseWriter())
|
||||
}
|
||||
|
||||
func (p Grpc) handleError(err error, w http.ResponseWriter) error {
|
||||
status, ok := status.FromError(err)
|
||||
if !ok {
|
||||
return httperrors.New(
|
||||
http.StatusServiceUnavailable,
|
||||
"upstream is not available",
|
||||
errors.WithMessage(err, "grpc proxy"),
|
||||
)
|
||||
}
|
||||
|
||||
statusCode := p.codeToHttpStatus(status.Code())
|
||||
for _, detail := range status.Details() {
|
||||
switch typeOfDetail := detail.(type) {
|
||||
case *isp.Message:
|
||||
switch {
|
||||
case typeOfDetail.GetBytesBody() != nil:
|
||||
return p.writeResponse(statusCode, typeOfDetail.GetBytesBody(), w)
|
||||
case typeOfDetail.GetListBody() != nil:
|
||||
return p.writeProto(statusCode, typeOfDetail.GetListBody(), w)
|
||||
case typeOfDetail.GetStructBody() != nil:
|
||||
return p.writeProto(statusCode, typeOfDetail.GetStructBody(), w)
|
||||
}
|
||||
default:
|
||||
return p.writeProto(statusCode, typeOfDetail, w)
|
||||
}
|
||||
}
|
||||
|
||||
return httperrors.New(
|
||||
statusCode,
|
||||
status.Message(),
|
||||
status.Err(),
|
||||
)
|
||||
}
|
||||
|
||||
func (p Grpc) writeProto(statusCode int, proto interface{}, w http.ResponseWriter) error {
|
||||
data, err := json.Marshal(proto)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "marshal grpc details to json")
|
||||
}
|
||||
return p.writeResponse(statusCode, data, w)
|
||||
}
|
||||
|
||||
func (p Grpc) writeResponse(statusCode int, data []byte, w http.ResponseWriter) error {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(statusCode)
|
||||
_, err := w.Write(data)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "response write")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p Grpc) codeToHttpStatus(code codes.Code) int {
|
||||
s, ok := inverseCodeMap[code]
|
||||
if !ok {
|
||||
return http.StatusInternalServerError
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/requestid"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// nolint:gomnd
|
||||
var (
|
||||
httpTransport = &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
DialContext: defaultTransportDialContext(&net.Dialer{
|
||||
Timeout: 3 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}),
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 512,
|
||||
MaxIdleConnsPerHost: 32,
|
||||
IdleConnTimeout: 60 * time.Second,
|
||||
TLSHandshakeTimeout: 5 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
)
|
||||
|
||||
type HttpHostManager interface {
|
||||
Next() (string, error)
|
||||
}
|
||||
|
||||
type Http struct {
|
||||
hostManager HttpHostManager
|
||||
skipAuth bool
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func NewHttp(hostManager HttpHostManager, skipAuth bool, timeout time.Duration) Http {
|
||||
return Http{
|
||||
hostManager: hostManager,
|
||||
skipAuth: skipAuth,
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
func (p Http) Handle(ctx *request.Context) error {
|
||||
host, err := p.hostManager.Next()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "http: next host")
|
||||
}
|
||||
|
||||
rawUrl := fmt.Sprintf("http://%s", host) // secure HTTP links are reset connection
|
||||
target, err := url.Parse(rawUrl)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "http: parse url")
|
||||
}
|
||||
|
||||
request := ctx.Request()
|
||||
request.URL.Path = ctx.Endpoint()
|
||||
err = setHttpHeaders(ctx, request.Header, p.skipAuth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
reverseProxy := httputil.NewSingleHostReverseProxy(target)
|
||||
reverseProxy.Transport = httpTransport
|
||||
var resultError error
|
||||
reverseProxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, err error) {
|
||||
resultError = httperrors.New(
|
||||
http.StatusServiceUnavailable,
|
||||
"upstream is not available",
|
||||
errors.WithMessagef(err, "http proxy to %s", host),
|
||||
)
|
||||
}
|
||||
|
||||
context, cancel := context.WithTimeout(request.Context(), p.timeout)
|
||||
defer cancel()
|
||||
request = request.WithContext(context)
|
||||
reverseProxy.ServeHTTP(ctx.ResponseWriter(), request)
|
||||
|
||||
return resultError
|
||||
}
|
||||
|
||||
func setHttpHeaders(ctx *request.Context, header http.Header, skipAuth bool) error {
|
||||
header.Set(requestid.RequestIdHeader, requestid.FromContext(ctx.Context()))
|
||||
if !skipAuth {
|
||||
authData, err := ctx.GetAuthData()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "http: get auth data")
|
||||
}
|
||||
header.Set(grpc.SystemIdHeader, strconv.Itoa(authData.SystemId))
|
||||
header.Set(grpc.DomainIdHeader, strconv.Itoa(authData.DomainId))
|
||||
header.Set(grpc.ServiceIdHeader, strconv.Itoa(authData.ServiceId))
|
||||
header.Set(grpc.ApplicationIdHeader, strconv.Itoa(authData.ApplicationId))
|
||||
if ctx.IsAdminAuthenticated() {
|
||||
header.Set(xAdminIdHeader, strconv.Itoa(ctx.AdminId())) //nolint:canonicalheader
|
||||
} else {
|
||||
header.Del(xAdminIdHeader) //nolint:canonicalheader
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultTransportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
|
||||
return dialer.DialContext
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/valyala/fasthttp"
|
||||
"google.golang.org/grpc/codes"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/log_code"
|
||||
"isp-gate-service/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
errNotInitialized = errors.New("http proxy not initialized")
|
||||
)
|
||||
|
||||
type HttpProxy struct {
|
||||
client *fasthttp.HostClient
|
||||
skipAuth bool
|
||||
skipExistCheck bool
|
||||
}
|
||||
|
||||
func NewProxy(skipAuth, skipExistCheck bool) *HttpProxy {
|
||||
return &HttpProxy{client: nil, skipAuth: skipAuth, skipExistCheck: skipExistCheck}
|
||||
}
|
||||
|
||||
func (p *HttpProxy) Consumer(addressList []structure.AddressConfiguration) bool {
|
||||
if len(addressList) == 0 {
|
||||
p.client = nil
|
||||
return true
|
||||
}
|
||||
addresses := make([]string, len(addressList))
|
||||
for key, addr := range addressList {
|
||||
addresses[key] = addr.GetAddress()
|
||||
}
|
||||
|
||||
p.client = &fasthttp.HostClient{
|
||||
Addr: strings.Join(addresses, `,`),
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *HttpProxy) ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse {
|
||||
client := p.client
|
||||
if client == nil {
|
||||
log.Error(log_code.ErrorClientHttp, errNotInitialized)
|
||||
utils.WriteError(ctx, errNotInitialized.Error(), codes.Internal, nil)
|
||||
return domain.Create().
|
||||
SetRequestBody(ctx.Request.Body()).
|
||||
SetResponseBody(ctx.Response.Body()).
|
||||
SetError(errNotInitialized)
|
||||
}
|
||||
|
||||
req := &ctx.Request
|
||||
res := &ctx.Response
|
||||
req.URI().SetPath("/" + path)
|
||||
|
||||
if addr, _, err := net.SplitHostPort(ctx.RemoteAddr().String()); err == nil {
|
||||
req.Header.Add("X-Forwarded-For", addr)
|
||||
}
|
||||
|
||||
err := client.Do(req, res)
|
||||
if err != nil {
|
||||
log.Error(log_code.ErrorClientHttp, err)
|
||||
}
|
||||
return domain.Create().
|
||||
SetRequestBody(ctx.Request.Body()).
|
||||
SetResponseBody(ctx.Response.Body()).
|
||||
SetError(err)
|
||||
}
|
||||
|
||||
func (p *HttpProxy) SkipAuth() bool {
|
||||
return p.skipAuth
|
||||
}
|
||||
|
||||
func (p *HttpProxy) SkipExistCheck() bool {
|
||||
return p.skipExistCheck
|
||||
}
|
||||
|
||||
func (p *HttpProxy) Close() {
|
||||
p.client = nil
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
"github.com/valyala/fasthttp"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/proxy/http"
|
||||
)
|
||||
|
||||
var (
|
||||
RoutingProxy *http.HttpProxy
|
||||
ApiPathPrefix string
|
||||
)
|
||||
|
||||
type (
|
||||
Proxy interface {
|
||||
ProxyRequest(ctx *fasthttp.RequestCtx, path string) domain.ProxyResponse
|
||||
Consumer([]structure.AddressConfiguration) bool
|
||||
SkipAuth() bool
|
||||
SkipExistCheck() bool
|
||||
Close()
|
||||
}
|
||||
)
|
||||
|
||||
func InitRoutingProxy(skipAuth bool, skipExistCheck bool) func(list []structure.AddressConfiguration) bool {
|
||||
RoutingProxy = http.NewProxy(skipAuth, skipExistCheck)
|
||||
return func(list []structure.AddressConfiguration) bool {
|
||||
RoutingProxy.Consumer(list)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func GetPathWithoutApiPrefix(initialPath string) string {
|
||||
s := strings.TrimPrefix(initialPath, ApiPathPrefix)
|
||||
if len(s) > 0 && s[0] == '/' {
|
||||
return s[1:]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func Close() {
|
||||
RoutingProxy.Close()
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tomakado/websocketproxy"
|
||||
"isp-gate-service/httperrors"
|
||||
"isp-gate-service/request"
|
||||
)
|
||||
|
||||
type Ws struct {
|
||||
hostManager HttpHostManager
|
||||
skipAuth bool
|
||||
}
|
||||
|
||||
func NewWs(hostManager HttpHostManager, skipAuth bool) Ws {
|
||||
return Ws{
|
||||
hostManager: hostManager,
|
||||
skipAuth: skipAuth,
|
||||
}
|
||||
}
|
||||
|
||||
//nolint:gomnd
|
||||
func (ws Ws) Handle(ctx *request.Context) error {
|
||||
host, err := ws.hostManager.Next()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "ws: next host")
|
||||
}
|
||||
|
||||
rawUrl := fmt.Sprintf("ws://%s", host)
|
||||
target, err := url.Parse(rawUrl)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "ws: parse url")
|
||||
}
|
||||
|
||||
request := ctx.Request()
|
||||
request.URL.Path = ctx.Endpoint()
|
||||
|
||||
var resultError error
|
||||
proxy := websocketproxy.NewProxy(target)
|
||||
proxy.Director = func(incoming *http.Request, out http.Header) {
|
||||
_ = setHttpHeaders(ctx, out, ws.skipAuth)
|
||||
}
|
||||
proxy.Upgrader = &websocket.Upgrader{
|
||||
HandshakeTimeout: 5 * time.Second,
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
WriteBufferPool: nil,
|
||||
Subprotocols: nil,
|
||||
Error: func(w http.ResponseWriter, r *http.Request, status int, reason error) {
|
||||
resultError = httperrors.New(
|
||||
http.StatusServiceUnavailable,
|
||||
"upstream is not available",
|
||||
errors.WithMessagef(reason, "ws proxy to %s", host),
|
||||
)
|
||||
},
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
return true
|
||||
},
|
||||
EnableCompression: false,
|
||||
}
|
||||
|
||||
proxy.ServeHTTP(ctx.ResponseWriter(), ctx.Request())
|
||||
|
||||
return resultError
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
rd "github.com/integration-system/isp-lib/v2/redis"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"isp-gate-service/log_code"
|
||||
)
|
||||
|
||||
var (
|
||||
Client = rd.NewRxClient(
|
||||
rd.WithInitHandler(func(c *rd.Client, err error) {
|
||||
if err != nil {
|
||||
log.Fatal(log_code.ErrorClientRedis, err)
|
||||
}
|
||||
}))
|
||||
)
|
||||
@@ -1,48 +0,0 @@
|
||||
// nolint:dupl
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
)
|
||||
|
||||
const (
|
||||
adminAuthenticate = "admin/secure/authenticate"
|
||||
adminAuthorize = "admin/secure/authorize"
|
||||
)
|
||||
|
||||
type Admin struct {
|
||||
cli *client.Client
|
||||
}
|
||||
|
||||
func NewAdmin(cli *client.Client) Admin {
|
||||
return Admin{cli: cli}
|
||||
}
|
||||
|
||||
func (r Admin) Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
||||
resp := domain.AdminAuthenticateResponse{}
|
||||
err := r.cli.Invoke(adminAuthenticate).
|
||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "grpc client invoke %s", adminAuthenticate)
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (r Admin) Authorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
||||
resp := domain.AdminAuthorizeResponse{}
|
||||
err := r.cli.Invoke(adminAuthorize).
|
||||
JsonRequestBody(domain.AdminAuthorizeRequest{AdminId: adminId, Permission: permission}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "grpc client invoke: %s", adminAuthorize)
|
||||
}
|
||||
return resp.Authorized, nil
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
"isp-gate-service/cache"
|
||||
"isp-gate-service/domain"
|
||||
)
|
||||
|
||||
type AuthenticationCache struct {
|
||||
cache *cache.Cache
|
||||
duration time.Duration
|
||||
}
|
||||
|
||||
func NewAuthenticationCache(duration time.Duration) AuthenticationCache {
|
||||
return AuthenticationCache{
|
||||
duration: duration,
|
||||
cache: cache.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (r AuthenticationCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
||||
data, ok := r.cache.Get(token)
|
||||
if !ok {
|
||||
return nil, domain.ErrAuthenticationCacheMiss
|
||||
}
|
||||
|
||||
result := domain.AuthData{}
|
||||
err := json.Unmarshal(data, &result)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r AuthenticationCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
||||
value, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "json marshal auth data")
|
||||
}
|
||||
|
||||
r.cache.Set(token, value, r.duration)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/cache"
|
||||
)
|
||||
|
||||
type AuthorizationCache struct {
|
||||
duration time.Duration
|
||||
cache *cache.Cache
|
||||
}
|
||||
|
||||
func NewAuthorizationCache(duration time.Duration) *AuthorizationCache {
|
||||
return &AuthorizationCache{
|
||||
duration: duration,
|
||||
cache: cache.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func (r AuthorizationCache) Get(ctx context.Context, id int, endpoint string) (bool, error) {
|
||||
key := r.key(id, endpoint)
|
||||
_, ok := r.cache.Get(key)
|
||||
return ok, nil
|
||||
}
|
||||
|
||||
func (r AuthorizationCache) SetAuthorized(ctx context.Context, id int, endpoint string) error {
|
||||
key := r.key(id, endpoint)
|
||||
r.cache.Set(key, nil, r.duration)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r AuthorizationCache) key(id int, endpoint string) string {
|
||||
return fmt.Sprintf("%d:%s", id, endpoint)
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
type DailyLimit struct {
|
||||
cli redis.UniversalClient
|
||||
}
|
||||
|
||||
func NewDailyLimit(cli redis.UniversalClient) DailyLimit {
|
||||
return DailyLimit{
|
||||
cli: cli,
|
||||
}
|
||||
}
|
||||
|
||||
func (r DailyLimit) Increment(ctx context.Context, applicationId int, today time.Time) (int64, error) {
|
||||
key := r.key(applicationId, today)
|
||||
value, err := r.cli.Incr(ctx, key).Result()
|
||||
if err != nil {
|
||||
return 0, errors.WithMessage(err, "incr")
|
||||
}
|
||||
|
||||
if value == 1 {
|
||||
err := r.cli.ExpireNX(ctx, key, 24*time.Hour).Err() //nolint:mnd,gomnd
|
||||
if err != nil {
|
||||
return 0, errors.WithMessage(err, "expire nx")
|
||||
}
|
||||
}
|
||||
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (r DailyLimit) key(applicationId int, today time.Time) string {
|
||||
y, m, d := today.Date()
|
||||
return fmt.Sprintf("daily_limit:%d:%d-%d-%d", applicationId, y, m, d)
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// nolint:dupl
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"isp-gate-service/domain"
|
||||
)
|
||||
|
||||
const (
|
||||
authenticate = "system/secure/authenticate"
|
||||
authorize = "system/secure/authorize"
|
||||
)
|
||||
|
||||
type System struct {
|
||||
cli *client.Client
|
||||
}
|
||||
|
||||
func NewSystem(cli *client.Client) System {
|
||||
return System{
|
||||
cli: cli,
|
||||
}
|
||||
}
|
||||
|
||||
func (r System) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
||||
resp := domain.AuthenticateResponse{}
|
||||
err := r.cli.Invoke(authenticate).
|
||||
JsonRequestBody(domain.AuthenticateRequest{Token: token}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessagef(err, "grpc client invoke: %s", authenticate)
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (r System) Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
||||
resp := domain.AuthorizeResponse{}
|
||||
err := r.cli.Invoke(authorize).
|
||||
JsonRequestBody(domain.AuthorizeRequest{ApplicationId: applicationId, Endpoint: endpoint}).
|
||||
JsonResponseBody(&resp).
|
||||
Do(ctx)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "grpc client invoke: %s", authorize)
|
||||
}
|
||||
return resp.Authorized, nil
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-redis/redis_rate/v10"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"isp-gate-service/domain"
|
||||
)
|
||||
|
||||
type Throttling struct {
|
||||
cli *redis_rate.Limiter
|
||||
}
|
||||
|
||||
func NewThrottling(cli redis.UniversalClient) Throttling {
|
||||
return Throttling{
|
||||
cli: redis_rate.NewLimiter(cli),
|
||||
}
|
||||
}
|
||||
|
||||
func (r Throttling) IsAllowRequestPerSecond(ctx context.Context, applicationId int, rate int) (*domain.RateLimitResult, error) {
|
||||
result, err := r.cli.Allow(ctx, r.key(applicationId), redis_rate.PerSecond(rate))
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "redis_rate/Allow")
|
||||
}
|
||||
return &domain.RateLimitResult{
|
||||
Allow: result.Allowed > 0,
|
||||
Remaining: result.Remaining,
|
||||
RetryAfter: result.RetryAfter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r Throttling) key(applicationId int) string {
|
||||
return fmt.Sprintf("throttling:%d", applicationId)
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package unused
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
)
|
||||
|
||||
type RedisAuthCache struct {
|
||||
cli redis.UniversalClient
|
||||
duration time.Duration
|
||||
db int
|
||||
}
|
||||
|
||||
func NewRedisAuthCache(cli redis.UniversalClient, duration time.Duration, db int) RedisAuthCache {
|
||||
return RedisAuthCache{
|
||||
cli: cli,
|
||||
duration: duration,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData, error) {
|
||||
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
||||
p.Select(ctx, r.db)
|
||||
p.Get(ctx, token)
|
||||
return nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, redis.Nil) {
|
||||
return nil, errors.WithMessage(err, "pipelined")
|
||||
}
|
||||
|
||||
data, err := results[1].(*redis.StringCmd).Result()
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return nil, domain.ErrAuthenticationCacheMiss
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get")
|
||||
}
|
||||
|
||||
result := domain.AuthData{}
|
||||
err = json.Unmarshal([]byte(data), &result)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "json unmarshal auth data")
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
func (r RedisAuthCache) Set(ctx context.Context, token string, data domain.AuthData) error {
|
||||
value, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "json marshal auth data")
|
||||
}
|
||||
|
||||
results, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
||||
p.Select(ctx, r.db)
|
||||
p.SetEx(ctx, token, string(value), r.duration)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "pipelined")
|
||||
}
|
||||
|
||||
err = results[1].Err()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "set ex")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package unused
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
type RedisAuthzCache struct {
|
||||
cli redis.UniversalClient
|
||||
duration time.Duration
|
||||
db int
|
||||
}
|
||||
|
||||
func NewRedisAuthzCache(cli redis.UniversalClient, duration time.Duration, db int) *RedisAuthzCache {
|
||||
return &RedisAuthzCache{
|
||||
cli: cli,
|
||||
duration: duration,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (r RedisAuthzCache) Get(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
||||
result, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
||||
p.Select(ctx, r.db)
|
||||
p.Get(ctx, r.key(applicationId, endpoint))
|
||||
return nil
|
||||
})
|
||||
if err != nil && !errors.Is(err, redis.Nil) {
|
||||
return false, errors.WithMessage(err, "pipelined")
|
||||
}
|
||||
|
||||
_, err = result[1].(*redis.StringCmd).Result()
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, errors.WithMessage(err, "get")
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (r RedisAuthzCache) SetAuthorized(ctx context.Context, applicationId int, endpoint string) error {
|
||||
result, err := r.cli.Pipelined(ctx, func(p redis.Pipeliner) error {
|
||||
p.Select(ctx, r.db)
|
||||
p.SetEx(ctx, r.key(applicationId, endpoint), "authorized", r.duration)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "pipelined")
|
||||
}
|
||||
|
||||
err = result[1].Err()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "set ex")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r RedisAuthzCache) key(applicationId int, endpoint string) string {
|
||||
return fmt.Sprintf("%d:%s", applicationId, endpoint)
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotAuthenticated = errors.New("not authenticated")
|
||||
)
|
||||
|
||||
type AuthData struct {
|
||||
SystemId int
|
||||
DomainId int
|
||||
ServiceId int
|
||||
ApplicationId int
|
||||
}
|
||||
|
||||
type Context struct {
|
||||
request *http.Request
|
||||
responseWriter http.ResponseWriter
|
||||
|
||||
endpoint string
|
||||
|
||||
authenticated bool
|
||||
authData *AuthData
|
||||
|
||||
adminAuthenticated bool
|
||||
adminId int
|
||||
adminToken string
|
||||
|
||||
queryParams map[string]string
|
||||
}
|
||||
|
||||
func NewContext(request *http.Request, response http.ResponseWriter, endpoint string) *Context {
|
||||
return &Context{
|
||||
request: request,
|
||||
responseWriter: response,
|
||||
endpoint: endpoint,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) Request() *http.Request {
|
||||
return c.request
|
||||
}
|
||||
|
||||
func (c *Context) ResponseWriter() http.ResponseWriter {
|
||||
return c.responseWriter
|
||||
}
|
||||
|
||||
func (c *Context) SetResponseWriter(writer http.ResponseWriter) {
|
||||
c.responseWriter = writer
|
||||
}
|
||||
|
||||
func (c *Context) Endpoint() string {
|
||||
return c.endpoint
|
||||
}
|
||||
|
||||
func (c *Context) Authenticate(authData AuthData) {
|
||||
c.authenticated = true
|
||||
c.authData = &authData
|
||||
}
|
||||
|
||||
func (c *Context) GetAuthData() (AuthData, error) {
|
||||
if !c.authenticated {
|
||||
return AuthData{}, ErrNotAuthenticated
|
||||
}
|
||||
return *c.authData, nil
|
||||
}
|
||||
|
||||
func (c *Context) IsAdminAuthenticated() bool {
|
||||
return c.adminAuthenticated
|
||||
}
|
||||
|
||||
func (c *Context) AdminId() int {
|
||||
return c.adminId
|
||||
}
|
||||
|
||||
func (c *Context) AdminToken() string {
|
||||
return c.adminToken
|
||||
}
|
||||
|
||||
func (c *Context) AuthenticateAdmin(adminId int, adminToken string) {
|
||||
c.adminAuthenticated = true
|
||||
c.adminId = adminId
|
||||
c.adminToken = adminToken
|
||||
}
|
||||
|
||||
func (c *Context) Context() context.Context {
|
||||
return c.request.Context()
|
||||
}
|
||||
|
||||
func (c *Context) SetContext(ctx context.Context) {
|
||||
c.request = c.request.WithContext(ctx)
|
||||
}
|
||||
|
||||
func (c *Context) Param(name string) string {
|
||||
value := c.request.Header.Get(name)
|
||||
if value != "" {
|
||||
return strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
if c.queryParams == nil {
|
||||
query := c.request.URL.Query()
|
||||
c.queryParams = map[string]string{}
|
||||
for key, values := range query {
|
||||
if len(values) == 0 {
|
||||
continue
|
||||
}
|
||||
c.queryParams[strings.ToLower(key)] = values[0]
|
||||
}
|
||||
}
|
||||
value = c.queryParams[strings.ToLower(name)]
|
||||
|
||||
return strings.TrimSpace(value)
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
)
|
||||
|
||||
type Routes struct {
|
||||
innerEndpoints map[string]bool
|
||||
requiredPermissions map[string]string
|
||||
}
|
||||
|
||||
func NewRoutes() *Routes {
|
||||
return &Routes{
|
||||
innerEndpoints: make(map[string]bool),
|
||||
requiredPermissions: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig) error {
|
||||
newInnerMethods := make(map[string]bool)
|
||||
newRequiredPermissions := make(map[string]string)
|
||||
for _, backend := range routes {
|
||||
for _, v := range backend.Endpoints {
|
||||
if v.Inner {
|
||||
newInnerMethods[v.Path] = true
|
||||
}
|
||||
perm, ok := cluster.GetRequiredAdminPermission(v)
|
||||
if ok {
|
||||
newRequiredPermissions[v.Path] = perm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.innerEndpoints = newInnerMethods
|
||||
s.requiredPermissions = newRequiredPermissions
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Routes) IsInnerEndpoint(path string) bool {
|
||||
return s.innerEndpoints[path]
|
||||
}
|
||||
|
||||
func (s *Routes) RequiredAdminPermission(path string) (string, bool) {
|
||||
perm, ok := s.requiredPermissions[path]
|
||||
return perm, ok
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/v2/structure"
|
||||
)
|
||||
|
||||
var (
|
||||
InnerMethods = make(map[string]bool)
|
||||
AllMethods = make(map[string]bool)
|
||||
AuthUserMethods = make(map[string]bool)
|
||||
)
|
||||
|
||||
func InitRoutes(configs structure.RoutingConfig) {
|
||||
newAddressMap := make(map[string]bool)
|
||||
newInnerAddressMap := make(map[string]bool)
|
||||
newAuthUserAddressMap := make(map[string]bool)
|
||||
for i := range configs {
|
||||
backend := &configs[i]
|
||||
if backend.Address.IP == "" {
|
||||
continue
|
||||
}
|
||||
if len(backend.HandlersInfo) == 0 {
|
||||
if len(backend.Endpoints) == 0 || backend.Address.Port == "" {
|
||||
continue
|
||||
}
|
||||
addEndpointsToMaps(backend.Endpoints, "", newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||
} else {
|
||||
for _, info := range backend.HandlersInfo {
|
||||
if info.Port != "" {
|
||||
addEndpointsToMaps(info.Endpoints, info.PathPrefix, newAddressMap, newInnerAddressMap, newAuthUserAddressMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
AllMethods = newAddressMap
|
||||
InnerMethods = newInnerAddressMap
|
||||
AuthUserMethods = newAuthUserAddressMap
|
||||
}
|
||||
|
||||
func addEndpointsToMaps(endpoints []structure.EndpointDescriptor,
|
||||
pathPrefix string, newAddressMap map[string]bool,
|
||||
newInnerAddressMap map[string]bool,
|
||||
newAuthUserAddressMap map[string]bool) {
|
||||
for _, el := range endpoints {
|
||||
if pathPrefix != "" {
|
||||
el.Path = pathPrefix + "/" + el.Path
|
||||
}
|
||||
newAddressMap[el.Path] = true
|
||||
if el.Inner {
|
||||
newInnerAddressMap[el.Path] = true
|
||||
}
|
||||
if el.UserAuthRequired {
|
||||
newAuthUserAddressMap[el.Path] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/integration-system/go-cmp/cmp"
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"github.com/valyala/fasthttp"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/handler"
|
||||
"isp-gate-service/log_code"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const defaultTimeout = 60 * time.Second
|
||||
|
||||
var Http = &httpSrv{mx: sync.Mutex{}}
|
||||
|
||||
type httpSrv struct {
|
||||
working bool
|
||||
srv *fasthttp.Server
|
||||
mx sync.Mutex
|
||||
}
|
||||
|
||||
func (s *httpSrv) Init(new, old conf.HttpSetting) {
|
||||
if s.working {
|
||||
if !cmp.Equal(new, old) {
|
||||
s.run(new.GetMaxRequestBodySize())
|
||||
}
|
||||
} else {
|
||||
s.run(new.GetMaxRequestBodySize())
|
||||
}
|
||||
}
|
||||
|
||||
func (s *httpSrv) run(maxRequestBodySize int64) {
|
||||
s.mx.Lock()
|
||||
s.working = true
|
||||
if s.srv != nil {
|
||||
if err := s.srv.Shutdown(); err != nil {
|
||||
log.Warn(log_code.WarnHttpServerShutdown, err)
|
||||
}
|
||||
}
|
||||
localConfig := config.Get().(*conf.Configuration)
|
||||
restAddress := localConfig.HttpInnerAddress.GetAddress()
|
||||
s.srv = &fasthttp.Server{
|
||||
Handler: handler.CompleteRequest,
|
||||
WriteTimeout: defaultTimeout,
|
||||
ReadTimeout: defaultTimeout,
|
||||
MaxRequestBodySize: int(maxRequestBodySize),
|
||||
}
|
||||
go func() {
|
||||
if err := s.srv.ListenAndServe(restAddress); err != nil {
|
||||
log.Error(log_code.ErrorHttpServerListen, err)
|
||||
}
|
||||
}()
|
||||
s.mx.Unlock()
|
||||
}
|
||||
|
||||
func (s *httpSrv) Close() {
|
||||
if s.srv != nil {
|
||||
s.working = false
|
||||
if err := s.srv.Shutdown(); err != nil {
|
||||
log.Warn(log_code.WarnHttpServerShutdown, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"isp-gate-service/domain"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type AdminAuth interface {
|
||||
Authenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error)
|
||||
Authorize(ctx context.Context, adminId int, permission string) (bool, error)
|
||||
}
|
||||
|
||||
type Admin struct {
|
||||
cache AuthorizationCache
|
||||
repo AdminAuth
|
||||
}
|
||||
|
||||
func NewAdmin(cache AuthorizationCache, adminAuth AdminAuth) Admin {
|
||||
return Admin{
|
||||
cache: cache,
|
||||
repo: adminAuth,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Admin) AdminAuthenticate(ctx context.Context, token string) (*domain.AdminAuthenticateResponse, error) {
|
||||
resp, err := s.repo.Authenticate(ctx, token)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "get admin token data from admin service")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s Admin) AdminAuthorize(ctx context.Context, adminId int, permission string) (bool, error) {
|
||||
ok, err := s.cache.Get(ctx, adminId, permission)
|
||||
if err != nil {
|
||||
return false, errors.WithMessage(err, "authz cache get")
|
||||
}
|
||||
if ok {
|
||||
return ok, nil
|
||||
}
|
||||
|
||||
ok, err = s.repo.Authorize(ctx, adminId, permission)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "authz repo authorize")
|
||||
}
|
||||
if ok {
|
||||
err = s.cache.SetAuthorized(ctx, adminId, permission)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "authz cache set")
|
||||
}
|
||||
}
|
||||
|
||||
return ok, nil
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/domain"
|
||||
)
|
||||
|
||||
type AuthenticationCache interface {
|
||||
Get(ctx context.Context, token string) (*domain.AuthData, error)
|
||||
Set(ctx context.Context, token string, data domain.AuthData) error
|
||||
}
|
||||
|
||||
type AuthenticationRepo interface {
|
||||
Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error)
|
||||
}
|
||||
|
||||
type Auth struct {
|
||||
cache AuthenticationCache
|
||||
repo AuthenticationRepo
|
||||
}
|
||||
|
||||
func NewAuthentication(cache AuthenticationCache, repo AuthenticationRepo) Auth {
|
||||
return Auth{
|
||||
cache: cache,
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Auth) Authenticate(ctx context.Context, token string) (*domain.AuthenticateResponse, error) {
|
||||
authData, err := s.cache.Get(ctx, token)
|
||||
if errors.Is(err, domain.ErrAuthenticationCacheMiss) {
|
||||
resp, err := s.repo.Authenticate(ctx, token)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth repo authenticate")
|
||||
}
|
||||
if !resp.Authenticated {
|
||||
return resp, nil
|
||||
}
|
||||
err = s.cache.Set(ctx, token, *resp.AuthData)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth cache set")
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "auth cache get")
|
||||
}
|
||||
return &domain.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: authData,
|
||||
}, nil
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type AuthorizationCache interface {
|
||||
Get(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
||||
SetAuthorized(ctx context.Context, applicationId int, endpoint string) error
|
||||
}
|
||||
|
||||
type AuthorizationRepo interface {
|
||||
Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error)
|
||||
}
|
||||
|
||||
type Authorization struct {
|
||||
cache AuthorizationCache
|
||||
repo AuthorizationRepo
|
||||
}
|
||||
|
||||
func NewAuthorization(cache AuthorizationCache, repo AuthorizationRepo) Authorization {
|
||||
return Authorization{
|
||||
cache: cache,
|
||||
repo: repo,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Authorization) Authorize(ctx context.Context, applicationId int, endpoint string) (bool, error) {
|
||||
ok, err := s.cache.Get(ctx, applicationId, endpoint)
|
||||
if err != nil {
|
||||
return false, errors.WithMessage(err, "authz cache get")
|
||||
}
|
||||
if ok {
|
||||
return ok, nil
|
||||
}
|
||||
|
||||
ok, err = s.repo.Authorize(ctx, applicationId, endpoint)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "authz repo authorize")
|
||||
}
|
||||
if ok {
|
||||
err = s.cache.SetAuthorized(ctx, applicationId, endpoint)
|
||||
if err != nil {
|
||||
return false, errors.WithMessagef(err, "authz cache set")
|
||||
}
|
||||
}
|
||||
|
||||
return ok, nil
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/conf"
|
||||
)
|
||||
|
||||
type DailyLimitRepo interface {
|
||||
Increment(ctx context.Context, applicationId int, today time.Time) (int64, error)
|
||||
}
|
||||
|
||||
type DailyLimit struct {
|
||||
repo DailyLimitRepo
|
||||
limits map[int]int64
|
||||
}
|
||||
|
||||
func NewDailyLimit(repo DailyLimitRepo, configs []conf.DailyLimit) DailyLimit {
|
||||
limits := make(map[int]int64)
|
||||
for _, config := range configs {
|
||||
limits[config.ApplicationId] = config.RequestsPerDay
|
||||
}
|
||||
return DailyLimit{
|
||||
repo: repo,
|
||||
limits: limits,
|
||||
}
|
||||
}
|
||||
|
||||
func (s DailyLimit) IncrementAndCheck(ctx context.Context, applicationId int) (bool, error) {
|
||||
limit, ok := s.limits[applicationId]
|
||||
if !ok {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
newValue, err := s.repo.Increment(ctx, applicationId, time.Now())
|
||||
if err != nil {
|
||||
return false, errors.WithMessage(err, "increment")
|
||||
}
|
||||
|
||||
return newValue <= limit, nil
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package matcher
|
||||
|
||||
import "sync"
|
||||
|
||||
type atLeastOneMatcher struct {
|
||||
cache map[string]bool
|
||||
lock sync.RWMutex
|
||||
rm runtimeMatcher
|
||||
}
|
||||
|
||||
func (mm *atLeastOneMatcher) Match(method string) bool {
|
||||
if len(mm.rm.patterns) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
mm.lock.RLock()
|
||||
matched, ok := mm.cache[method]
|
||||
mm.lock.RUnlock()
|
||||
if ok {
|
||||
return matched
|
||||
}
|
||||
|
||||
mm.lock.Lock()
|
||||
defer mm.lock.Unlock()
|
||||
if matched, ok = mm.cache[method]; ok {
|
||||
return matched
|
||||
} else {
|
||||
arrayPattern := mm.rm.Match(method)
|
||||
matched = len(arrayPattern) > 0
|
||||
}
|
||||
mm.cache[method] = matched
|
||||
return matched
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package matcher
|
||||
|
||||
import "sync"
|
||||
|
||||
type cacheableMatcher struct {
|
||||
cache map[string][]string
|
||||
lock sync.RWMutex
|
||||
rm runtimeMatcher
|
||||
}
|
||||
|
||||
func (mm *cacheableMatcher) Match(method string) []string {
|
||||
if len(mm.rm.patterns) == 0 {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
mm.lock.RLock()
|
||||
arrayPattern, ok := mm.cache[method]
|
||||
mm.lock.RUnlock()
|
||||
if ok {
|
||||
return arrayPattern
|
||||
}
|
||||
|
||||
mm.lock.Lock()
|
||||
defer mm.lock.Unlock()
|
||||
if arrayPattern, ok = mm.cache[method]; ok {
|
||||
return arrayPattern
|
||||
} else if arrayPattern = mm.rm.Match(method); len(arrayPattern) > 0 {
|
||||
mm.cache[method] = arrayPattern
|
||||
}
|
||||
|
||||
return arrayPattern
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package matcher
|
||||
|
||||
var JournalMethods AtLeastOneMatcher = &atLeastOneMatcher{}
|
||||
|
||||
type Matcher interface {
|
||||
Match(method string) []string
|
||||
}
|
||||
|
||||
type AtLeastOneMatcher interface {
|
||||
Match(method string) bool
|
||||
}
|
||||
|
||||
func NewRuntimeMatcher(patterns []string) Matcher {
|
||||
return &runtimeMatcher{
|
||||
patterns: patterns,
|
||||
}
|
||||
}
|
||||
|
||||
func NewCacheableMatcher(patterns []string) Matcher {
|
||||
return &cacheableMatcher{
|
||||
cache: make(map[string][]string),
|
||||
rm: runtimeMatcher{patterns: patterns},
|
||||
}
|
||||
}
|
||||
|
||||
func NewAtLeastOneMatcher(patterns []string) AtLeastOneMatcher {
|
||||
return &atLeastOneMatcher{
|
||||
cache: make(map[string]bool),
|
||||
rm: runtimeMatcher{patterns: patterns},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//nolint
|
||||
package matcher
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
patterns = []string{
|
||||
"mdm-master/group/method",
|
||||
"mdm-master/group/*",
|
||||
"mdm-master/group2/method",
|
||||
"mdm-master/group3/*",
|
||||
}
|
||||
cases = []struct {
|
||||
method string
|
||||
coincidence int
|
||||
atLeastOne bool
|
||||
}{
|
||||
{method: "mdm-master/group/method", coincidence: 2, atLeastOne: true},
|
||||
{method: "mdm-master/group/method2", coincidence: 1, atLeastOne: true},
|
||||
{method: "mdm-master/group2/", coincidence: 0, atLeastOne: false},
|
||||
{method: "mdm-master/group2/method3", coincidence: 0, atLeastOne: false},
|
||||
{method: "mdm-master/group2/method", coincidence: 1, atLeastOne: true},
|
||||
{method: "mdm-master/group3/some", coincidence: 1, atLeastOne: true},
|
||||
{method: "mdm-master/group3/", coincidence: 1, atLeastOne: true},
|
||||
}
|
||||
)
|
||||
|
||||
func TestCacheableMatcher_Match(t *testing.T) {
|
||||
matcher := NewCacheableMatcher(patterns)
|
||||
for _, c := range cases {
|
||||
res := matcher.Match(c.method)
|
||||
if c.coincidence != len(res) {
|
||||
t.Error(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAtLeastOneMatcher_Match(t *testing.T) {
|
||||
matcher := NewAtLeastOneMatcher(patterns)
|
||||
for _, c := range cases {
|
||||
res := matcher.Match(c.method)
|
||||
if c.atLeastOne != res {
|
||||
t.Error(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCacheableMatcher_Match(b *testing.B) {
|
||||
matcher := NewCacheableMatcher(patterns)
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, c := range cases {
|
||||
_ = matcher.Match(c.method)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRuntimeMatcher_Match(b *testing.B) {
|
||||
matcher := NewRuntimeMatcher(patterns)
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, c := range cases {
|
||||
_ = matcher.Match(c.method)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package matcher
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type runtimeMatcher struct {
|
||||
patterns []string
|
||||
}
|
||||
|
||||
func (mm runtimeMatcher) Match(method string) []string {
|
||||
resp := make([]string, 0)
|
||||
for _, pattern := range mm.patterns {
|
||||
patternLen := len(pattern)
|
||||
if patternLen > 0 && pattern[patternLen-1] == '*' {
|
||||
if strings.HasPrefix(method, pattern[:patternLen-1]) {
|
||||
resp = append(resp, pattern)
|
||||
}
|
||||
} else if strings.EqualFold(method, pattern) {
|
||||
resp = append(resp, pattern)
|
||||
}
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/v2/metric"
|
||||
"github.com/rcrowley/go-metrics"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultSampleSize = 2048
|
||||
)
|
||||
|
||||
var Metrics = &metricService{mh: nil}
|
||||
|
||||
type (
|
||||
metricService struct {
|
||||
mh *metricHolder
|
||||
}
|
||||
|
||||
metricHolder struct {
|
||||
methodHistograms map[string]metrics.Histogram
|
||||
methodLock sync.RWMutex
|
||||
statusCounters map[string]metrics.Counter
|
||||
statusLock sync.RWMutex
|
||||
}
|
||||
)
|
||||
|
||||
func (m *metricService) Init() {
|
||||
m.mh = &metricHolder{
|
||||
methodHistograms: make(map[string]metrics.Histogram),
|
||||
statusCounters: make(map[string]metrics.Counter),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metricService) UpdateMethodResponseTime(uri string, time time.Duration) {
|
||||
if m.notEmptyHolder() {
|
||||
m.getOrRegisterHistogram(uri).Update(int64(time))
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metricService) UpdateStatusCounter(status string) {
|
||||
if m.notEmptyHolder() {
|
||||
m.getOrRegisterCounter(status).Inc(1)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *metricService) getOrRegisterHistogram(uri string) metrics.Histogram {
|
||||
m.mh.methodLock.RLock()
|
||||
histogram, ok := m.mh.methodHistograms[uri]
|
||||
m.mh.methodLock.RUnlock()
|
||||
if ok {
|
||||
return histogram
|
||||
}
|
||||
|
||||
m.mh.methodLock.Lock()
|
||||
defer m.mh.methodLock.Unlock()
|
||||
if d, ok := m.mh.methodHistograms[uri]; ok {
|
||||
return d
|
||||
}
|
||||
histogram = metrics.GetOrRegisterHistogram(
|
||||
"http.response.time_"+uri,
|
||||
metric.GetRegistry(),
|
||||
metrics.NewUniformSample(defaultSampleSize),
|
||||
)
|
||||
m.mh.methodHistograms[uri] = histogram
|
||||
return histogram
|
||||
}
|
||||
|
||||
func (m *metricService) getOrRegisterCounter(status string) metrics.Counter {
|
||||
m.mh.statusLock.RLock()
|
||||
d, ok := m.mh.statusCounters[status]
|
||||
m.mh.statusLock.RUnlock()
|
||||
if ok {
|
||||
return d
|
||||
}
|
||||
|
||||
m.mh.statusLock.Lock()
|
||||
defer m.mh.statusLock.Unlock()
|
||||
if d, ok := m.mh.statusCounters[status]; ok {
|
||||
return d
|
||||
}
|
||||
d = metrics.GetOrRegisterCounter("http.response.count."+status, metric.GetRegistry())
|
||||
m.mh.statusCounters[status] = d
|
||||
return d
|
||||
}
|
||||
|
||||
func (m *metricService) notEmptyHolder() bool {
|
||||
return m.mh != nil
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
)
|
||||
|
||||
type ThrottlingRepo interface {
|
||||
IsAllowRequestPerSecond(ctx context.Context, applicationId int, rate int) (*domain.RateLimitResult, error)
|
||||
}
|
||||
|
||||
type Throttling struct {
|
||||
repo ThrottlingRepo
|
||||
limits map[int]int
|
||||
}
|
||||
|
||||
func NewThrottling(repo ThrottlingRepo, configs []conf.Throttling) Throttling {
|
||||
limits := make(map[int]int)
|
||||
for _, config := range configs {
|
||||
limits[config.ApplicationId] = config.RequestsPerSeconds
|
||||
}
|
||||
return Throttling{
|
||||
repo: repo,
|
||||
limits: limits,
|
||||
}
|
||||
}
|
||||
|
||||
func (s Throttling) AllowRateLimit(ctx context.Context, applicationId int) (*domain.RateLimitResult, error) {
|
||||
rate, ok := s.limits[applicationId]
|
||||
if !ok {
|
||||
return &domain.RateLimitResult{
|
||||
Allow: true,
|
||||
Remaining: -1,
|
||||
RetryAfter: -1,
|
||||
}, nil
|
||||
}
|
||||
|
||||
result, err := s.repo.IsAllowRequestPerSecond(ctx, applicationId, rate)
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "is allow request per second")
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package veritification
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
cacheablesVerify struct {
|
||||
cache map[string]cacheInfo
|
||||
timeout time.Duration
|
||||
rv *runtimeVerify
|
||||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
cacheInfo struct {
|
||||
created time.Time
|
||||
identity map[string]string
|
||||
}
|
||||
)
|
||||
|
||||
func (cv *cacheablesVerify) ApplicationToken(token string) (map[string]string, error) {
|
||||
cv.lock.RLock()
|
||||
cache, ok := cv.cache[token]
|
||||
cv.lock.RUnlock()
|
||||
if ok {
|
||||
if time.Since(cache.created) < cv.timeout {
|
||||
return cv.copyCache(cache.identity), nil
|
||||
}
|
||||
}
|
||||
|
||||
cv.lock.Lock()
|
||||
defer cv.lock.Unlock()
|
||||
cache, ok = cv.cache[token]
|
||||
if ok {
|
||||
if time.Since(cache.created) < cv.timeout {
|
||||
return cv.copyCache(cache.identity), nil
|
||||
}
|
||||
delete(cv.cache, token)
|
||||
}
|
||||
|
||||
identity, err := cv.rv.ApplicationToken(token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cv.cache[token] = cacheInfo{created: time.Now(), identity: identity}
|
||||
return cv.copyCache(identity), nil
|
||||
}
|
||||
|
||||
func (cv *cacheablesVerify) Identity(identity map[string]string, uri string) (map[string]string, error) {
|
||||
return cv.rv.Identity(identity, uri)
|
||||
}
|
||||
|
||||
func (cv *cacheablesVerify) copyCache(cache map[string]string) map[string]string {
|
||||
resp := make(map[string]string, 4)
|
||||
for key, value := range cache {
|
||||
resp[key] = value
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package veritification
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrorInvalidUserId = errors.New("received unexpected user identity")
|
||||
ErrorPermittedToCallApplication = errors.New("application has no rights to call this method")
|
||||
ErrorPermittedToCallUser = errors.New("user has no rights to call this method")
|
||||
)
|
||||
@@ -0,0 +1,162 @@
|
||||
package veritification
|
||||
|
||||
import (
|
||||
"context"
|
||||
rd "github.com/go-redis/redis/v8"
|
||||
"github.com/integration-system/isp-lib/v2/config"
|
||||
"github.com/integration-system/isp-lib/v2/redis"
|
||||
"github.com/integration-system/isp-lib/v2/utils"
|
||||
"github.com/pkg/errors"
|
||||
"isp-gate-service/conf"
|
||||
rdClient "isp-gate-service/redis"
|
||||
)
|
||||
|
||||
const (
|
||||
permittedToCallInfo = "0"
|
||||
)
|
||||
|
||||
var (
|
||||
errNoRedisCmd = errors.New("no redis cmd")
|
||||
errUnexpectedCmd = errors.New("expected StringCmd")
|
||||
headerKeyByRedisIdentity = map[string]string{
|
||||
"1": utils.SystemIdHeader,
|
||||
"2": utils.DomainIdHeader,
|
||||
"3": utils.ServiceIdHeader,
|
||||
"4": utils.ApplicationIdHeader,
|
||||
}
|
||||
)
|
||||
|
||||
type runtimeVerify struct{}
|
||||
|
||||
func (v *runtimeVerify) ApplicationToken(token string) (map[string]string, error) {
|
||||
instanceUuid := config.Get().(*conf.Configuration).InstanceUuid
|
||||
key := makeDbKey(token, instanceUuid)
|
||||
|
||||
resp, err := rdClient.Client.UseDb(redis.ApplicationTokenDb, func(p rd.Pipeliner) error {
|
||||
if cmd := p.HGetAll(context.Background(), key); v.isError(cmd.Err()) {
|
||||
return cmd.Err()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(resp) < 2 || resp[1].Err() == rd.Nil {
|
||||
return nil, nil
|
||||
} else if resp[1].Err() != nil {
|
||||
return nil, err
|
||||
} else if stringStringMapCmd, ok := resp[1].(*rd.StringStringMapCmd); !ok {
|
||||
return nil, errUnexpectedCmd
|
||||
} else {
|
||||
vals := stringStringMapCmd.Val()
|
||||
identityMap := make(map[string]string, len(vals))
|
||||
for i, value := range vals {
|
||||
identityMap[headerKeyByRedisIdentity[i]] = value
|
||||
}
|
||||
return identityMap, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (v *runtimeVerify) Identity(t map[string]string, uri string) (map[string]string, error) {
|
||||
secondDbKey := makeDbKey(t[utils.ApplicationIdHeader], uri)
|
||||
thirdDbKey := makeDbKey(t[utils.UserTokenHeader], t[utils.DomainIdHeader])
|
||||
fourthDbKey := makeDbKey(t[utils.UserIdHeader], uri)
|
||||
fifthDbKey := makeDbKey(t[utils.DeviceTokenHeader], t[utils.DomainIdHeader])
|
||||
|
||||
resp, err := rdClient.Client.Pipelined(context.Background(), func(p rd.Pipeliner) error {
|
||||
if _, err := p.Select(context.Background(), int(redis.ApplicationPermissionDb)).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
if _, err := p.Get(context.Background(), secondDbKey).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := p.Select(context.Background(), int(redis.UserTokenDb)).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
if _, err := p.Get(context.Background(), thirdDbKey).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := p.Select(context.Background(), int(redis.UserPermissionDb)).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
if _, err := p.Get(context.Background(), fourthDbKey).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := p.Select(context.Background(), int(redis.DeviceTokenDb)).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
if _, err := p.Get(context.Background(), fifthDbKey).Result(); v.isError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if v.isError(err) {
|
||||
return t, err
|
||||
}
|
||||
// ===== NOT PERMITTED BY APPLICATION ID =====
|
||||
msg, err := v.findStringCmd(resp, 1)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
if msg == permittedToCallInfo {
|
||||
return t, ErrorPermittedToCallApplication
|
||||
}
|
||||
// ===== CHECK USER TOKEN =====
|
||||
msg, err = v.findStringCmd(resp, 3)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
userIdentity, found := t[utils.UserIdHeader]
|
||||
if found && msg != userIdentity {
|
||||
return t, ErrorInvalidUserId
|
||||
}
|
||||
// ===== NOT PERMITTED BY USER ID =====
|
||||
msg, err = v.findStringCmd(resp, 5)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
if msg == permittedToCallInfo {
|
||||
return t, ErrorPermittedToCallUser
|
||||
}
|
||||
// ===== CHECK DEVICE TOKEN =====
|
||||
msg, err = v.findStringCmd(resp, 7)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t[utils.DeviceIdHeader] = msg
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func (v *runtimeVerify) isError(err error) bool {
|
||||
return err != nil && err != rd.Nil
|
||||
}
|
||||
|
||||
func (v *runtimeVerify) findStringCmd(cmders []rd.Cmder, arrayKey int) (string, error) {
|
||||
if len(cmders) <= arrayKey {
|
||||
return "", errNoRedisCmd
|
||||
}
|
||||
|
||||
cmd := cmders[arrayKey]
|
||||
if cmd == nil {
|
||||
return "", errNoRedisCmd
|
||||
}
|
||||
|
||||
if v.isError(cmd.Err()) {
|
||||
return "", cmd.Err()
|
||||
}
|
||||
|
||||
if stringCmd, ok := cmd.(*rd.StringCmd); !ok {
|
||||
return "", errUnexpectedCmd
|
||||
} else {
|
||||
return stringCmd.Val(), nil
|
||||
}
|
||||
}
|
||||
|
||||
func makeDbKey(key, val string) string {
|
||||
return key + "|" + val
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package veritification
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var Default = NewRuntimeVerify()
|
||||
|
||||
type Verify interface {
|
||||
ApplicationToken(string) (map[string]string, error)
|
||||
Identity(map[string]string, string) (map[string]string, error)
|
||||
}
|
||||
|
||||
func NewRuntimeVerify() Verify {
|
||||
return &runtimeVerify{}
|
||||
}
|
||||
|
||||
func NewCacheablesVerify(timeout time.Duration) Verify {
|
||||
return &cacheablesVerify{
|
||||
cache: make(map[string]cacheInfo),
|
||||
timeout: timeout,
|
||||
rv: &runtimeVerify{},
|
||||
}
|
||||
}
|
||||
@@ -1,365 +0,0 @@
|
||||
// nolint:canonicalheader
|
||||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"isp-gate-service/assembly"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/stretchr/testify/require"
|
||||
etp "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/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"
|
||||
)
|
||||
|
||||
type request struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
type response struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
type HappyPathTestSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) TestGrpcProxy() {
|
||||
test, require := test.New(s.T())
|
||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
||||
|
||||
requestId := requestid.Next()
|
||||
targetService, targetCli := grpct.NewMock(test)
|
||||
targetService.Mock("endpoint", func(ctx context.Context, authData grpc.AuthData, req request) response {
|
||||
systemId, err := authData.SystemId()
|
||||
require.NoError(err)
|
||||
domainId, err := authData.DomainId()
|
||||
require.NoError(err)
|
||||
serviceId, err := authData.ServiceId()
|
||||
require.NoError(err)
|
||||
applicationId, err := authData.ApplicationId()
|
||||
require.NoError(err)
|
||||
require.EqualValues(requestId, requestid.FromContext(ctx))
|
||||
require.EqualValues(1, systemId)
|
||||
require.EqualValues(2, domainId)
|
||||
require.EqualValues(3, serviceId)
|
||||
require.EqualValues(4, applicationId)
|
||||
|
||||
adminId, err := grpc.StringFromMd("x-admin-id", metadata.MD(authData))
|
||||
require.NoError(err)
|
||||
require.EqualValues("1", adminId)
|
||||
|
||||
return response{Id: req.Id} //nolint:gosimple
|
||||
})
|
||||
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)
|
||||
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations, redisCli)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-request-id", requestId).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) TestHttpProxy() {
|
||||
test, require := test.New(s.T())
|
||||
config, redisCli, 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
|
||||
})
|
||||
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)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "http",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations, redisCli)
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-request-id", requestId).
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
}
|
||||
|
||||
func (s *HappyPathTestSuite) TestWsProxy() { // nolint: funlen
|
||||
test, require := test.New(s.T())
|
||||
config, redisCli, systemCli, adminCli := s.commonDependencies(test)
|
||||
|
||||
requestId := requestid.Next()
|
||||
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)
|
||||
}))
|
||||
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)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/ws",
|
||||
Protocol: "ws",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations, redisCli)
|
||||
require.NoError(err)
|
||||
srv := httptest.NewServer(handler)
|
||||
|
||||
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"
|
||||
requestUrl.RawQuery = url.Values{
|
||||
"x-application-token": []string{"token"},
|
||||
"x-auth-admin": []string{"mock-token"},
|
||||
}.Encode()
|
||||
err = cli.Dial(context.Background(), requestUrl.String())
|
||||
require.NoError(err)
|
||||
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)
|
||||
|
||||
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
|
||||
})
|
||||
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)
|
||||
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, err := locator.Handler(config, locations, redisCli)
|
||||
require.NoError(err)
|
||||
|
||||
err = routes.ReceiveRoutes(context.Background(), cluster.RoutingConfig{{
|
||||
ModuleName: "target",
|
||||
Endpoints: []cluster.EndpointDescriptor{{
|
||||
Path: "endpoint",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("ok_permission"),
|
||||
}, {
|
||||
Path: "failed_endpoint",
|
||||
Inner: true,
|
||||
Extra: cluster.RequireAdminPermission("failed_permission"),
|
||||
}},
|
||||
}})
|
||||
require.NoError(err)
|
||||
|
||||
srv := httptest.NewServer(handler)
|
||||
cli := httpcli.New()
|
||||
req := request{Id: uuid.New().String()}
|
||||
resp := response{}
|
||||
_, err = cli.Post(srv.URL+"/api/endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
require.NoError(err)
|
||||
require.EqualValues(req.Id, resp.Id)
|
||||
|
||||
_, err = cli.Post(srv.URL+"/api/failed_endpoint").
|
||||
Header("x-application-token", "token").
|
||||
Header("x-auth-admin", "mock-token").
|
||||
JsonRequestBody(req).
|
||||
JsonResponseBody(&resp).
|
||||
StatusCodeToError().
|
||||
Do(context.Background())
|
||||
errResp := httpcli.ErrorResponse{}
|
||||
require.ErrorAs(err, &errResp)
|
||||
require.EqualValues(http.StatusForbidden, errResp.StatusCode)
|
||||
}
|
||||
|
||||
// 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)
|
||||
})
|
||||
|
||||
config := conf.Remote{
|
||||
Redis: &conf.Redis{Address: redisCli.address},
|
||||
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}},
|
||||
EnableClientRequestIdForwarding: true,
|
||||
}
|
||||
|
||||
systemService, systemCli := grpct.NewMock(test)
|
||||
systemService.Mock("system/secure/authenticate", func() domain.AuthenticateResponse {
|
||||
return domain.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: &domain.AuthData{
|
||||
SystemId: 1,
|
||||
DomainId: 2,
|
||||
ServiceId: 3,
|
||||
ApplicationId: 4,
|
||||
},
|
||||
}
|
||||
}).Mock("system/secure/authorize", func() domain.AuthorizeResponse {
|
||||
return domain.AuthorizeResponse{Authorized: true}
|
||||
})
|
||||
|
||||
adminService, adminCli := grpct.NewMock(test)
|
||||
adminService.Mock("admin/secure/authenticate", func(req domain.AdminAuthorizeRequest) domain.AdminAuthenticateResponse {
|
||||
return domain.AdminAuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AdminId: 1,
|
||||
}
|
||||
}).Mock("admin/secure/authorize", func(req domain.AdminAuthorizeRequest) domain.AdminAuthorizeResponse {
|
||||
if req.Permission == "ok_permission" {
|
||||
return domain.AdminAuthorizeResponse{Authorized: true}
|
||||
}
|
||||
return domain.AdminAuthorizeResponse{Authorized: false}
|
||||
})
|
||||
|
||||
return config, redisCli, systemCli, adminCli
|
||||
}
|
||||
|
||||
func TestHappyPathTestSuite(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, new(HappyPathTestSuite))
|
||||
}
|
||||
|
||||
func assertHeaders(require *require.Assertions, requestId string, ctx context.Context, headers http.Header) {
|
||||
systemId, err := strconv.Atoi(headers.Get("x-system-identity"))
|
||||
require.NoError(err)
|
||||
domainId, err := strconv.Atoi(headers.Get("x-domain-identity"))
|
||||
require.NoError(err)
|
||||
serviceId, err := strconv.Atoi(headers.Get("x-service-identity"))
|
||||
require.NoError(err)
|
||||
applicationId, err := strconv.Atoi(headers.Get("x-application-identity"))
|
||||
require.NoError(err)
|
||||
require.EqualValues(requestId, requestid.FromContext(ctx))
|
||||
require.EqualValues(1, systemId)
|
||||
require.EqualValues(2, domainId)
|
||||
require.EqualValues(3, serviceId)
|
||||
require.EqualValues(4, applicationId)
|
||||
|
||||
adminId, err := strconv.Atoi(headers.Get("x-admin-id"))
|
||||
require.NoError(err)
|
||||
require.EqualValues(1, adminId)
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"isp-gate-service/assembly"
|
||||
"isp-gate-service/conf"
|
||||
"isp-gate-service/domain"
|
||||
"isp-gate-service/routes"
|
||||
|
||||
"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 {
|
||||
Id string
|
||||
}
|
||||
|
||||
type response struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
// nolint
|
||||
func main() {
|
||||
redisCli := redis.NewClient(&redis.Options{})
|
||||
ctx := context.Background()
|
||||
logger, err := log.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer func() {
|
||||
_, _ = 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
|
||||
})
|
||||
}()
|
||||
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},
|
||||
DailyLimits: []conf.DailyLimit{{ApplicationId: 1, RequestsPerDay: 100000000}},
|
||||
Throttling: []conf.Throttling{{ApplicationId: 1, RequestsPerSeconds: 5000}},
|
||||
}
|
||||
|
||||
systemService, systemCli, _ := NewMock(logger)
|
||||
systemService.Mock("system/secure/authenticate", func() domain.AuthenticateResponse {
|
||||
return domain.AuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AuthData: &domain.AuthData{
|
||||
SystemId: 1,
|
||||
DomainId: 1,
|
||||
ServiceId: 1,
|
||||
ApplicationId: 1,
|
||||
},
|
||||
}
|
||||
}).Mock("system/secure/authorize", func() domain.AuthorizeResponse {
|
||||
return domain.AuthorizeResponse{Authorized: true}
|
||||
})
|
||||
|
||||
adminService, _, adminCli := NewMock(logger)
|
||||
adminService.Mock("admin/secure/authenticate", func() domain.AdminAuthenticateResponse {
|
||||
return domain.AdminAuthenticateResponse{
|
||||
Authenticated: true,
|
||||
ErrorReason: "",
|
||||
AdminId: 1,
|
||||
}
|
||||
})
|
||||
|
||||
targetService, targetCli, _ := NewMock(logger)
|
||||
targetService.Mock("endpoint", func(req request) response {
|
||||
return response{Id: req.Id}
|
||||
})
|
||||
targetClients := map[string]*client.Client{"target": targetCli}
|
||||
logger, _ = log.New(log.WithLevel(log.DebugLevel))
|
||||
locator := assembly.NewLocator(logger, targetClients, nil, routes.NewRoutes(), systemCli, adminCli)
|
||||
locations := []conf.Location{{
|
||||
SkipAuth: false,
|
||||
PathPrefix: "/api",
|
||||
Protocol: "grpc",
|
||||
TargetModule: "target",
|
||||
}}
|
||||
handler, _ := locator.Handler(config, locations, redisCli)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: "localhost:8000",
|
||||
Handler: handler,
|
||||
}
|
||||
srv.ListenAndServe()
|
||||
}
|
||||
|
||||
func TestServer(service isp.BackendServiceServer) (*grpc.Server, *client.Client, *client.Client) {
|
||||
listener, _ := net.Listen("tcp", "127.0.0.1:")
|
||||
srv := grpc.NewServer()
|
||||
sysCli, _ := client.Default()
|
||||
adminCli, _ := client.Default()
|
||||
srv.Upgrade(service)
|
||||
go func() {
|
||||
_ = srv.Serve(listener)
|
||||
}()
|
||||
|
||||
sysCli.Upgrade([]string{listener.Addr().String()})
|
||||
adminCli.Upgrade([]string{listener.Addr().String()})
|
||||
return srv, sysCli, adminCli
|
||||
}
|
||||
|
||||
type MockServer struct {
|
||||
srv *grpc.Server
|
||||
logger log.Logger
|
||||
mockEndpoints map[string]interface{}
|
||||
}
|
||||
|
||||
func NewMock(logger log.Logger) (*MockServer, *client.Client, *client.Client) {
|
||||
srv, syscli, admincli := TestServer(grpc.NewMux())
|
||||
return &MockServer{
|
||||
srv: srv,
|
||||
logger: logger,
|
||||
mockEndpoints: make(map[string]interface{}),
|
||||
}, syscli, admincli
|
||||
}
|
||||
|
||||
func (m *MockServer) Mock(endpoint string, handler interface{}) *MockServer {
|
||||
m.mockEndpoints[endpoint] = handler
|
||||
wrapper := endpoint2.DefaultWrapper(m.logger)
|
||||
muxer := grpc.NewMux()
|
||||
for e, handler := range m.mockEndpoints {
|
||||
muxer.Handle(e, wrapper.Endpoint(handler))
|
||||
}
|
||||
m.srv.Upgrade(muxer)
|
||||
return m
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"id": "GO4IIZW5uav4cSo2zyR6i41LdalKytNH628yDhC92jXQF07gu4LS75JuzQgc6d3Dly48fwla9iHK6LPTJcvFbOcklXp7Zr9g3b180s0H3dVgaYGcO8BrAFxMVb2KcHyu"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
bombardier -c 128 -t 1s -d 60s --fasthttp -H "x-application-token: token" -m POST -f body.json http://localhost:8000/api/endpoint
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/txix-open/isp-kit/test"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
Loaded 100 of 101 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user