Inline init as it's only called in one place
parent
9bbb2b0911
commit
bfda034655
|
@ -104,13 +104,6 @@ func (p *Poller) setPrev(pl List) {
|
||||||
// that it's been administratively disabled or the underlying
|
// that it's been administratively disabled or the underlying
|
||||||
// OS is not implemented.
|
// OS is not implemented.
|
||||||
func (p *Poller) init() error {
|
func (p *Poller) init() error {
|
||||||
p.initOnce.Do(func() {
|
|
||||||
p.initErr = p.initWithErr()
|
|
||||||
})
|
|
||||||
return p.initErr
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Poller) initWithErr() error {
|
|
||||||
if debugDisablePortlist() {
|
if debugDisablePortlist() {
|
||||||
return errors.New("portlist disabled by envknob")
|
return errors.New("portlist disabled by envknob")
|
||||||
}
|
}
|
||||||
|
@ -169,11 +162,11 @@ func (p *Poller) send(ctx context.Context, pl List, plErr error) (sent bool) {
|
||||||
//
|
//
|
||||||
// Run may only be called once.
|
// Run may only be called once.
|
||||||
func (p *Poller) Run(ctx context.Context) (chan Update, error) {
|
func (p *Poller) Run(ctx context.Context) (chan Update, error) {
|
||||||
if p.os == nil {
|
p.initOnce.Do(func() {
|
||||||
err := p.init()
|
p.initErr = p.init()
|
||||||
if err != nil {
|
})
|
||||||
return nil, fmt.Errorf("error initializing poller: %w", err)
|
if p.initErr != nil {
|
||||||
}
|
return nil, fmt.Errorf("error initializing poller: %w", p.initErr)
|
||||||
}
|
}
|
||||||
tick := time.NewTicker(p.Interval)
|
tick := time.NewTicker(p.Interval)
|
||||||
defer tick.Stop()
|
defer tick.Stop()
|
||||||
|
|
Loading…
Reference in New Issue