|
I have an assignment in an operating systems class I'm taking. I'm supposed to create a client with a connection to a server, which calls methods which are defined in a .proto file, I think? I'm supposed to call methods from the client file anyway, which I need to implement in a separate server file. Problem is, I have no idea what I'm doing. I'm fairly adequate at coding, but I can't wrap my head around how gRPC actually work and the syntaxes of request handlers and functions. I'm terrible at learning and understanding concepts from reading documentations, I haven't found any relevant tutorials online, and my teacher has been sick for two weeks with pneumonia, so he hasn't been any help either. I have been given a .proto file with a service and several request and response definitions, an empty client.go file and a service.go file where I need to implement the methods from the .proto file. I've managed to create a client file, I think. Now I need it to communicate with the server file and make the right method calls. If somebody could explain the relationship between these, how they operate, and maybe a basic guide to how to do function calls from the client, that would be very helpful. Here is the kv.proto file code:
code:
code:
|
# ? Sep 30, 2016 10:30 |
|
|
# ? May 5, 2024 00:24 |
|
First, I'd recommend going through the examples on http://www.grpc.io/docs/quickstart/go.html to get a basic understanding of how this work, but you say you're terrible at this, so I'll try to help. Secondly, this probably isn't a big enough question for its own thread, but the Go thread is inactive so w/e. In a nutshell, all you're going to do is define a struct that implements Insert, Lookup, and Keys in your server file, register that struct as the server for those methods, and start up a server listening on some port. In your client, you simply connect to that port and use the client interface to make calls to that server. It's almost exactly what is shown in the quickstart example I linked above. Your server is probably going to look something like: https://play.golang.org/p/4SB6fFzyYm. Everything just return nil, that's where your logic goes, I guess. Your client is probably going to do something like: https://play.golang.org/p/mtxyScfsja. Yet again, the values that you're inserting or looking up or keying for are all missing, but that's supposed to be your homework. You run the server forever and then run the client. That's the main structure, hope that is helpful. Don't think I could help anymore without directly doing your homework for you.
|
# ? Oct 1, 2016 00:32 |