Class: Html2rss::RequestService::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/request_service/strategy.rb

Overview

Defines the guarded request interface for every strategy adapter.

#execute always runs timeout check → budget/policy preflight → #fetch → ResponseGuard postflight so new adapters cannot skip shared controls.

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ Strategy

Returns a new instance of Strategy.

Parameters:

  • ctx (Context)

    the context for the request



13
14
15
# File 'lib/html2rss/request_service/strategy.rb', line 13

def initialize(ctx)
  @ctx = ctx
end

Instance Method Details

#executeResponse

Executes the request through the shared preflight/postflight path.

Returns:

  • (Response)

    the response from the strategy

Raises:

  • (NotImplementedError)

    if the subclass does not implement #fetch



22
23
24
25
26
27
28
29
# File 'lib/html2rss/request_service/strategy.rb', line 22

def execute
  check_timeout!
  response = perform_execute
  postflight!(response, response_guard:)
  response
rescue StandardError => error
  handle_error(error)
end