func NewAgent(config *Config, logOutput io.Writer) (*Agent, error) {
	a := &Agent{
		config:     config,
		logger:     log.New(logOutput, "", log.LstdFlags|log.Lmicroseconds),
		logOutput:  logOutput,
		shutdownCh: make(chan struct{}),
	}

	if err := a.setupConsul(config.Consul); err != nil {
		return nil, fmt.Errorf("Failed to initialize Consul client: %v", err)
	}
	if err := a.setupServer(); err != nil {
		return nil, err
	}
	if err := a.setupClient(); err != nil {
		return nil, err
	}
	if a.client == nil && a.server == nil {
		return nil, fmt.Errorf("must have at least client or server mode enabled")
	}

	return a, nil
}
// NewAgent is used to create a new agent with the given configuration
NewAgent is used to create a new agent with the given configuration
// NewAgent is used to create a new agent with the given configuration
func NewAgent(config *Config, logOutput io.Writer) (*Agent, error) {
	a := &Agent{
		config:     config,
		logger:     log.New(logOutput, "", log.LstdFlags|log.Lmicroseconds),
		logOutput:  logOutput,
		shutdownCh: make(chan struct{}),
	}
	if err := a.setupConsul(config.Consul); err != nil {
		return nil, fmt.Errorf("Failed to initialize Consul client: %v", err)
	}
	if err := a.setupServer(); err != nil {
		return nil, err
	}
	if err := a.setupClient(); err != nil {
		return nil, err
	}
	if a.client == nil && a.server == nil {
		return nil, fmt.Errorf("must have at least client or server mode enabled")
	}
	return a, nil
}
func NewAgent ( config * Config , logOutput io . Writer ) ( * Agent , error ) { a := & Agent { config : config , logger : log . New ( logOutput , " " , log . LstdFlags | log . Lmicroseconds ) , logOutput : logOutput , shutdownCh : make ( chan struct { } ) , } if err := a . setupConsul ( config . Consul ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := a . setupServer ( ) ; err != nil { return nil , err } if err := a . setupClient ( ) ; err != nil { return nil , err } if a . client == nil && a . server == nil { return nil , fmt . Errorf ( " " ) } return a , nil }
NewAgent is used to create a new agent with the given configuration
NewAgent is used to create a new agent with the given configuration