Merge pull request #2295 from jmccann/keepalive_server

Allow setting MinTime for keepalive enforcement on server
This commit is contained in:
Brad Rydzewski 2018-02-19 13:36:13 -08:00 committed by GitHub
commit ce740a635e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,7 @@ import (
"time" "time"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"
@ -468,6 +469,11 @@ var flags = []cli.Flag{
Name: "coding-skip-verify", Name: "coding-skip-verify",
Usage: "coding skip ssl verification", Usage: "coding skip ssl verification",
}, },
cli.DurationFlag{
EnvVar: "DRONE_KEEPALIVE_MIN_TIME",
Name: "keepalive-min-time",
Usage: "server-side enforcement policy on the minimum amount of time a client should wait before sending a keepalive ping.",
},
} }
func server(c *cli.Context) error { func server(c *cli.Context) error {
@ -534,6 +540,9 @@ func server(c *cli.Context) error {
s := grpc.NewServer( s := grpc.NewServer(
grpc.StreamInterceptor(auther.streamInterceptor), grpc.StreamInterceptor(auther.streamInterceptor),
grpc.UnaryInterceptor(auther.unaryIntercaptor), grpc.UnaryInterceptor(auther.unaryIntercaptor),
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
MinTime: c.Duration("keepalive-min-time"),
}),
) )
ss := new(droneserver.DroneServer) ss := new(droneserver.DroneServer)
ss.Queue = droneserver.Config.Services.Queue ss.Queue = droneserver.Config.Services.Queue