Class: PatientHttp::ProcessorObserver

Inherits:
Object
  • Object
show all
Defined in:
lib/patient_http/processor_observer.rb

Overview

Interface for observing request processing. A process observer can be registered with a Processor and receive events as requests are processed. Observers will run on the main processor thread and so should be lightweight and not do processing other than recording metrics or similar.

Instance Method Summary collapse

Instance Method Details

#capacity_exceededvoid

This method returns an undefined value.

Called when a request cannot be enqueued because the processor is at capacity.



24
25
# File 'lib/patient_http/processor_observer.rb', line 24

def capacity_exceeded
end

#request_end(request_task) ⇒ void

This method returns an undefined value.

Called when a request finishes processing.

Parameters:

  • request_task (RequestTask)

    the request task that ended



73
74
# File 'lib/patient_http/processor_observer.rb', line 73

def request_end(request_task)
end

#request_enqueued(request_task) ⇒ void

This method returns an undefined value.

Called when a request task is handed to the processor, before the task is visible to the reactor. The notification is guaranteed to arrive before request_start for the task, so observers can set up durable tracking (e.g. a crash-recovery registry entry) with no risk that the task completes first. If the processor does not accept the task, request_rejected is sent afterward. Unlike other notifications, an error raised here propagates from Processor#enqueue and rejects the task, so a failed tracking setup does not let the task be accepted as if it were durable.

Parameters:

  • request_task (RequestTask)

    the request task that was enqueued



39
40
# File 'lib/patient_http/processor_observer.rb', line 39

def request_enqueued(request_task)
end

#request_error(error) ⇒ void

This method returns an undefined value.

Called when a request encounters an error.

Parameters:

  • error (StandardError)

    the error that occurred



80
81
# File 'lib/patient_http/processor_observer.rb', line 80

def request_error(error)
end

#request_rejected(request_task) ⇒ void

This method returns an undefined value.

Called when a request task announced with request_enqueued was not accepted by the processor (not running or at capacity). Observers should tear down anything they set up in request_enqueued; the caller owns the request again once this is sent.

Parameters:

  • request_task (RequestTask)

    the request task that was rejected



49
50
# File 'lib/patient_http/processor_observer.rb', line 49

def request_rejected(request_task)
end

#request_requeued(request_task) ⇒ void

This method returns an undefined value.

Called when an incomplete request task was re-enqueued through its task handler (processor shutdown or reactor failure). The task handler's job system owns the request again once this is sent, so observers should tear down any durable tracking for the task.

Parameters:

  • request_task (RequestTask)

    the request task that was re-enqueued



59
60
# File 'lib/patient_http/processor_observer.rb', line 59

def request_requeued(request_task)
end

#request_start(request_task) ⇒ void

This method returns an undefined value.

Called when a request starts processing.

Parameters:

  • request_task (RequestTask)

    the request task that started



66
67
# File 'lib/patient_http/processor_observer.rb', line 66

def request_start(request_task)
end

#startvoid

This method returns an undefined value.

Called when the processor starts.



12
13
# File 'lib/patient_http/processor_observer.rb', line 12

def start
end

#stopvoid

This method returns an undefined value.

Called when the processor stops.



18
19
# File 'lib/patient_http/processor_observer.rb', line 18

def stop
end