Class: Tasker::HandlersController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Tasker::HandlersController
- Defined in:
- app/controllers/tasker/handlers_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET /handlers - List all namespaces with intelligent caching.
-
#show ⇒ Object
GET /handlers/:namespace/:name - Show specific handler with dependency graph (cached).
-
#show_namespace ⇒ Object
GET /handlers/:namespace - List handlers in a specific namespace.
- #visit_step(step_name, steps_by_name, visited, order) ⇒ Object
Instance Method Details
#index ⇒ Object
GET /handlers - List all namespaces with intelligent caching
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/tasker/handlers_controller.rb', line 12 def index cache_key = "tasker:handlers:namespaces:#{handler_registry_version}" cached_data = @intelligent_cache.intelligent_fetch(cache_key, base_ttl: 2.minutes) do { namespaces: @handler_factory.registered_namespaces.map do |namespace| { name: namespace.to_s, handler_count: count_handlers_in_namespace(namespace) } end, total_namespaces: @handler_factory.registered_namespaces.size, generated_at: Time.current } end render json: cached_data, status: :ok end |
#show ⇒ Object
GET /handlers/:namespace/:name - Show specific handler with dependency graph (cached)
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/tasker/handlers_controller.rb', line 60 def show namespace_name = params[:namespace] handler_name = params[:name] version = params[:version] || '0.1.0' unless @handler_factory.registered_namespaces.include?(namespace_name.to_sym) render json: { error: 'Namespace not found' }, status: :not_found return end # Use intelligent caching for expensive handler discovery and dependency graph building cache_key = "tasker:handlers:show:#{namespace_name}:#{handler_name}:#{version}:#{handler_registry_version}" cached_result = @intelligent_cache.intelligent_fetch(cache_key, base_ttl: 2.minutes) do handler_data = find_handler_data(namespace_name, handler_name, version) if handler_data # Add dependency graph information (expensive operation) handler_data[:dependency_graph] = build_dependency_graph(handler_data[:step_templates]) { handler: handler_data, generated_at: Time.current, cache_key: cache_key } else { error: 'Handler not found in namespace', generated_at: Time.current } end end if cached_result[:error] render json: { error: cached_result[:error] }, status: :not_found else render json: cached_result, status: :ok end end |
#show_namespace ⇒ Object
GET /handlers/:namespace - List handlers in a specific namespace
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 |
# File 'app/controllers/tasker/handlers_controller.rb', line 32 def show_namespace namespace_name = params[:namespace] unless @handler_factory.registered_namespaces.include?(namespace_name.to_sym) render json: { error: 'Namespace not found' }, status: :not_found return end namespace_handlers = @handler_factory.list_handlers(namespace: namespace_name) handlers_data = namespace_handlers.map do |handler_name, versions| { name: handler_name, namespace: namespace_name, versions: versions.keys.sort, latest_version: versions.keys.max, handler_count: versions.size } end render json: { namespace: namespace_name, handlers: handlers_data, total_handlers: handlers_data.size }, status: :ok end |
#visit_step(step_name, steps_by_name, visited, order) ⇒ Object
197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'app/controllers/tasker/handlers_controller.rb', line 197 def visit_step(step_name, steps_by_name, visited, order) return if visited.include?(step_name) step = steps_by_name[step_name] return unless step # Visit dependencies first visit_step(step[:depends_on_step], steps_by_name, visited, order) if step[:depends_on_step] visited.add(step_name) order << step_name end |