Class: Ruact::Flight::Request
- Inherits:
-
Object
- Object
- Ruact::Flight::Request
- Defined in:
- lib/ruact/flight/request.rb
Overview
Central state for a single Flight render. Owns the ID allocator, chunk queues, and dedup tracker.
Instance Attribute Summary collapse
-
#bundler_config ⇒ Object
readonly
Returns the value of attribute bundler_config.
-
#completed_error_chunks ⇒ Object
readonly
E rows — flushed last.
-
#completed_import_chunks ⇒ Object
readonly
I rows — flushed first.
-
#completed_regular_chunks ⇒ Object
readonly
model rows.
-
#deferred_chunks ⇒ Object
readonly
{ id:, element:, delay: } — emitted after root row.
-
#next_chunk_id ⇒ Object
readonly
Returns the value of attribute next_chunk_id.
-
#on_as_json_warning ⇒ Object
readonly
Returns the value of attribute on_as_json_warning.
-
#pending_chunks ⇒ Object
readonly
Returns the value of attribute pending_chunks.
-
#root_model ⇒ Object
readonly
Returns the value of attribute root_model.
-
#strict_serialization ⇒ Object
readonly
Returns the value of attribute strict_serialization.
-
#written_objects ⇒ Object
readonly
object_id => “$L<hex>” reference (dedup).
Instance Method Summary collapse
- #allocate_id ⇒ Object
- #decrement_pending ⇒ Object
- #increment_pending ⇒ Object
-
#initialize(model, bundler_config, strict_serialization: false, on_as_json_warning: nil) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(model, bundler_config, strict_serialization: false, on_as_json_warning: nil) ⇒ Request
Returns a new instance of Request.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruact/flight/request.rb', line 21 def initialize(model, bundler_config, strict_serialization: false, on_as_json_warning: nil) @strict_serialization = strict_serialization @on_as_json_warning = on_as_json_warning @next_chunk_id = 0 @pending_chunks = 0 @bundler_config = bundler_config @completed_import_chunks = [] @completed_regular_chunks = [] @completed_error_chunks = [] @deferred_chunks = [] @written_objects = {}.compare_by_identity # Root task is always ID 0 @root_model = model end |
Instance Attribute Details
#bundler_config ⇒ Object (readonly)
Returns the value of attribute bundler_config.
18 19 20 |
# File 'lib/ruact/flight/request.rb', line 18 def bundler_config @bundler_config end |
#completed_error_chunks ⇒ Object (readonly)
E rows — flushed last
13 14 15 |
# File 'lib/ruact/flight/request.rb', line 13 def completed_error_chunks @completed_error_chunks end |
#completed_import_chunks ⇒ Object (readonly)
I rows — flushed first
9 10 11 |
# File 'lib/ruact/flight/request.rb', line 9 def completed_import_chunks @completed_import_chunks end |
#completed_regular_chunks ⇒ Object (readonly)
model rows
11 12 13 |
# File 'lib/ruact/flight/request.rb', line 11 def completed_regular_chunks @completed_regular_chunks end |
#deferred_chunks ⇒ Object (readonly)
{ id:, element:, delay: } — emitted after root row
15 16 17 |
# File 'lib/ruact/flight/request.rb', line 15 def deferred_chunks @deferred_chunks end |
#next_chunk_id ⇒ Object (readonly)
Returns the value of attribute next_chunk_id.
18 19 20 |
# File 'lib/ruact/flight/request.rb', line 18 def next_chunk_id @next_chunk_id end |
#on_as_json_warning ⇒ Object (readonly)
Returns the value of attribute on_as_json_warning.
18 19 20 |
# File 'lib/ruact/flight/request.rb', line 18 def on_as_json_warning @on_as_json_warning end |
#pending_chunks ⇒ Object (readonly)
Returns the value of attribute pending_chunks.
18 19 20 |
# File 'lib/ruact/flight/request.rb', line 18 def pending_chunks @pending_chunks end |
#root_model ⇒ Object (readonly)
Returns the value of attribute root_model.
18 19 20 |
# File 'lib/ruact/flight/request.rb', line 18 def root_model @root_model end |
#strict_serialization ⇒ Object (readonly)
Returns the value of attribute strict_serialization.
18 19 20 |
# File 'lib/ruact/flight/request.rb', line 18 def strict_serialization @strict_serialization end |
#written_objects ⇒ Object (readonly)
object_id => “$L<hex>” reference (dedup)
17 18 19 |
# File 'lib/ruact/flight/request.rb', line 17 def written_objects @written_objects end |
Instance Method Details
#allocate_id ⇒ Object
39 40 41 42 43 |
# File 'lib/ruact/flight/request.rb', line 39 def allocate_id id = @next_chunk_id @next_chunk_id += 1 id end |
#decrement_pending ⇒ Object
49 50 51 |
# File 'lib/ruact/flight/request.rb', line 49 def decrement_pending @pending_chunks -= 1 end |
#increment_pending ⇒ Object
45 46 47 |
# File 'lib/ruact/flight/request.rb', line 45 def increment_pending @pending_chunks += 1 end |