Skip to content

Commit

Permalink
Fix grpc options (#854)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art authored Apr 26, 2023
1 parent a15565e commit f40324b
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,17 @@ func main() {
tlsServerConfig := tlsconfig.MTLSServerConfig(source, source, tlsconfig.AuthorizeAny())
tlsServerConfig.MinVersion = tls.VersionTLS12

dialOptions := []grpc.DialOption{
grpc.WithBlock(),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(credentials.NewTLS(tlsClientConfig))),
dialOptions := append(
tracing.WithTracingDial(),
grpc.WithDefaultCallOptions(
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, cfg.MaxTokenLifetime))),
),
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, cfg.MaxTokenLifetime)))),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(tlsClientConfig))),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
}
)
spiffeIDConnMap := genericsync.Map[spiffeid.ID, *genericsync.Map[string, struct{}]]{}
endpoint := xconnectns.NewServer(
ctx,
Expand Down Expand Up @@ -266,10 +267,13 @@ func main() {
now = time.Now()

server := grpc.NewServer(
// TODO add serveroptions for tracing
grpc.Creds(
grpcfd.TransportCredentials(
credentials.NewTLS(tlsServerConfig))),
append(
tracing.WithTracing(),
grpc.Creds(
grpcfd.TransportCredentials(
credentials.NewTLS(tlsServerConfig)),
),
)...,
)
endpoint.Register(server)

Expand All @@ -282,23 +286,9 @@ func main() {
log.FromContext(ctx).Infof("executing phase 9: register %s with the registry (time since start: %s)", cfg.NSName, time.Since(starttime))
// ********************************************************************************
now = time.Now()

clientOptions := append(
tracing.WithTracingDial(),
grpc.WithBlock(),
grpc.WithDefaultCallOptions(
grpc.WaitForReady(true),
grpc.PerRPCCredentials(token.NewPerRPCCredentials(spiffejwt.TokenGeneratorFunc(source, cfg.MaxTokenLifetime)))),
grpc.WithTransportCredentials(
grpcfd.TransportCredentials(
credentials.NewTLS(tlsClientConfig))),
grpcfd.WithChainStreamInterceptor(),
grpcfd.WithChainUnaryInterceptor(),
)

registryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx,
registryclient.WithClientURL(&cfg.ConnectTo),
registryclient.WithDialOptions(clientOptions...),
registryclient.WithDialOptions(dialOptions...),
registryclient.WithNSEAdditionalFunctionality(
sendfd.NewNetworkServiceEndpointRegistryClient(),
),
Expand Down

0 comments on commit f40324b

Please sign in to comment.