code: func New(config *Config) (*Agent, error) {
  	if err := config.validate(); err != nil {
  		return nil, err
  	}
  
  	a := &Agent{
  		config:           config,
  		sessionq:         make(chan sessionOperation),
  		started:          make(chan struct{}),
  		leaving:          make(chan struct{}),
  		left:             make(chan struct{}),
  		stopped:          make(chan struct{}),
  		closed:           make(chan struct{}),
  		ready:            make(chan struct{}),
  		nodeUpdatePeriod: nodeUpdatePeriod,
  	}
  
  	a.worker = newWorker(config.DB, config.Executor, a)
  	return a, nil
  }
docs: // New returns a new agent, ready for task dispatch.