Exemple #1
0
func NewServer(opt ...ServerOption) *Server {
	var err error
	s := new(Server)

	if s.r, err = rpc.NewRouter(nil, nil); err != nil {
		return nil
	}

	s.ln = "grpc-api-listener"
	s.mf = rpc.NewMsgHeaderFactory(pbt.NewMsgProtobufFactory())

	return s
}
Exemple #2
0
func Dial(target string, opts ...DialOption) (*ClientConn, error) {
	var err error
	cc := new(ClientConn)

	if cc.r, err = rpc.NewRouter(nil, nil); err != nil {
		return nil, err
	}

	cc.r.Run()

	cc.cn = "grpc-api-connector"
	cc.mf = rpc.NewMsgHeaderFactory(pbt.NewMsgProtobufFactory())

	if err = cc.r.Dial(cc.cn, "tcp", target, cc.mf); err != nil {
		cc.r.Stop()
		return nil, err
	}

	return cc, nil
}