func (l *Listener) Stop() {
	l.probes.SetReady(false)
	l.probes.SetAlive(false)
	close(l.stop)
	l.wg.Wait()
	l.nc.Close()
	l.probes.Close()
}
Stop shuts down a running listener. It should be called exactly
once for every Listener instance.
package listener
import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"net"
	"net/http"
	"os"
	"strconv"
	"sync"
	"time"
	"github.com/jumptrading/influx-spout/v2/batch"
	"github.com/jumptrading/influx-spout/v2/batchsplitter"
	"github.com/jumptrading/influx-spout/v2/config"
	"github.com/jumptrading/influx-spout/v2/influx"
	"github.com/jumptrading/influx-spout/v2/probes"
	"github.com/jumptrading/influx-spout/v2/stats"
	nats "github.com/nats-io/nats.go"
)
const (
	statReceived          = "received"
	statSent              = "sent"
	statReadErrors        = "read_errors"
	statFailedNATSPublish = "failed_nats_publish"
	maxUDPDatagramSize = 65536
)
func StartListener(c *config.Config) (_ *Listener, err error) {
	listener, err := newListener(c)
	if err != nil {
		return nil, err
	}
	defer func() {
		if err != nil {
			listener.Stop()
		}
	}()
	sc, err := listener.setupUDP(int(c.ReadBufferSize.Bytes()))
	if err != nil {
		return nil, err
	}
	listener.wg.Add(2)
	go listener.startStatistician()
	go listener.listenUDP(sc)
	log.Printf("UDP listener publishing to [%s] at %s", c.NATSSubject[0], c.NATSAddress)
	return listener, nil
}
func StartHTTPListener(c *config.Config) (*Listener, error) {
	listener, err := newListener(c)
	if err != nil {
		return nil, err
	}
	server := listener.setupHTTP()
	listener.wg.Add(2)
	go listener.startStatistician()
	go listener.listenHTTP(server)
	log.Printf("HTTP listener publishing to [%s] at %s", c.NATSSubject[0], c.NATSAddress)
	return listener, nil
}
type Listener struct {
	c      *config.Config
	nc     *nats.Conn
	stats  *stats.Stats
	probes probes.Probes
	batch *batch.Batch
	wg   sync.WaitGroup
	stop chan struct{}
	mu   sync.Mutex  
}