write raw data

This commit is contained in:
Josh Baker 2016-09-22 13:11:27 -07:00
parent 67c21aa488
commit 4380ff9799
1 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,8 @@ type Conn interface {
WriteArray(count int)
// WriteNull writes a null to the client
WriteNull()
// WriteRaw writes raw data to the client.
WriteRaw(data []byte)
// Context returns a user-defined context
Context() interface{}
// SetContext sets a user-defined context
@ -259,6 +261,7 @@ func (c *conn) WriteInt(num int) { c.wr.WriteInt(num) }
func (c *conn) WriteError(msg string) { c.wr.WriteError(msg) }
func (c *conn) WriteArray(count int) { c.wr.WriteArray(count) }
func (c *conn) WriteNull() { c.wr.WriteNull() }
func (c *conn) WriteRaw(data []byte) { c.wr.WriteRaw(data) }
func (c *conn) RemoteAddr() string { return c.addr }
// DetachedConn represents a connection that is detached from the server
@ -405,6 +408,11 @@ func (w *Writer) WriteInt(num int) {
w.b = append(w.b, '\r', '\n')
}
// WriteRaw writes raw data to the client.
func (w *Writer) WriteRaw(data []byte) {
w.b = append(w.b, data...)
}
// Reader represent a reader for RESP or telnet commands.
type Reader struct {
rd *bufio.Reader