github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/rpc/inproc.go (about)

     1  package rpc
     2  
     3  import (
     4  	"context"
     5  	"net"
     6  )
     7  
     8  // NewInProcClient attaches an in-process connection to the given RPC server.
     9  func DialInProc(handler *Server) *Client {
    10  	initctx := context.Background()
    11  	c, _ := newClient(initctx, func(context.Context) (net.Conn, error) {
    12  		p1, p2 := net.Pipe()
    13  		go handler.ServeCodec(NewJSONCodec(p1), OptionMethodInvocation|OptionSubscriptions)
    14  		return p2, nil
    15  	})
    16  	return c
    17  }