func testRequest(t *testing.T, request siesta.Request, expected []byte) { sizing := siesta.NewSizingEncoder() request.Write(sizing) bytes := make([]byte, sizing.Size()) encoder := siesta.NewBinaryEncoder(bytes) request.Write(encoder) assert(t, bytes, expected) }
func (s *Selector) send(correlationID int32, conn *net.TCPConn, request siesta.Request) error { writer := siesta.NewRequestHeader(correlationID, s.config.ClientID, request) bytes := make([]byte, writer.Size()) encoder := siesta.NewBinaryEncoder(bytes) writer.Write(encoder) conn.SetWriteDeadline(time.Now().Add(s.config.WriteTimeout)) _, err := conn.Write(bytes) return err }