Last active
August 6, 2021 11:36
-
-
Save percybolmer/25967657fc9ff066272316834c459b02 to your computer and use it in GitHub Desktop.
A pingcounting grpc Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GenerateTLSApi will load TLS certificates and key and create a grpc server with those. | |
func GenerateTLSApi(pemPath, keyPath string) (*grpc.Server, error) { | |
cred, err := credentials.NewServerTLSFromFile(pemPath, keyPath) | |
if err != nil { | |
return nil, err | |
} | |
// Add PingCounter from the interceptors package | |
pc := interceptors.PingCounter{} | |
s := grpc.NewServer( | |
grpc.Creds(cred), | |
// Here we add the ServerCount interceptor | |
grpc.UnaryInterceptor(pc.ServerCount), | |
) | |
return s, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment