mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-02 09:49:13 +02:00
fix:#56 added update for grpc
This commit is contained in:
@@ -2,8 +2,10 @@ package grpc
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
pb "htwkalender/common/genproto/modules"
|
||||
@@ -14,7 +16,20 @@ func StartGRPCServer(app *pocketbase.PocketBase) {
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
s := grpc.NewServer()
|
||||
s := grpc.NewServer(
|
||||
grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||
MaxConnectionIdle: 5 * time.Minute, // Idle timeout before closing connection
|
||||
MaxConnectionAge: 30 * time.Minute, // Max time before connection is closed
|
||||
MaxConnectionAgeGrace: 5 * time.Minute, // Allow grace period before closing
|
||||
Time: 2 * time.Minute, // Ping the client every 2 minutes
|
||||
Timeout: 20 * time.Second, // Wait 20 seconds for ping ack
|
||||
}),
|
||||
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
||||
MinTime: 1 * time.Minute, // Minimum time between pings from clients
|
||||
PermitWithoutStream: true, // Don't allow pings when there are no active RPCs
|
||||
}),
|
||||
grpc.MaxConcurrentStreams(0),
|
||||
)
|
||||
|
||||
pb.RegisterModuleServiceServer(s, &ModuleServiceHandler{
|
||||
app: app,
|
||||
|
Reference in New Issue
Block a user