2024-01-22 17:22:41: merge [master:56d3e06e49d7a75f142424293788a4f3b6245430];
This commit is contained in:
1 parent
7014f56cbb
commit
2b91caece0
60 files changed
+3558
No files matched your search
@@ -0,0 +1,24 @@
|
||||
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: /api
|
||||
protocol: grpc
|
||||
targetModule: router
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
- pathPrefix: /api
|
||||
protocol: grpc
|
||||
skipAuth: false
|
||||
targetModule: router
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"logging": {
|
||||
"logLevel": "debug",
|
||||
"requestLogEnable": true,
|
||||
"bodyLogEnable": false,
|
||||
"skipBodyLoggingEndpointPrefixes": []
|
||||
},
|
||||
"caching": {
|
||||
"authenticationDataInSec": 60,
|
||||
"authorizationDataInSec": 60
|
||||
},
|
||||
"http": {
|
||||
"maxRequestBodySizeInMb": 64,
|
||||
"proxyTimeoutInSec": 60
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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,77 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/integration-system/isp-kit/log"
|
||||
"github.com/integration-system/isp-kit/rc/schema"
|
||||
"github.com/integration-system/jsonschema"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
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:"Настройки пропускной способности"`
|
||||
}
|
||||
|
||||
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,13 @@
|
||||
package conf_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/integration-system/isp-kit/test/rct"
|
||||
"isp-gate-service/conf"
|
||||
)
|
||||
|
||||
func TestDefaultRemoteConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
rct.Test(t, "default_remote_config.json", conf.Remote{})
|
||||
}
|
||||
Reference in new issue
Block a user