Struct puff_rs::runtime::RuntimeConfig
source · pub struct RuntimeConfig { /* private fields */ }Expand description
Controls options for running puff tasks.
See the Readme’s Architecture Section for more information about the multi-threaded tokio runtime, coroutine threads, and blocking threads to get a better understanding of these options. The default options should be sane for most applications.
Examples
use puff_rs::runtime::{RuntimeConfig, Strategy};
let config = RuntimeConfig::default().set_strategy(Strategy::Random);Implementations
sourceimpl RuntimeConfig
impl RuntimeConfig
sourcepub fn strategy(&self) -> Strategy
pub fn strategy(&self) -> Strategy
Get the current strategy.
See Strategy for more information about choosing a strategy.
sourcepub fn max_blocking_threads(&self) -> usize
pub fn max_blocking_threads(&self) -> usize
Get the current max_blocking_threads
This is the number of threads that can be spawned for blocking tasks.
sourcepub fn tokio_worker_threads(&self) -> usize
pub fn tokio_worker_threads(&self) -> usize
Get the current tokio_worker_threads
This is the number of threads that Tokio will use to execute things like DB queries, HTTP Servers, and IO. These threads can share and distribute tasks amongst themselves.
sourcepub fn blocking_task_keep_alive(&self) -> Duration
pub fn blocking_task_keep_alive(&self) -> Duration
Get the current blocking_task_keep_alive
The maximum time a blocking thread can keep executing before being killed.
pub fn python(&self) -> bool
sourcepub fn redis_pool_size(&self) -> u32
pub fn redis_pool_size(&self) -> u32
Get if a global redis will be enabled.
sourcepub fn postgres_pool_size(&self) -> u32
pub fn postgres_pool_size(&self) -> u32
Get if a global postgres will be enabled.
sourcepub fn http_client_builder(&self) -> ClientBuilder
pub fn http_client_builder(&self) -> ClientBuilder
Get if a global pubsub will be enabled.
sourcepub fn task_queue(&self) -> bool
pub fn task_queue(&self) -> bool
Get if a global task_queue will be enabled.
sourcepub fn task_queue_max_concurrent_tasks(&self) -> usize
pub fn task_queue_max_concurrent_tasks(&self) -> usize
Get maximum number of concurrent tasks to pull from queue.
sourcepub fn gql_module(&self) -> Option<Text>
pub fn gql_module(&self) -> Option<Text>
Get the gql module that will be enabled.
sourcepub fn python_paths(&self) -> Vec<Text>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn python_paths(&self) -> Vec<Text>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get all python paths to add to environment.
sourcepub fn env_vars(&self) -> Vec<(Text, Text)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn env_vars(&self) -> Vec<(Text, Text)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get all env vars to add to environment.
sourcepub fn apply_env_vars(&self)
pub fn apply_env_vars(&self)
Apply env vars to add to environment.
sourcepub fn global_state(&self) -> PyResult<PyObject>
pub fn global_state(&self) -> PyResult<PyObject>
Get the global Python object
sourcepub fn set_tokio_worker_threads(self, tokio_worker_threads: usize) -> Self
pub fn set_tokio_worker_threads(self, tokio_worker_threads: usize) -> Self
Set the tokio_worker_threads for coroutines.
Default: num_cpus
sourcepub fn set_blocking_task_keep_alive(
self,
blocking_task_keep_alive: Duration
) -> Self
pub fn set_blocking_task_keep_alive(
self,
blocking_task_keep_alive: Duration
) -> Self
Set the blocking_task_keep_alive.
Default: 30 seconds
sourcepub fn set_max_blocking_threads(self, max_blocking_threads: usize) -> Self
pub fn set_max_blocking_threads(self, max_blocking_threads: usize) -> Self
Set the max_blocking_threads.
Default: 1024
sourcepub fn set_strategy(self, strategy: Strategy) -> Self
pub fn set_strategy(self, strategy: Strategy) -> Self
Sets the strategy for distributing tasks onto a coroutine thread.
Default: Strategy::RoundRobin
sourcepub fn set_python(self, python: bool) -> Self
pub fn set_python(self, python: bool) -> Self
Sets whether to start with python.
Default: true
sourcepub fn set_redis(self, redis: bool) -> Self
pub fn set_redis(self, redis: bool) -> Self
Sets whether to start with a global Redis pool.
Default: false
sourcepub fn set_postgres(self, postgres: bool) -> Self
pub fn set_postgres(self, postgres: bool) -> Self
Sets whether to start with a global Postgres pool.
Default: false
sourcepub fn set_postgres_pool_size(self, pool_size: u32) -> Self
pub fn set_postgres_pool_size(self, pool_size: u32) -> Self
Sets the max size of postgres pool. Also enables postgres if not enabled already.
Default: 10
sourcepub fn set_redis_pool_size(self, pool_size: u32) -> Self
pub fn set_redis_pool_size(self, pool_size: u32) -> Self
Sets the max size of redis pool. Also enables redis if not enabled already.
Default: 10
sourcepub fn set_pubsub(self, pubsub: bool) -> Self
pub fn set_pubsub(self, pubsub: bool) -> Self
Sets whether to start with a global PubSubClient.
Default: false
sourcepub fn set_http_client_builder_fn<F: Fn() -> ClientBuilder + 'static>(
self,
builder: F
) -> Self
pub fn set_http_client_builder_fn<F: Fn() -> ClientBuilder + 'static>(
self,
builder: F
) -> Self
Set a constructor function for the HTTP ClientBuilder
Default: ClientBuilder::new
sourcepub fn set_task_queue(self, task_queue: bool) -> Self
pub fn set_task_queue(self, task_queue: bool) -> Self
Sets whether to start with a global TaskQueue.
Default: false
sourcepub fn set_task_queue_concurrent_tasks(self, max_workers: usize) -> Self
pub fn set_task_queue_concurrent_tasks(self, max_workers: usize) -> Self
Sets the number of tasks to run concurrently from the queue. Sets task_queue to true.
Default: num_cpu * 4
sourcepub fn set_greenlets(self, greenlets: bool) -> Self
pub fn set_greenlets(self, greenlets: bool) -> Self
Sets whether to use greenlets when executing python.
Default: true
sourcepub fn set_asyncio(self, asyncio: bool) -> Self
pub fn set_asyncio(self, asyncio: bool) -> Self
Sets whether to use greenlets when executing python.
Default: false
sourcepub fn set_gql_schema_class<T: Into<Text>>(self, schema_module_path: T) -> Self
pub fn set_gql_schema_class<T: Into<Text>>(self, schema_module_path: T) -> Self
If provided, will load the GraphQl configuration from the module path to the Schema.
Default: None
sourcepub fn set_global_state_fn<F: Fn(Python<'_>) -> PyResult<PyObject> + Send + Sync + 'static>(
self,
f: F
) -> Self
pub fn set_global_state_fn<F: Fn(Python<'_>) -> PyResult<PyObject> + Send + Sync + 'static>(
self,
f: F
) -> Self
Run a function in a python context and set the result as the global state for Python.
Default: None
sourcepub fn add_env<K: Into<Text>, V: Into<Text>>(self, k: K, v: V) -> Self
pub fn add_env<K: Into<Text>, V: Into<Text>>(self, k: K, v: V) -> Self
Add the current directory to the PYTHONPATH
sourcepub fn add_cwd_to_python_path(self) -> Self
pub fn add_cwd_to_python_path(self) -> Self
Add the current directory to the PYTHONPATH
sourcepub fn add_python_path<T: Into<Text>>(self, path: T) -> Self
pub fn add_python_path<T: Into<Text>>(self, path: T) -> Self
Add the relative directory to the PYTHONPATH
Trait Implementations
sourceimpl Clone for RuntimeConfig
impl Clone for RuntimeConfig
sourcefn clone(&self) -> RuntimeConfig
fn clone(&self) -> RuntimeConfig
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more