New creates a new Server instance with the given configuration
(config *Config, deps *Dependencies, opts ...Option)
| 53 | |
| 54 | // New creates a new Server instance with the given configuration |
| 55 | func New(config *Config, deps *Dependencies, opts ...Option) (*Server, error) { |
| 56 | if config == nil { |
| 57 | config = DefaultConfig() |
| 58 | } |
| 59 | |
| 60 | if deps == nil { |
| 61 | return nil, errors.New("dependencies cannot be nil") |
| 62 | } |
| 63 | |
| 64 | // Set Gin mode based on config |
| 65 | if config.Mode == "production" { |
| 66 | gin.SetMode(gin.ReleaseMode) |
| 67 | } else { |
| 68 | gin.SetMode(gin.DebugMode) |
| 69 | } |
| 70 | |
| 71 | s := &Server{ |
| 72 | config: config, |
| 73 | router: gin.New(), |
| 74 | store: deps.Store, |
| 75 | deps: deps, |
| 76 | agentRegistry: handlers.NewRuntimeAgentRegistry(), |
| 77 | } |
| 78 | |
| 79 | // Initialize auth and observability |
| 80 | s.initializeAuthAndObservability() |
| 81 | |
| 82 | // Initialize A2A protocol support |
| 83 | s.initializeA2A() |
| 84 | |
| 85 | // Apply options |
| 86 | for _, opt := range opts { |
| 87 | opt(s) |
| 88 | } |
| 89 | |
| 90 | // Setup middleware |
| 91 | s.setupMiddleware() |
| 92 | |
| 93 | // Setup routes |
| 94 | s.setupRoutes() |
| 95 | |
| 96 | return s, nil |
| 97 | } |
| 98 | |
| 99 | // initializeAuthAndObservability initializes authentication and observability components |
| 100 | func (s *Server) initializeAuthAndObservability() { |