Deflate compression is awful, imo. Why don't u use lz4 or something similar (may be custom)?
My apologies I was not exactly clear:
Looking at your client.go & server.go it appears they both generate and store a var net.Conn privately within the clientHandler and serverHandler methods. It is the net.Conn object I need to supply to gorpc as my program needs to startup an rpc server/client on an already established TLS socket by passing into the rpc client/server the existing net.Conn objects my TLS socket has already generated.
c := &gorpc.Client{
Addr: "rpc.server.addr:12345",
Dial: func(c *Client) (conn net.Conn, err error) {
if conn, err = net.Dial("tcp", c.Addr); err != nil {
return nil, err
}
return setupTLSAndOtherStuffYouWantForClient(conn)
},
}
// setup listener before server start
ln, err := net.Listen("tcp", ":12345")
s := &gorpc.Server{
Accept: func(s *gorpc.Server) (conn net.Conn, err error) {
if conn, err = ln.Accept(); err != nil {
return nil, err
}
return setupTLSAndOtherStuffYouWantForServer(conn)
},
}
Anyway, the final API I came up with looks like this:
Constants
Variables
func CompressBlock(src, dst []byte, soffset int) (int, error)
func CompressBlockBound(n int) int
func CompressBlockHC(src, dst []byte, soffset int) (int, error)
func UncompressBlock(src, dst []byte, di int) (int, error)
type Header
type Reader
func NewReader(src io.Reader) *Reader
func (z *Reader) Read(buf []byte) (n int, err error)
func (z *Reader) Reset(r io.Reader)
func (z *Reader) WriteTo(w io.Writer) (n int64, err error)
type Writer
func NewWriter(dst io.Writer) *Writer
func (z *Writer) Close() error
func (z *Writer) Flush() error
func (z *Writer) ReadFrom(r io.Reader) (n int64, err error)
func (z *Writer) Reset(w io.Writer)
func (z *Writer) Write(buf []byte) (n int, err error)
Hopefully you will try it out when I release it (should be very soon...).
These plans became reality in master repository - now the Client provides Dial callback and the server provides Listener interface. Arbitrary custom transport can be easily implemented with these additions to gorpc.