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;
let config = RuntimeConfig::default();
Implementations
sourceimpl RuntimeConfig
impl RuntimeConfig
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 postgres(&self) -> &HashMap<Text, PostgresOpts>
pub fn postgres(&self) -> &HashMap<Text, PostgresOpts>
Get if a global postgres will be enabled.
sourcepub fn pubsub(&self) -> &HashMap<Text, PubSubOpts>
pub fn pubsub(&self) -> &HashMap<Text, PubSubOpts>
Get if a global pubsub will be enabled.
sourcepub fn http_client_builder(&self) -> &HashMap<Text, HttpClientOpts>
pub fn http_client_builder(&self) -> &HashMap<Text, HttpClientOpts>
Get if a global pubsub will be enabled.
sourcepub fn task_queue(&self) -> &HashMap<Text, TaskQueueOpts>
pub fn task_queue(&self) -> &HashMap<Text, TaskQueueOpts>
Get if a global task_queue will be enabled.
sourcepub fn gql_modules(&self) -> &HashMap<Text, GqlOpts>
pub fn gql_modules(&self) -> &HashMap<Text, GqlOpts>
Get the gql modules that will be enabled.
sourcepub fn python_paths(&self) -> Vec<Text>ⓘ
pub fn python_paths(&self) -> Vec<Text>ⓘ
Get all python paths 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_python(self, python: bool) -> Self
pub fn set_python(self, python: bool) -> Self
Sets whether to start with python.
Default: true
sourcepub fn add_default_redis(self) -> Self
pub fn add_default_redis(self) -> Self
Sets whether to start with a global Redis pool.
sourcepub fn add_named_redis<N: Into<Text>>(self, name: N, opts: RedisOpts) -> Self
pub fn add_named_redis<N: Into<Text>>(self, name: N, opts: RedisOpts) -> Self
Configure an additional named redis pool.
sourcepub fn add_default_postgres(self) -> Self
pub fn add_default_postgres(self) -> Self
Sets whether to start with a global Postgres pool.
sourcepub fn add_named_postgres<N: Into<Text>>(
self,
name: N,
opts: PostgresOpts
) -> Self
pub fn add_named_postgres<N: Into<Text>>(
self,
name: N,
opts: PostgresOpts
) -> Self
Configure an additional named Postgres pool.
sourcepub fn add_default_pubsub(self) -> Self
pub fn add_default_pubsub(self) -> Self
Sets whether to start with a global PubSubClient.
sourcepub fn add_named_pubsub<N: Into<Text>>(self, name: N, config: PubSubOpts) -> Self
pub fn add_named_pubsub<N: Into<Text>>(self, name: N, config: PubSubOpts) -> Self
Sets whether to start with a global PubSubClient.
sourcepub fn add_http_client(self) -> Self
pub fn add_http_client(self) -> Self
Add global HTTP Client
sourcepub fn add_named_http_client<N: Into<Text>>(
self,
name: N,
opts: HttpClientOpts
) -> Self
pub fn add_named_http_client<N: Into<Text>>(
self,
name: N,
opts: HttpClientOpts
) -> Self
Add named HTTP Client
sourcepub fn add_default_task_queue(self) -> Self
pub fn add_default_task_queue(self) -> Self
Sets whether to start with a global TaskQueue.
sourcepub fn add_named_task_queue<N: Into<Text>>(
self,
name: N,
opts: TaskQueueOpts
) -> Self
pub fn add_named_task_queue<N: Into<Text>>(
self,
name: N,
opts: TaskQueueOpts
) -> Self
Sets whether to start with a global TaskQueue.
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 add_gql_schema<T: Into<Text>>(self, schema_module_path: T) -> Self
pub fn add_gql_schema<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 add_gql_schema_named<N: Into<Text>>(self, name: N, opts: GqlOpts) -> Self
pub fn add_gql_schema_named<N: Into<Text>>(self, name: N, opts: GqlOpts) -> Self
If provided, will load an additional GraphQl configuration from the 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