Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0be5d9006a |
No files matched your search
@@ -1,3 +1,5 @@
|
|||||||
|
### v3.10.0
|
||||||
|
* событие `MODULE_READY` теперь может быть обработано несколько раз, обновляя полученные данные об инстансе модуля
|
||||||
### v3.9.3
|
### v3.9.3
|
||||||
* обновлены зависимости
|
* обновлены зависимости
|
||||||
### v3.9.2
|
### v3.9.2
|
||||||
|
|||||||
+12
-4
@@ -4,11 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"isp-config-service/entity"
|
"isp-config-service/entity"
|
||||||
"isp-config-service/middlewares/sql_metrics"
|
"isp-config-service/middlewares/sql_metrics"
|
||||||
"isp-config-service/service/rqlite/db"
|
"isp-config-service/service/rqlite/db"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Backend struct {
|
type Backend struct {
|
||||||
@@ -21,8 +22,8 @@ func NewBackend(db db.DB) Backend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Backend) Insert(ctx context.Context, backend entity.Backend) error {
|
func (r Backend) Upsert(ctx context.Context, backend entity.Backend) error {
|
||||||
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.Insert")
|
ctx = sql_metrics.OperationLabelToContext(ctx, "Backend.Upsert")
|
||||||
|
|
||||||
query, args, err := squirrel.Insert(Table("backend")).
|
query, args, err := squirrel.Insert(Table("backend")).
|
||||||
Columns("ws_connection_id", "module_id", "address",
|
Columns("ws_connection_id", "module_id", "address",
|
||||||
@@ -34,6 +35,13 @@ func (r Backend) Insert(ctx context.Context, backend entity.Backend) error {
|
|||||||
backend.ConfigServiceNodeId, backend.Endpoints, backend.RequiredModules,
|
backend.ConfigServiceNodeId, backend.Endpoints, backend.RequiredModules,
|
||||||
backend.MetricsAutodiscovery,
|
backend.MetricsAutodiscovery,
|
||||||
).
|
).
|
||||||
|
Suffix(`on conflict (ws_connection_id) do update
|
||||||
|
set module_id = excluded.module_id, address = excluded.address,
|
||||||
|
version = excluded.version, lib_version = excluded.lib_version,
|
||||||
|
module_name = excluded.module_name, transport = excluded.transport,
|
||||||
|
config_service_node_id = excluded.config_service_node_id,
|
||||||
|
endpoints = excluded.endpoints, required_modules = excluded.required_modules,
|
||||||
|
metrics_autodiscovery = excluded.metrics_autodiscovery`).
|
||||||
ToSql()
|
ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.WithMessage(err, "build query")
|
return errors.WithMessage(err, "build query")
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Repo interface {
|
type Repo interface {
|
||||||
Insert(ctx context.Context, backend entity.Backend) error
|
Upsert(ctx context.Context, backend entity.Backend) error
|
||||||
DeleteByWsConnectionIds(ctx context.Context, wsConnIds []string) error
|
DeleteByWsConnectionIds(ctx context.Context, wsConnIds []string) error
|
||||||
GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error)
|
GetByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) ([]entity.Backend, error)
|
||||||
DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error)
|
DeleteByConfigServiceNodeId(ctx context.Context, configServiceNodeId string) (int, error)
|
||||||
@@ -86,7 +86,7 @@ func (s Backend) Connect(
|
|||||||
MetricsAutodiscovery: metricsAd,
|
MetricsAutodiscovery: metricsAd,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s.backendRepo.Insert(ctx, backend)
|
err := s.backendRepo.Upsert(ctx, backend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.WithMessage(err, "upsert backend in store")
|
return nil, errors.WithMessage(err, "upsert backend in store")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user