MSP-3809 update grpc server
This commit is contained in:
1 parent
408e1cf762
commit
3f1414006f
3 files changed
+9
-18
No files matched your search
@@ -4,8 +4,6 @@ package assembly
|
||||
import (
|
||||
"context"
|
||||
|
||||
stdgrpc "google.golang.org/grpc"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/txix-open/isp-kit/app"
|
||||
"github.com/txix-open/isp-kit/bootstrap"
|
||||
@@ -16,8 +14,6 @@ import (
|
||||
"isp-script-service/conf"
|
||||
)
|
||||
|
||||
const GrpcMaxRecvMsgSize = 64 * 1024 * 1024
|
||||
|
||||
type Assembly struct {
|
||||
boot *bootstrap.Bootstrap
|
||||
server *grpc.Server
|
||||
@@ -26,7 +22,7 @@ type Assembly struct {
|
||||
}
|
||||
|
||||
func New(boot *bootstrap.Bootstrap) (*Assembly, error) {
|
||||
server := grpc.NewServer(stdgrpc.MaxRecvMsgSize(GrpcMaxRecvMsgSize))
|
||||
server := grpc.DefaultServer()
|
||||
router, err := client.Default()
|
||||
if err != nil {
|
||||
return nil, errors.WithMessage(err, "create repository client")
|
||||
|
||||
+7
-11
@@ -2,9 +2,9 @@
|
||||
package assembly
|
||||
|
||||
import (
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/grpc/client"
|
||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
||||
"github.com/txix-open/isp-kit/grpc/isp"
|
||||
"github.com/txix-open/isp-kit/log"
|
||||
"isp-script-service/conf"
|
||||
"isp-script-service/controller"
|
||||
@@ -25,19 +25,15 @@ func NewLocator(logger log.Logger, grpcCli *client.Client) Locator {
|
||||
}
|
||||
}
|
||||
|
||||
func (l Locator) Handler(cfg conf.Remote) isp.BackendServiceServer {
|
||||
func (l Locator) Handler(cfg conf.Remote) *grpc.Mux {
|
||||
router := repository.NewRouter(l.grpcCli)
|
||||
scriptService := service.NewScript(router, l.logger, cfg.Scripts, cfg.SharedScript, cfg.ScriptExecutionTimeoutMs)
|
||||
scriptController := controller.NewScript(scriptService)
|
||||
|
||||
handler := routes.Handler(
|
||||
endpoint.DefaultWrapper(
|
||||
l.logger,
|
||||
),
|
||||
routes.Controllers{
|
||||
Script: scriptController,
|
||||
},
|
||||
)
|
||||
|
||||
c := routes.Controllers{
|
||||
Script: scriptController,
|
||||
}
|
||||
mapper := endpoint.DefaultWrapper(l.logger, endpoint.BodyLogger(l.logger))
|
||||
handler := routes.Handler(mapper, c)
|
||||
return handler
|
||||
}
|
||||
+1
-2
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/txix-open/isp-kit/cluster"
|
||||
"github.com/txix-open/isp-kit/grpc"
|
||||
"github.com/txix-open/isp-kit/grpc/endpoint"
|
||||
"github.com/txix-open/isp-kit/grpc/isp"
|
||||
"isp-script-service/controller"
|
||||
)
|
||||
|
||||
@@ -17,7 +16,7 @@ func EndpointDescriptors() []cluster.EndpointDescriptor {
|
||||
return endpointDescriptors(Controllers{})
|
||||
}
|
||||
|
||||
func Handler(wrapper endpoint.Wrapper, c Controllers) isp.BackendServiceServer {
|
||||
func Handler(wrapper endpoint.Wrapper, c Controllers) *grpc.Mux {
|
||||
muxer := grpc.NewMux()
|
||||
for _, descriptor := range endpointDescriptors(c) {
|
||||
muxer.Handle(descriptor.Path, wrapper.Endpoint(descriptor.Handler))
|
||||
|
||||
Reference in new issue
Block a user