Class: Hooks::Core::Builder
- Inherits:
-
Object
- Object
- Hooks::Core::Builder
- Defined in:
- lib/hooks/core/builder.rb
Overview
Main builder that orchestrates the webhook server setup
Instance Method Summary collapse
-
#build ⇒ Object
Build and return Rack-compatible application.
-
#initialize(config: nil, log: nil, **extra_components) ⇒ Builder
constructor
Initialize builder with configuration options.
Constructor Details
#initialize(config: nil, log: nil, **extra_components) ⇒ Builder
Initialize builder with configuration options
19 20 21 22 23 |
# File 'lib/hooks/core/builder.rb', line 19 def initialize(config: nil, log: nil, **extra_components) @log = log @config_input = config @extra_components = extra_components end |
Instance Method Details
#build ⇒ Object
Build and return Rack-compatible application
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hooks/core/builder.rb', line 28 def build # Load and validate configuration config = load_and_validate_config # Create logger unless a custom logger is provided if @log.nil? @log = LoggerFactory.create( log_level: config[:log_level], custom_logger: @custom_logger ) end @log.debug("global config loaded: #{config.inspect}") Hooks::Log.instance = @log # Register user-defined components globally Hooks::Core::GlobalComponents.register_extra_components(@extra_components) # Hydrate our Retryable instance Retry.setup!(log: @log) # Load all plugins at boot time load_plugins(config) # Load endpoints endpoints = load_endpoints(config) # Log startup @log.info "starting hooks server v#{Hooks::VERSION}" @log.info "config: #{endpoints.size} endpoints loaded" @log.info "environment: #{config[:environment]}" @log.info "available endpoints: #{endpoints.map { |e| e[:path] }.join(', ')}" # Build and return Grape API class Hooks::App::API.create( config:, endpoints:, log: @log ) end |