Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
listener: Remove unused state metrics
Browse files Browse the repository at this point in the history
... and added some missing docstrings for public types/methods.
  • Loading branch information
mjs committed Apr 4, 2018
1 parent 4c5d1a8 commit 0efbc53
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func StartListener(c *config.Config) (_ *Listener, err error) {
go listener.listenUDP(sc)

log.Printf("UDP listener publishing to [%s] at %s", c.NATSSubject[0], c.NATSAddress)
listener.notifyState("ready")

return listener, nil
}
Expand All @@ -93,11 +92,13 @@ func StartHTTPListener(c *config.Config) (*Listener, error) {
go listener.listenHTTP(server)

log.Printf("HTTP listener publishing to [%s] at %s", c.NATSSubject[0], c.NATSAddress)
listener.notifyState("ready")

return listener, nil
}

// Listener accepts measurements in InfluxDB Line Protocol format via
// UDP or HTTP, batches them and then publishes them to a NATS
// subject.
type Listener struct {
c *config.Config
nc *nats.Conn
Expand All @@ -118,6 +119,8 @@ func (l *Listener) Ready() <-chan struct{} {
return l.ready
}

// Stop shuts down a running listener. It should be called exactly
// once for every Listener instance.
func (l *Listener) Stop() {
close(l.stop)
l.wg.Wait()
Expand Down Expand Up @@ -147,7 +150,6 @@ func newListener(c *config.Config) (*Listener, error) {
nc.Opts.MaxReconnect = -1
l.nc = nc

l.notifyState("boot")
return l, nil
}

Expand Down Expand Up @@ -302,19 +304,6 @@ func (l *Listener) startStatistician() {
}
}

var notifyLine = lineformatter.New("spout_mon", nil, "type", "state", "pid")

func (l *Listener) notifyState(state string) {
line := notifyLine.Format(nil, "listener", state, os.Getpid())
if err := l.nc.Publish(l.c.NATSSubjectMonitor, line); err != nil {
l.handleNatsError(err)
return
}
if err := l.nc.Flush(); err != nil {
l.handleNatsError(err)
}
}

type timeouter interface {
Timeout() bool
}
Expand Down

0 comments on commit 0efbc53

Please sign in to comment.