RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption)
| 551 | // RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but |
| 552 | // automatically dials to "endpoint" and closes the connection when "ctx" gets done. |
| 553 | func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { |
| 554 | conn, err := grpc.Dial(endpoint, opts...) |
| 555 | if err != nil { |
| 556 | return err |
| 557 | } |
| 558 | defer func() { |
| 559 | if err != nil { |
| 560 | if cerr := conn.Close(); cerr != nil { |
| 561 | grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) |
| 562 | } |
| 563 | return |
| 564 | } |
| 565 | go func() { |
| 566 | <-ctx.Done() |
| 567 | if cerr := conn.Close(); cerr != nil { |
| 568 | grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) |
| 569 | } |
| 570 | }() |
| 571 | }() |
| 572 | |
| 573 | return RegisterQueryHandler(ctx, mux, conn) |
| 574 | } |
| 575 | |
| 576 | // RegisterQueryHandler registers the http handlers for service Query to "mux". |
| 577 | // The handlers forward requests to the grpc endpoint over "conn". |
nothing calls this directly
no test coverage detected