flowmachine.core.init¶
Source: flowmachine/core/init.py
This module provides initial setup routines for flowmachine. From a user perspective, only the connect method is relevant.
From a developer perspective, this is where one-time operations should live - for example configuring loggers.
connect¶
connect(*, log_level: Optional[str] = None, flowdb_port: Optional[int] = None, flowdb_user: Optional[str] = None, flowdb_password: Optional[str] = None, flowdb_host: Optional[str] = None, flowdb_connection_pool_size: Optional[int] = None, flowdb_connection_pool_overflow: Optional[int] = None, redis_host: Optional[str] = None, redis_port: Optional[int] = None, redis_password: Optional[str] = None, conn: Optional[flowmachine.core.connection.Connection] = None) -> None
Connects flowmachine to a database, and performs initial set-up routines. You may provide a Settings object here, which can specify the database you wish to connect to, logging behaviour, available tables and so on.
After connecting, you should use flowmachine.core.context.get_db() to access the database connection, flowmachine.core.context.get_redis() to get the redis connection, and flowmachine.core.context.get_executor() to get the threadpool.
Parameters¶
-
log_level:typing.Optional, defaultNoneLevel to log at
-
flowdb_port:typing.Optional, defaultNonePort number to connect to flowdb
-
flowdb_user:typing.Optional, defaultNoneName of user to connect to flowdb as
-
flowdb_password:typing.Optional, defaultNonePassword to connect to flowdb
-
flowdb_host:typing.Optional, defaultNoneHostname of flowdb server
-
flowdb_connection_pool_size:typing.Optional, defaultNoneDefault number of database connections to use
-
flowdb_connection_pool_overflow:typing.Optional, defaultNoneNumber of extra database connections to allow
-
redis_host:typing.Optional, defaultNoneHostname for redis server.
-
redis_port:typing.Optional, defaultNonePort the redis server is available on
-
redis_password:typing.Optional, defaultNonePassword for the redis instance
-
conn:typing.Optional, defaultNoneOptionally provide an existing Connection object to use, overriding any the db options specified here.
Note
All parameters can also be provided as environment variables. If a parameter is provided, and an environment variable is set, then the provided value is used. If neither is provided, the defaults as given in the docstring are used. Parameters can also be set using Docker secrets, in which case a file with the name of the parameter in upper case should be present at /run/secrets/THE_PARAM. If a secret is available, the secret takes precedence over both the environment variable, and the default.
connections¶
connections(*, log_level: Optional[str] = None, flowdb_port: Optional[int] = None, flowdb_user: Optional[str] = None, flowdb_password: Optional[str] = None, flowdb_host: Optional[str] = None, flowdb_connection_pool_size: Optional[int] = None, flowdb_connection_pool_overflow: Optional[int] = None, redis_host: Optional[str] = None, redis_port: Optional[int] = None, redis_password: Optional[str] = None, conn: Optional[flowmachine.core.connection.Connection] = None) -> None
Context manager which connects flowmachine to a database, and performs initial set-up routines. You may provide a Settings object here, which can specify the database you wish to connect to, logging behaviour, available tables and so on.
After connecting, you should use flowmachine.core.context.get_db() to access the database connection, flowmachine.core.context.get_redis() to get the redis connection, and flowmachine.core.context.get_executor() to get the threadpool.
Parameters¶
-
log_level:typing.Optional, defaultNoneLevel to log at
-
flowdb_port:typing.Optional, defaultNonePort number to connect to flowdb
-
flowdb_user:typing.Optional, defaultNoneName of user to connect to flowdb as
-
flowdb_password:typing.Optional, defaultNonePassword to connect to flowdb
-
flowdb_host:typing.Optional, defaultNoneHostname of flowdb server
-
flowdb_connection_pool_size:typing.Optional, defaultNoneDefault number of database connections to use
-
flowdb_connection_pool_overflow:typing.Optional, defaultNoneNumber of extra database connections to allow
-
redis_host:typing.Optional, defaultNoneHostname for redis server.
-
redis_port:typing.Optional, defaultNonePort the redis server is available on
-
redis_password:typing.Optional, defaultNonePassword for the redis instance
-
conn:typing.Optional, defaultNoneOptionally provide an existing Connection object to use, overriding any the db options specified here.
Note
All parameters can also be provided as environment variables. If a parameter is provided, and an environment variable is set, then the provided value is used. If neither is provided, the defaults as given in the docstring are used. Parameters can also be set using Docker secrets, in which case a file with the name of the parameter in upper case should be present at /run/secrets/THE_PARAM. If a secret is available, the secret takes precedence over both the environment variable, and the default.