pynenc_mongo.builder¶
Mongo plugin builder extensions for Pynenc.
This module contains the Mongo-specific builder methods that will be moved to the pynenc-mongo plugin package.
Key components:
MongoBuilderPlugin: Plugin class that registers Mongo methods
mongo(): Main method for full Mongo stack configuration
mongo_client_data_store(): Mongo-specific client data store method
mongo_trigger(): Mongo-specific trigger system method
Module Contents¶
Classes¶
Mongo plugin that provides builder methods for Mongo backend configuration. |
Functions¶
Configure Mongo components for the Pynenc application. |
|
Configure Mongo-based client data store. |
|
Configure Mongo-based trigger system. |
|
Validate Mongo plugin configuration. |
API¶
- class pynenc_mongo.builder.MongoBuilderPlugin[source]¶
Mongo plugin that provides builder methods for Mongo backend configuration.
- static register_builder_methods(builder_class: type[pynenc.builder.PynencBuilder]) None[source]¶
Register Mongo builder methods with PynencBuilder.
This method is called automatically when the plugin is discovered via entry points.
- Parameters:
builder_class (type[“PynencBuilder”]) – The PynencBuilder class to extend
- pynenc_mongo.builder.mongo(builder: pynenc.builder.PynencBuilder, url: str | None = None, db: str | None = None, host: str | None = None, port: int | None = None, username: str | None = None, password: str | None = None, auth_source: str | None = None) pynenc.builder.PynencBuilder[source]¶
Configure Mongo components for the Pynenc application.
This sets up all Mongo-related components (orchestrator, broker, state backend, and argument cache) to use Mongo as their backend.
- Parameters:
builder (PynencBuilder) – The PynencBuilder instance
url (str | None) – The Mongo URL to connect to. If specified, overrides all other connection parameters including host, port, db, username, password, and auth_source.
db (str | None) – The Mongo database name to use. Only valid when url is not provided. If url is provided, the database should be specified in the URL itself.
host (str | None) – The Mongo host to connect to. Ignored if url is provided.
port (int | None) – The Mongo port to connect to. Ignored if url is provided.
username (str | None) – The Mongo username to use. Ignored if url is provided.
password (str | None) – The Mongo password to use. Ignored if url is provided.
auth_source (str | None) – The Mongo authentication source database. Ignored if url is provided.
- Returns:
The builder instance for method chaining
- Raises:
ValueError – If both url and any other connection parameter are provided, since url takes precedence
- pynenc_mongo.builder.mongo_client_data_store(builder: pynenc.builder.PynencBuilder, min_size_to_cache: int = 1024, local_cache_size: int = 1024, max_size_to_cache: int = 16 * 1024 * 1024) pynenc.builder.PynencBuilder[source]¶
Configure Mongo-based client data store.
This method configures the Mongo client data store with the specified parameters. It requires that Mongo components have been configured either through mongo() or through configuration files.
- Parameters:
builder (PynencBuilder) – The PynencBuilder instance
min_size_to_cache (int) – Minimum string length (in characters) required to cache an argument. Arguments smaller than this size will be passed directly. Default is 1024 characters (roughly 1KB)
local_cache_size (int) – Maximum number of items to cache locally. Default is 1024
max_size_to_cache (int) – Maximum size of an argument to cache. Default is 16MB
- Returns:
The builder instance for method chaining
- Raises:
ValueError – If Mongo configuration is not present
- pynenc_mongo.builder.mongo_trigger(builder: pynenc.builder.PynencBuilder, scheduler_interval_seconds: int = 60, enable_scheduler: bool = True) pynenc.builder.PynencBuilder[source]¶
Configure Mongo-based trigger system.
This method configures the Mongo trigger system with the specified parameters. It requires that Mongo components have been configured either through mongo() or through configuration files.
- Parameters:
- Returns:
The builder instance for method chaining
- Raises:
ValueError – If Mongo configuration is not present
- pynenc_mongo.builder.validate_mongo_config(config: dict[str, Any]) None[source]¶
Validate Mongo plugin configuration.
This function validates that Mongo configuration is present when Mongo components are being used. It’s called automatically during the build process.
- Parameters:
config (dict[str, Any]) – The builder configuration dictionary
- Raises:
ValueError – If Mongo configuration is invalid