Class: GraphQL::Query::ParallelExecution
- Inherits:
-
BaseExecution
- Object
- BaseExecution
- GraphQL::Query::ParallelExecution
- Defined in:
- lib/graphql/query/parallel_execution.rb
Overview
Utilize Celluloid::Future to run field resolution in parallel.
Defined Under Namespace
Classes: ExecutionPool, ExecutionWorker, FieldResolution, FragmentSpreadResolution, FutureFieldResolution, InlineFragmentResolution, OperationResolution, SelectionResolution
Instance Method Summary collapse
- #async(block) ⇒ Object
- #has_futures? ⇒ Boolean
-
#initialize ⇒ ParallelExecution
constructor
A new instance of ParallelExecution.
- #pool ⇒ Object
Methods inherited from BaseExecution
#execute, #field_resolution, #fragment_spread_resolution, #inline_fragment_resolution, #operation_resolution, #selection_resolution
Constructor Details
#initialize ⇒ ParallelExecution
5 6 7 8 9 |
# File 'lib/graphql/query/parallel_execution.rb', line 5 def initialize # Why isn't `require "celluloid/current"` enough here? Celluloid.boot unless Celluloid.running? @has_futures = false end |
Instance Method Details
#async(block) ⇒ Object
16 17 18 19 |
# File 'lib/graphql/query/parallel_execution.rb', line 16 def async(block) @has_futures ||= true pool.future.resolve(block) end |
#has_futures? ⇒ Boolean
21 22 23 |
# File 'lib/graphql/query/parallel_execution.rb', line 21 def has_futures? @has_futures end |
#pool ⇒ Object
11 12 13 14 |
# File 'lib/graphql/query/parallel_execution.rb', line 11 def pool @pool ||= ExecutionPool.run! @pool[:execution_worker_pool] end |