gRPC: Up and Running by Danesh Kuruppu & Kasun Indrasiri

gRPC: Up and Running by Danesh Kuruppu & Kasun Indrasiri

Author:Danesh Kuruppu & Kasun Indrasiri [Danesh Kuruppu]
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2020-01-29T16:00:00+00:00


Example 5-5. gRPC deadlines for the client application

conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Fatalf("did not connect: %v", err) } defer conn.Close() client := pb.NewOrderManagementClient(conn) clientDeadline := time.Now().Add( time.Duration(2 * time.Second)) ctx, cancel := context.WithDeadline( context.Background(), clientDeadline) defer cancel() // Add Order order1 := pb.Order{Id: "101", Items:[]string{"iPhone XS", "Mac Book Pro"}, Destination:"San Jose, CA", Price:2300.00} res, addErr := client.AddOrder(ctx, &order1) if addErr != nil { got := status.Code(addErr) log.Printf("Error Occured -> addOrder : , %v:", got) } else { log.Print("AddOrder Response -> ", res.Value) }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.