How to increase GRPC message size in Mortar? #58
Answered
by
talgendler
yingjingchen-pki
asked this question in
Q&A
-
I would like to increase GRPC message size. on server:
But, how to do it in Mortar? |
Beta Was this translation helpful? Give feedback.
Answered by
talgendler
Jul 31, 2022
Replies: 1 comment 1 reply
-
Assuming you are using the service git template, you will need to replace Web service invocation run by the Instead of calling a generic service invocation code here: https://github.com/go-masonry/mortar-template/blob/master/main.go#L42 You will need to copy and change this file on your service and call it instead. type webServiceDependencies struct {
fx.In
LifeCycle fx.Lifecycle
Logger log.Logger
WebServiceBuilder server.GRPCWebServiceBuilder
}
// Service should be invoked by FX, it will build the entire dependencies graph and add lifecycle hooks
func Service(deps webServiceDependencies) (server.WebService, error) {
webService, err := deps.WebServiceBuilder.
/*******************************************************************************************************
Add any kind of options here to the builder before it gets built.
AddGRPCServerOptions(your options).
********************************************************************************************************/
Build()
if err != nil {
return nil, err
}
deps.LifeCycle.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
go webService.Run(ctx) // this should exit only when service was shutdown
return deps.pingService(ctx, webService)
},
OnStop: func(ctx context.Context) error {
return webService.Stop(ctx)
},
})
return webService, nil
}
func (deps webServiceDependencies) pingService(ctx context.Context, service server.WebService) (err error) {
err = fmt.Errorf("failed to check internal service health")
ports := service.Ports()
if grpcAddress := deps.getGRPCAddress(ports); len(grpcAddress) > 0 {
var conn *grpc.ClientConn
if conn, err = grpc.DialContext(ctx, grpcAddress, grpc.WithInsecure()); err == nil {
defer conn.Close()
healthClient := health.NewHealthClient(conn)
_, err = healthClient.Check(ctx, &health.HealthCheckRequest{})
}
}
if err == nil {
for _, info := range ports {
deps.Logger.Debug(ctx, "Service is accepting %s calls on %s", info.Type, info.Address)
}
deps.Logger.Debug(ctx, "Service is up")
}
return
}
func (deps webServiceDependencies) getGRPCAddress(ports []server.ListenInfo) string {
for _, info := range ports {
if info.Type == server.GRPCServer {
return info.Address
}
}
return ""
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
yingjingchen-pki
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming you are using the service git template, you will need to replace Web service invocation run by the
main.go
file.Instead of calling a generic service invocation code here: https://github.com/go-masonry/mortar-template/blob/master/main.go#L42
You will need to copy and change this file on your service and call it instead.