Merge pull request #4791 from orthogonous/master
Added some comments to the udp service so golint passes. Ref #4098pull/4792/head
commit
69803ddc6f
|
@ -33,6 +33,7 @@ const (
|
||||||
DefaultReadBuffer = 0
|
DefaultReadBuffer = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Config holds various configuration settings for the UDP listener.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Enabled bool `toml:"enabled"`
|
Enabled bool `toml:"enabled"`
|
||||||
BindAddress string `toml:"bind-address"`
|
BindAddress string `toml:"bind-address"`
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Maximum UDP packet size
|
// UDPBufferSize is the maximum UDP packet size
|
||||||
// see https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure
|
// see https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure
|
||||||
UDPBufferSize = 65536
|
UDPBufferSize = 65536
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ type Service struct {
|
||||||
statMap *expvar.Map
|
statMap *expvar.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewService returns a new instance of Service.
|
||||||
func NewService(c Config) *Service {
|
func NewService(c Config) *Service {
|
||||||
d := *c.WithDefaults()
|
d := *c.WithDefaults()
|
||||||
return &Service{
|
return &Service{
|
||||||
|
@ -75,6 +76,7 @@ func NewService(c Config) *Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open starts the service
|
||||||
func (s *Service) Open() (err error) {
|
func (s *Service) Open() (err error) {
|
||||||
// Configure expvar monitoring. It's OK to do this even if the service fails to open and
|
// Configure expvar monitoring. It's OK to do this even if the service fails to open and
|
||||||
// should be done before any data could arrive for the service.
|
// should be done before any data could arrive for the service.
|
||||||
|
@ -197,6 +199,7 @@ func (s *Service) parser() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the underlying listener.
|
||||||
func (s *Service) Close() error {
|
func (s *Service) Close() error {
|
||||||
if s.conn == nil {
|
if s.conn == nil {
|
||||||
return errors.New("Service already closed")
|
return errors.New("Service already closed")
|
||||||
|
@ -221,6 +224,7 @@ func (s *Service) SetLogger(l *log.Logger) {
|
||||||
s.Logger = l
|
s.Logger = l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Addr returns the listener's address
|
||||||
func (s *Service) Addr() net.Addr {
|
func (s *Service) Addr() net.Addr {
|
||||||
return s.addr
|
return s.addr
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue