Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close gprcClient defined by service in the .proto file. #2264

Closed
bradyjoestar opened this issue Aug 15, 2018 · 2 comments
Closed

Close gprcClient defined by service in the .proto file. #2264

bradyjoestar opened this issue Aug 15, 2018 · 2 comments

Comments

@bradyjoestar
Copy link

Please answer these questions before submitting your issue.

What version of gRPC are you using?

grpc-go

What version of Go are you using (go version)?

1.10

What operating system (Linux, Windows, …) and version?

ubuntu

What did you do?

In the grpc-go/examples/helloworld/helloworld/helloworld.pb.go,It define a

// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type GreeterClient interface {
	// Sends a greeting
	SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
}

type greeterClient struct {
	cc *grpc.ClientConn
}

How should I close a GreenClient connect? its not a net.Conn and greeterClient doesn't expose a Close().

@lyuxuan
Copy link
Contributor

lyuxuan commented Aug 15, 2018

GreeterClient is the stub(interface) for RPC calls. greeterClient is the proto generated implementation of GreeterClient interface, and greeterClient takes a ClientConn to be initialized (here). Therefore, to close the connection, you simply close the ClientConn you initialize greeterClient with (like here). greeterClient itself is not a connection, therefore cannot be closed. It only keeps a reference to a connection(i.e. ClientConn). Thanks!

@bradyjoestar
Copy link
Author

@lyuxuan Thanks for help! Appreciate it!

melekes pushed a commit to tendermint/tendermint that referenced this issue Aug 17, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Feb 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants