Developing a gRPC client
This section presents the development of the gRPC client based on the api.proto
file presented earlier. The main purpose of the client is to test the functionality of the server. However, what is really important is the implementation of three helper functions, each one corresponding to a different RPC call, because these three functions allow you to interact with the gRPC server. The purpose of the main()
function of gClient.go
is to use these three helper functions.
So, the code of gClient.go
is the following:
package main
import (
"context"
"fmt"
"math/rand"
"os"
"time"
"github.com/mactsouk/protoapi"
"google.golang.org/grpc"
)
var port = ":8080"
func AskingDateTime(ctx context.Context, m protoapi.RandomClient) (*protoapi.DateTime, error) {
You can name the AskingDateTime()
function anything you want. However, the signature of the function...