Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e571aa709a | ||
|
|
3c0c32ec72 |
No files matched your search
@@ -1,3 +1,11 @@
|
||||
### v3.9.0
|
||||
* Обновлены зависимости
|
||||
* Добавлено поле `transport` в таблицу `isp_config_service__backend`
|
||||
* Расширен ответ по `/routing/get_routes` и `/module/get_modules_info`:
|
||||
* Добавлено поле `httpMethod` в `domain.EndpointDescriptor`
|
||||
* Добавлено поле `transport` в `domain.Connection`
|
||||
### v3.8.1
|
||||
* исправлена миграция для `config-history`
|
||||
### v3.8.0
|
||||
* Добавлен новый endpoint `config/schema/update_by_module_name` для обновления схемы модуля по его названию
|
||||
## v3.7.0
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ require (
|
||||
github.com/mattn/go-sqlite3 v1.14.32
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pressly/goose/v3 v3.26.0
|
||||
github.com/txix-open/isp-kit v1.63.3
|
||||
github.com/txix-open/isp-kit v1.64.11
|
||||
isp-config-service v0.0.0-00010101000000-000000000000
|
||||
)
|
||||
|
||||
|
||||
+4
-4
@@ -67,8 +67,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
||||
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=
|
||||
@@ -147,8 +147,8 @@ github.com/txix-open/bellows v1.2.0 h1:CXv8nQaZtB/micraeRilYyj/gtfv+bqBgP5aPYQgj
|
||||
github.com/txix-open/bellows v1.2.0/go.mod h1:qbKCy+RTgD30Qpw1fyb3y3jp5Y9mGhLLxgae1l0W92o=
|
||||
github.com/txix-open/etp/v4 v4.0.1 h1:5VSYgGsvnMz0tvUHsjVWFETI0qWBTCF1O3ARCHaCIgA=
|
||||
github.com/txix-open/etp/v4 v4.0.1/go.mod h1:FIu7TUDdwcgmtmF6tFTV1bGA2fRY/iVaPQdsGzvqYc8=
|
||||
github.com/txix-open/isp-kit v1.63.3 h1:UJLgR4z8sYXUX6r1sl6Ww1aijPx6b7ieMeB+elZoViM=
|
||||
github.com/txix-open/isp-kit v1.63.3/go.mod h1:rwqKqB3PyZxaoep6iH1PKL89LS9nzRklA6+S4II72M4=
|
||||
github.com/txix-open/isp-kit v1.64.11 h1:K7RILD1of3iUYRFVCMw+S0epxo4CnL6KoYo8lNUi4Tk=
|
||||
github.com/txix-open/isp-kit v1.64.11/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb/go.mod h1:0biAFE0bgbcKeBBAwgEDhbZz6uT1vuSETCrFQlv2RiA=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
|
||||
+2
-2
@@ -167,7 +167,7 @@ func main() {
|
||||
AdminId: 0,
|
||||
CreatedAt: xtypes.Time(history.CreatedAt),
|
||||
}
|
||||
err := configHistoryRepo.Insert(ctx, result)
|
||||
err := configHistoryRepo.InsertV2(ctx, result)
|
||||
if err != nil {
|
||||
panic(errors.WithMessagef(err, "err inserting config_history: %s", history.Id))
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func main() {
|
||||
Header("Content-Type", "application/octet-stream").
|
||||
RequestBody(sqliteFile).
|
||||
StatusCodeToError().
|
||||
Timeout(60 * time.Second).
|
||||
Timeout(120 * time.Second).
|
||||
DoWithoutResponse(ctx)
|
||||
if err != nil {
|
||||
panic(errors.WithMessage(err, "load sqlite file"))
|
||||
|
||||
@@ -72,6 +72,8 @@ definitions:
|
||||
type: string
|
||||
moduleName:
|
||||
type: string
|
||||
transport:
|
||||
type: string
|
||||
version:
|
||||
type: string
|
||||
type: object
|
||||
@@ -141,6 +143,8 @@ definitions:
|
||||
type: object
|
||||
domain.EndpointDescriptor:
|
||||
properties:
|
||||
httpMethod:
|
||||
type: string
|
||||
inner:
|
||||
type: boolean
|
||||
path:
|
||||
|
||||
+4
-2
@@ -33,6 +33,7 @@ type Connection struct {
|
||||
LibVersion string
|
||||
Version string
|
||||
Address Address
|
||||
Transport string
|
||||
Endpoints []EndpointDescriptor
|
||||
EstablishedAt time.Time
|
||||
}
|
||||
@@ -43,8 +44,9 @@ type Address struct {
|
||||
}
|
||||
|
||||
type EndpointDescriptor struct {
|
||||
Path string
|
||||
Inner bool
|
||||
HttpMethod string
|
||||
Path string
|
||||
Inner bool
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
||||
@@ -13,6 +13,7 @@ type Backend struct {
|
||||
Version string `json:"version"`
|
||||
LibVersion string `json:"lib_version"`
|
||||
ModuleName string `json:"module_name"`
|
||||
Transport string `json:"transport"`
|
||||
ConfigServiceNodeId string `json:"config_service_node_id"`
|
||||
Endpoints xtypes.Json[[]cluster.EndpointDescriptor] `json:"endpoints"`
|
||||
RequiredModules xtypes.Json[[]cluster.ModuleDependency] `json:"required_modules"`
|
||||
|
||||
@@ -21,7 +21,7 @@ require (
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/txix-open/etp/v4 v4.0.1
|
||||
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60
|
||||
github.com/txix-open/isp-kit v1.63.3
|
||||
github.com/txix-open/isp-kit v1.64.11
|
||||
github.com/xeipuuv/gojsonschema v1.2.0
|
||||
golang.org/x/sync v0.18.0
|
||||
google.golang.org/grpc v1.77.0
|
||||
|
||||
@@ -172,8 +172,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
|
||||
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
@@ -313,8 +313,10 @@ github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60 h1:7SZ72lNU69g8ei
|
||||
github.com/txix-open/go-cmp v0.0.0-20240401171944-16b203530f60/go.mod h1:jzpq0uwcdGq0OSNXZ6vv6UJkCOU/fLPgeoz+KkGDYgo=
|
||||
github.com/txix-open/grmq v1.9.0 h1:ArDbJJcFX9zXKEcPf49rp9nYiRyGMJxGKJAxdbSsfaM=
|
||||
github.com/txix-open/grmq v1.9.0/go.mod h1:EyFOP17KrwEFOUjR+PH8iH3LCtiN9TSQ8t0ysyk62po=
|
||||
github.com/txix-open/isp-kit v1.63.3 h1:UJLgR4z8sYXUX6r1sl6Ww1aijPx6b7ieMeB+elZoViM=
|
||||
github.com/txix-open/isp-kit v1.63.3/go.mod h1:rwqKqB3PyZxaoep6iH1PKL89LS9nzRklA6+S4II72M4=
|
||||
github.com/txix-open/isp-kit v1.64.10 h1:lAowLtShBbICZbOWQJ4ptr9LaKKRZ7CE5DBK+7LcLqM=
|
||||
github.com/txix-open/isp-kit v1.64.10/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
|
||||
github.com/txix-open/isp-kit v1.64.11 h1:K7RILD1of3iUYRFVCMw+S0epxo4CnL6KoYo8lNUi4Tk=
|
||||
github.com/txix-open/isp-kit v1.64.11/go.mod h1:GvBsX5p2U3/ugK6PuWANYzSy/4YgawROm3eAKb35G6o=
|
||||
github.com/txix-open/jsonschema v1.3.0 h1:XGuOTg22G7PdqfKypjajM20/i5FyGfFYsJKmheebKi4=
|
||||
github.com/txix-open/jsonschema v1.3.0/go.mod h1:l8YDZ1nvJrw6uxWowSVOxCV/ebiMJyapffW87ZEqH00=
|
||||
github.com/txix-open/validator/v10 v10.0.0-20250506161033-f8ce404fffdb h1:UJgT4u/QMv5QHKOQeJ7igShHa36c2/vIRqJiRLdDlf0=
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"isp-config-service/service/startup"
|
||||
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/shutdown"
|
||||
)
|
||||
|
||||
@@ -25,7 +26,7 @@ var (
|
||||
//go:generate swag init --parseDependency
|
||||
//go:generate rm -f docs/swagger.json docs/docs.go
|
||||
func main() {
|
||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors())
|
||||
boot := bootstrap.New(version, conf.Remote{}, routes.EndpointDescriptors(), cluster.GrpcTransport)
|
||||
app := boot.App
|
||||
logger := app.Logger()
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
-- +goose Up
|
||||
-- +goose NO TRANSACTION
|
||||
alter table isp_config_service__backend add column transport text;
|
||||
|
||||
-- +goose Down
|
||||
alter table isp_config_service__backend drop column transport;
|
||||
@@ -26,11 +26,13 @@ func (r Backend) Insert(ctx context.Context, backend entity.Backend) error {
|
||||
|
||||
query, args, err := squirrel.Insert(Table("backend")).
|
||||
Columns("ws_connection_id", "module_id", "address",
|
||||
"version", "lib_version", "module_name", "config_service_node_id",
|
||||
"endpoints", "required_modules", "metrics_autodiscovery").
|
||||
"version", "lib_version", "module_name", "transport",
|
||||
"config_service_node_id", "endpoints", "required_modules",
|
||||
"metrics_autodiscovery").
|
||||
Values(backend.WsConnectionId, backend.ModuleId, backend.Address,
|
||||
backend.Version, backend.LibVersion, backend.ModuleName, backend.ConfigServiceNodeId,
|
||||
backend.Endpoints, backend.RequiredModules, backend.MetricsAutodiscovery,
|
||||
backend.Version, backend.LibVersion, backend.ModuleName, backend.Transport,
|
||||
backend.ConfigServiceNodeId, backend.Endpoints, backend.RequiredModules,
|
||||
backend.MetricsAutodiscovery,
|
||||
).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
|
||||
@@ -44,6 +44,25 @@ func (r ConfigHistory) Delete(ctx context.Context, id string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r ConfigHistory) InsertV2(ctx context.Context, history entity.ConfigHistory) error {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.InsertV2")
|
||||
|
||||
query, args, err := squirrel.Insert(Table("config_history")).
|
||||
Columns("id", "config_id", "data", "version", "admin_id").
|
||||
Values(history.Id, history.ConfigId, history.Data, history.Version, history.AdminId).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "build query")
|
||||
}
|
||||
|
||||
_, err = r.db.Exec(ctx, query, args...)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "exec: %s", query)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r ConfigHistory) Insert(ctx context.Context, history entity.ConfigHistory) error {
|
||||
ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Insert")
|
||||
|
||||
|
||||
@@ -142,12 +142,17 @@ func (s Module) backendToDto(backend entity.Backend) (domain.Connection, error)
|
||||
endpointsDescriptors := make([]domain.EndpointDescriptor, 0)
|
||||
for _, desc := range backend.Endpoints.Value {
|
||||
endpointsDescriptors = append(endpointsDescriptors, domain.EndpointDescriptor{
|
||||
Path: desc.Path,
|
||||
Inner: desc.Inner,
|
||||
HttpMethod: desc.HttpMethod,
|
||||
Path: desc.Path,
|
||||
Inner: desc.Inner,
|
||||
})
|
||||
}
|
||||
slices.SortFunc(endpointsDescriptors, func(a, b domain.EndpointDescriptor) int {
|
||||
return cmp.Compare(a.Path, b.Path)
|
||||
c := cmp.Compare(a.Path, b.Path)
|
||||
if c != 0 {
|
||||
return c
|
||||
}
|
||||
return cmp.Compare(a.HttpMethod, b.HttpMethod)
|
||||
})
|
||||
|
||||
conn := domain.Connection{
|
||||
@@ -155,6 +160,7 @@ func (s Module) backendToDto(backend entity.Backend) (domain.Connection, error)
|
||||
ModuleName: backend.ModuleName,
|
||||
LibVersion: backend.LibVersion,
|
||||
Version: backend.Version,
|
||||
Transport: backend.Transport,
|
||||
Address: domain.Address{
|
||||
Ip: addr.IP,
|
||||
Port: addr.Port,
|
||||
|
||||
@@ -3,13 +3,15 @@ package backend
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"isp-config-service/entity"
|
||||
"isp-config-service/entity/xtypes"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/etp/v4"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-config-service/entity"
|
||||
"isp-config-service/entity/xtypes"
|
||||
)
|
||||
|
||||
type Repo interface {
|
||||
@@ -58,6 +60,17 @@ func (s Backend) Connect(
|
||||
metricsAd = &xtypes.Json[cluster.MetricsAutodiscovery]{Value: *declaration.MetricsAutodiscovery}
|
||||
}
|
||||
|
||||
if declaration.Transport == "" {
|
||||
declaration.Transport = cluster.GrpcTransport
|
||||
}
|
||||
if declaration.Transport == cluster.GrpcTransport {
|
||||
for i := range declaration.Endpoints {
|
||||
if declaration.Endpoints[i].HttpMethod == "" {
|
||||
declaration.Endpoints[i].HttpMethod = http.MethodPost
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
backend := entity.Backend{
|
||||
WsConnectionId: connId,
|
||||
ModuleId: moduleId,
|
||||
@@ -65,6 +78,7 @@ func (s Backend) Connect(
|
||||
Version: declaration.Version,
|
||||
LibVersion: declaration.LibVersion,
|
||||
ModuleName: declaration.ModuleName,
|
||||
Transport: declaration.Transport,
|
||||
ConfigServiceNodeId: s.nodeId,
|
||||
Endpoints: xtypes.Json[[]cluster.EndpointDescriptor]{Value: declaration.Endpoints},
|
||||
RequiredModules: xtypes.Json[[]cluster.ModuleDependency]{Value: declaration.RequiredModules},
|
||||
|
||||
@@ -209,6 +209,7 @@ func (s Service) notifyRoutingChanged(ctx context.Context, event string, conns [
|
||||
ModuleName: backend.ModuleName,
|
||||
Version: backend.Version,
|
||||
LibVersion: backend.LibVersion,
|
||||
Transport: backend.Transport,
|
||||
Endpoints: backend.Endpoints.Value,
|
||||
RequiredModules: backend.RequiredModules.Value,
|
||||
Address: addr,
|
||||
|
||||
@@ -172,7 +172,7 @@ func setupTest(t *testing.T) log.Logger {
|
||||
|
||||
t.Setenv("APP_CONFIG_PATH", "../conf/config.yml")
|
||||
t.Setenv("DefaultRemoteConfigPath", "../conf/default_remote_config.json")
|
||||
boot := bootstrap.New("1.0.0", conf.Remote{}, nil)
|
||||
boot := bootstrap.New("1.0.0", conf.Remote{}, nil, cluster.GrpcTransport)
|
||||
boot.MigrationsDir = "../migrations"
|
||||
dataPath := dataDir(t)
|
||||
boot.App.Config().Set("rqlite.DataPath", dataPath)
|
||||
|
||||
@@ -92,7 +92,7 @@ func setupTestWithAppRun(t *testing.T) (*require.Assertions, log.Logger) {
|
||||
|
||||
t.Setenv("APP_CONFIG_PATH", "../conf/config.yml")
|
||||
t.Setenv("DefaultRemoteConfigPath", "../conf/default_remote_config.json")
|
||||
boot := bootstrap.New("1.0.0", conf.Remote{}, nil)
|
||||
boot := bootstrap.New("1.0.0", conf.Remote{}, nil, cluster.GrpcTransport)
|
||||
boot.MigrationsDir = "../migrations"
|
||||
dataPath := dataDir(t)
|
||||
boot.App.Config().Set("rqlite.DataPath", dataPath)
|
||||
|
||||
Reference in new issue
Block a user