MCPcopy Create free account
hub / github.com/Sifchain/sifnode / RegisterQueryHandlerFromEndpoint

Function RegisterQueryHandlerFromEndpoint

x/margin/types/query.pb.gw.go:553–574  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

551// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
552// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
553func 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".

Callers

nothing calls this directly

Calls 2

RegisterQueryHandlerFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected