Class: Banzai::Filter::TimeoutTextPipelineFilter
- Inherits:
-
HTML::Pipeline::TextFilter
- Object
- HTML::Pipeline::TextFilter
- Banzai::Filter::TimeoutTextPipelineFilter
- Defined in:
- lib/banzai/filter/timeout_text_pipeline_filter.rb
Overview
Text Filter that wraps a filter in a Gitlab::RenderTimeout. This way partial results can be returned, and the entire pipeline is not killed.
This should not be used for any filter that must be allowed to complete, like a ‘ReferenceRedactorFilter`
Direct Known Subclasses
Constant Summary collapse
- RENDER_TIMEOUT =
10.seconds
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/banzai/filter/timeout_text_pipeline_filter.rb', line 15 def call Gitlab::RenderTimeout.timeout(foreground: RENDER_TIMEOUT) { call_with_timeout } rescue Timeout::Error => e class_name = self.class.name.demodulize Gitlab::ErrorTracking.track_exception(e, project_id: context[:project]&.id, class_name: class_name) # we've timed out, but some work may have already been completed, # so go ahead and return the text @text end |
#call_with_timeout ⇒ Object
26 27 28 |
# File 'lib/banzai/filter/timeout_text_pipeline_filter.rb', line 26 def call_with_timeout raise NotImplementedError end |