func New(config *Config, logger log.Logger) (*Agent, error) {
	config = DefaultConfig().Merge(config)
	if logger == nil {
		return nil, errors.New("missing logger")
	}
	a := &Agent{
		config:     config,
		logger:     logger.WithName("agent"),
		shutdownCh: make(chan struct{}),
	}
	if err := a.setupRPCConnection(); err != nil {
		return nil, err
	}
	if err := a.setupServer(); err != nil {
		return nil, err
	}
	if err := a.setupClient(); err != nil {
		if a.server != nil {
			a.server.Shutdown()
		}
		return nil, err
	}
	if a.client == nil && a.server == nil {
		return nil, errors.New("must have either client or server mode enabled")
	}
	if err := a.setupHTTPServer(); err != nil {
		a.Shutdown()
		return nil, fmt.Errorf("could not initialize http server: %s", err)
	}
	return a, nil
}
New creates a new Drago agent from the configuration,
potentially returning an error
package agent
import (
	"errors"
	"fmt"
	stdhttp "net/http"
	"sync"
	handler "github.com/seashell/drago/agent/adapter/http"
	middleware "github.com/seashell/drago/agent/adapter/http/middleware"
	conn "github.com/seashell/drago/agent/conn"
	client "github.com/seashell/drago/client"
	drago "github.com/seashell/drago/drago"
	config "github.com/seashell/drago/drago/structs/config"
	http "github.com/seashell/drago/pkg/http"
	log "github.com/seashell/drago/pkg/log"
)
type Agent struct {
	config *Config
	logger log.Logger
	rpcConn conn.RPCConnection
	server *drago.Server
	client *client.Client
	httpServer *http.Server
	shutdown     bool
	shutdownCh   chan struct{}
	shutdownLock sync.Mutex
}