func NewConn(addr string, config *Config, delegate ConnDelegate) *Conn {
	if !config.initialized {
		panic("Config must be created with NewConfig()")
	}
	return &Conn{
		addr: addr,
		config:   config,
		delegate: delegate,
		maxRdyCount:      2500,
		lastMsgTimestamp: time.Now().UnixNano(),
		cmdChan:         make(chan *Command),
		msgResponseChan: make(chan *msgResponse),
		exitChan:        make(chan int),
		drainReady:      make(chan int),
	}
}
NewConn returns a new Conn instance
package nsq
import (
	"bufio"
	"bytes"
	"compress/flate"
	"crypto/tls"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net"
	"strings"
	"sync"
	"sync/atomic"
	"time"
	"github.com/golang/snappy"
)
type IdentifyResponse struct {
	MaxRdyCount  int64 `json:"max_rdy_count"`
	TLSv1        bool  `json:"tls_v1"`
	Deflate      bool  `json:"deflate"`
	Snappy       bool  `json:"snappy"`
	AuthRequired bool  `json:"auth_required"`
}
type AuthResponse struct {
	Identity        string `json:"identity"`
	IdentityUrl     string `json:"identity_url"`
	PermissionCount int64  `json:"permission_count"`
}
type msgResponse struct {
	msg     *Message
	cmd     *Command
	success bool
	backoff bool
}
type Conn struct {
	messagesInFlight int64
	maxRdyCount      int64
	rdyCount         int64
	lastRdyCount     int64
	lastRdyTimestamp int64
	lastMsgTimestamp int64
	mtx sync.Mutex
	config *Config
	conn    *net.TCPConn
	tlsConn *tls.Conn
	addr    string
	delegate ConnDelegate
	logger   logger
	logLvl   LogLevel
	logFmt   string
	logGuard sync.RWMutex
	r io.Reader
	w io.Writer
	cmdChan         chan *Command
	msgResponseChan chan *msgResponse
	exitChan        chan int
	drainReady      chan int
	closeFlag int32
	stopper   sync.Once
	wg        sync.WaitGroup
	readLoopRunning int32
}