go-health icon indicating copy to clipboard operation
go-health copied to clipboard

reduce ReachableDialer interface to easily allow grpc.Dial

Open sergeyt opened this issue 5 years ago • 0 comments

otherwise I need to write something

type grpcCon struct {
	conn *grpc.ClientConn
}

func (c *grpcCon) Close() error {
	return c.conn.Close()
}

func (c *grpcCon) LocalAddr() net.Addr {
	panic("not implemented")
}

func (c *grpcCon) RemoteAddr() net.Addr {
	panic("not implemented")
}

func (c *grpcCon) Read(b []byte) (n int, err error) {
	panic("not implemented")
}

func (c *grpcCon) Write(b []byte) (n int, err error) {
	panic("not implemented")
}

func (c *grpcCon) SetDeadline(t time.Time) error {
	panic("not implemented")
}

func (c *grpcCon) SetReadDeadline(t time.Time) error {
	panic("not implemented")
}

func (c *grpcCon) SetWriteDeadline(t time.Time) error {
	panic("not implemented")
}

func Dial(network, address string, timeout time.Duration) (net.Conn, error) {
	c, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithTimeout(timeout))
	if err != nil {
		return nil, err
	}
	return &grpcCon{c}, nil
}

sergeyt avatar Jan 12 '20 09:01 sergeyt