...

Source file src/github.com/grpc-ecosystem/go-grpc-prometheus/examples/grpc-server-with-prometheus/client/client.go

Documentation: github.com/grpc-ecosystem/go-grpc-prometheus/examples/grpc-server-with-prometheus/client

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  
     7  	"golang.org/x/net/context"
     8  	"google.golang.org/grpc"
     9  
    10  	pb "github.com/grpc-ecosystem/go-grpc-prometheus/examples/grpc-server-with-prometheus/protobuf"
    11  )
    12  
    13  func main() {
    14  	// Create a insecure gRPC channel to communicate with the server.
    15  	conn, err := grpc.Dial(
    16  		fmt.Sprintf("localhost:%v", 9093),
    17  		grpc.WithInsecure(),
    18  	)
    19  	if err != nil {
    20  		log.Fatal(err)
    21  	}
    22  
    23  	defer conn.Close()
    24  
    25  	// Create a gRPC server client.
    26  	client := pb.NewDemoServiceClient(conn)
    27  	// Call “SayHello” method and wait for response from gRPC Server.
    28  	resp, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "Test"})
    29  	if err != nil {
    30  		log.Fatal(err)
    31  	}
    32  
    33  	fmt.Println(resp)
    34  }
    35  

View as plain text