MSP-8292 Up deps
This commit is contained in:
1 parent
3a66223a89
commit
5daaea50a1
186 files changed
+7092
-1579
No files matched your search
+5
-5
@@ -17,13 +17,13 @@
|
||||
|
||||
Обработать критические ошибки с уведомлением в Sentry
|
||||
|
||||
#### `New(moduleVersion string, remoteConfig any, endpoints []cluster.EndpointDescriptor, transport string) *Bootstrap`
|
||||
#### `New(moduleVersion string, remoteConfig any, endpointsResolver cluster.EndpointsResolver, transport string) *Bootstrap`
|
||||
|
||||
Конструктор с параметрами:
|
||||
|
||||
- `moduleVersion` - версия модуля
|
||||
- `remoteConfig` - структура для динамической конфигурации
|
||||
- `endpoints` - список эндпоинтов модуля, для транспорта `http` у каждого `endpoint`'а должен быть указан `HttpMethod`
|
||||
- `endpointsResolver` - резолвер эндпоинтов модуля; используйте `cluster.Endpoints(...)` для статического списка или реализуйте интерфейс `cluster.EndpointsResolver` для динамического; для транспорта `http` у каждого `endpoint`'а должен быть указан `HttpMethod`
|
||||
- `transport` - тип сервера, `grpc`, `http` или `empty`
|
||||
|
||||
#### `NewStandalone(moduleVersion string) *StandaloneBootstrap`
|
||||
@@ -82,7 +82,7 @@ type remoteConfig struct {
|
||||
func noopHandler() {}
|
||||
|
||||
func main() {
|
||||
endpoints := []cluster.EndpointDescriptor{{
|
||||
endpointsResolver := cluster.Endpoints([]cluster.EndpointDescriptor{{
|
||||
Path: "/api/service/private",
|
||||
Inner: true,
|
||||
Handler: noopHandler,
|
||||
@@ -90,8 +90,8 @@ func main() {
|
||||
Path: "/api/service/public",
|
||||
Inner: false,
|
||||
Handler: noopHandler,
|
||||
}}
|
||||
boot := bootstrap.New("1.0.0", remoteConfig{}, endpoints, cluster.GrpcTransport)
|
||||
}})
|
||||
boot := bootstrap.New("1.0.0", remoteConfig{}, endpointsResolver, cluster.GrpcTransport)
|
||||
|
||||
shutdown.On(func() { /* waiting for SIGINT & SIGTERM signals */
|
||||
log.Println("shutting down...")
|
||||
|
||||
+1
-1
@@ -8,9 +8,9 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/config"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/healthcheck"
|
||||
"github.com/txix-open/isp-kit/infra"
|
||||
"github.com/txix-open/isp-kit/infra/pprof"
|
||||
|
||||
+13
-13
@@ -11,7 +11,7 @@
|
||||
// boot := bootstrap.New(
|
||||
// "1.0.0", // module version
|
||||
// &RemoteConfig{}, // remote config struct
|
||||
// []cluster.EndpointDescriptor{}, // service endpoints
|
||||
// cluster.Endpoints([]cluster.EndpointDescriptor{}), // service endpoints
|
||||
// cluster.HttpTransport, // transport type
|
||||
// )
|
||||
//
|
||||
@@ -50,9 +50,9 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/txix-open/isp-kit/observability/sentry"
|
||||
@@ -88,7 +88,7 @@ type Bootstrap struct {
|
||||
// Parameters:
|
||||
// - moduleVersion: Version string of the module (e.g., "1.0.0")
|
||||
// - remoteConfig: Pointer to a struct defining the remote configuration schema
|
||||
// - endpoints: List of service endpoint descriptors for cluster discovery
|
||||
// - endpointsResolver: Resolver providing service endpoint descriptors for cluster discovery
|
||||
// - transport: Transport type (e.g., cluster.HttpTransport or cluster.GrpcTransport)
|
||||
//
|
||||
// Returns a fully initialized Bootstrap instance with:
|
||||
@@ -107,15 +107,15 @@ type Bootstrap struct {
|
||||
// boot := bootstrap.New(
|
||||
// "1.2.3",
|
||||
// &MyRemoteConfig{},
|
||||
// []cluster.EndpointDescriptor{
|
||||
// cluster.Endpoints([]cluster.EndpointDescriptor{
|
||||
// {Path: "/api/v1", HttpMethod: "GET"},
|
||||
// },
|
||||
// }),
|
||||
// cluster.HttpTransport,
|
||||
// )
|
||||
func New(
|
||||
moduleVersion string,
|
||||
remoteConfig any,
|
||||
endpoints []cluster.EndpointDescriptor,
|
||||
endpointsResolver cluster.EndpointsResolver,
|
||||
transport string,
|
||||
) *Bootstrap {
|
||||
isDev := isOnDevMode()
|
||||
@@ -124,8 +124,8 @@ func New(
|
||||
stdlog.Fatal(err)
|
||||
}
|
||||
|
||||
if transport == cluster.HttpTransport {
|
||||
for _, endpoint := range endpoints {
|
||||
if transport == cluster.HttpTransport && endpointsResolver != nil {
|
||||
for _, endpoint := range endpointsResolver.Endpoints() {
|
||||
if endpoint.HttpMethod == "" {
|
||||
app.Logger().Fatal(
|
||||
app.Context(),
|
||||
@@ -178,7 +178,7 @@ func New(
|
||||
transport,
|
||||
remoteConfig,
|
||||
moduleVersion,
|
||||
endpoints,
|
||||
endpointsResolver,
|
||||
)
|
||||
if err != nil {
|
||||
err = errors.WithMessage(err, "create bootstrap")
|
||||
@@ -196,7 +196,7 @@ func newClustered(
|
||||
transport string,
|
||||
remoteConfig any,
|
||||
moduleVersion string,
|
||||
endpoints []cluster.EndpointDescriptor,
|
||||
endpointsResolver cluster.EndpointsResolver,
|
||||
) (*Bootstrap, error) {
|
||||
broadcastHost, err := resolveBroadcastHost(localConfig)
|
||||
if err != nil {
|
||||
@@ -223,7 +223,7 @@ func newClustered(
|
||||
moduleVersion,
|
||||
transport,
|
||||
broadcastHost,
|
||||
endpoints,
|
||||
endpointsResolver,
|
||||
wrappedLogger,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -294,7 +294,7 @@ func initClusterClient(
|
||||
moduleVersion string,
|
||||
transport string,
|
||||
broadcastHost string,
|
||||
endpoints []cluster.EndpointDescriptor,
|
||||
endpointsResolver cluster.EndpointsResolver,
|
||||
logger log.Logger,
|
||||
) (*cluster.Client, error) {
|
||||
moduleInfo := cluster.ModuleInfo{
|
||||
@@ -306,7 +306,7 @@ func initClusterClient(
|
||||
IP: broadcastHost,
|
||||
Port: strconv.Itoa(localConfig.GrpcOuterAddress.Port),
|
||||
},
|
||||
Endpoints: endpoints,
|
||||
EndpointsResolver: endpointsResolver,
|
||||
MetricsAutodiscovery: metricsServiceDiscovery(localConfig, broadcastHost),
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
stdlog "log"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
"github.com/txix-open/isp-kit/json"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"github.com/txix-open/isp-kit/observability/sentry"
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@ import (
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/config"
|
||||
"github.com/txix-open/isp-kit/errors"
|
||||
)
|
||||
|
||||
func isOnDevMode() bool {
|
||||
|
||||
Reference in new issue
Block a user