Skip to content

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: Union[str, NoneType] = None, flowdb_port: Union[int, NoneType] = None, flowdb_user: Union[str, NoneType] = None, flowdb_password: Union[str, NoneType] = None, flowdb_host: Union[str, NoneType] = None, flowdb_connection_pool_size: Union[int, NoneType] = None, flowdb_connection_pool_overflow: Union[int, NoneType] = None, redis_host: Union[str, NoneType] = None, redis_port: Union[int, NoneType] = None, redis_password: Union[str, NoneType] = None, conn: Union[flowmachine.core.connection.Connection, NoneType] = None) -> None
Source: flowmachine/core/init.py

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.Union[str, NoneType], default None

    Level to log at

  • flowdb_port: typing.Union[int, NoneType], default None

    Port number to connect to flowdb

  • flowdb_user: typing.Union[str, NoneType], default None

    Name of user to connect to flowdb as

  • flowdb_password: typing.Union[str, NoneType], default None

    Password to connect to flowdb

  • flowdb_host: typing.Union[str, NoneType], default None

    Hostname of flowdb server

  • flowdb_connection_pool_size: typing.Union[int, NoneType], default None

    Default number of database connections to use

  • flowdb_connection_pool_overflow: typing.Union[int, NoneType], default None

    Number of extra database connections to allow

  • redis_host: typing.Union[str, NoneType], default None

    Hostname for redis server.

  • redis_port: typing.Union[int, NoneType], default None

    Port the redis server is available on

  • redis_password: typing.Union[str, NoneType], default None

    Password for the redis instance

  • conn: typing.Union[flowmachine.core.connection.Connection, NoneType], default None

    Optionally 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: Union[str, NoneType] = None, flowdb_port: Union[int, NoneType] = None, flowdb_user: Union[str, NoneType] = None, flowdb_password: Union[str, NoneType] = None, flowdb_host: Union[str, NoneType] = None, flowdb_connection_pool_size: Union[int, NoneType] = None, flowdb_connection_pool_overflow: Union[int, NoneType] = None, redis_host: Union[str, NoneType] = None, redis_port: Union[int, NoneType] = None, redis_password: Union[str, NoneType] = None, conn: Union[flowmachine.core.connection.Connection, NoneType] = None) -> None
Source: flowmachine/core/init.py

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.Union[str, NoneType], default None

    Level to log at

  • flowdb_port: typing.Union[int, NoneType], default None

    Port number to connect to flowdb

  • flowdb_user: typing.Union[str, NoneType], default None

    Name of user to connect to flowdb as

  • flowdb_password: typing.Union[str, NoneType], default None

    Password to connect to flowdb

  • flowdb_host: typing.Union[str, NoneType], default None

    Hostname of flowdb server

  • flowdb_connection_pool_size: typing.Union[int, NoneType], default None

    Default number of database connections to use

  • flowdb_connection_pool_overflow: typing.Union[int, NoneType], default None

    Number of extra database connections to allow

  • redis_host: typing.Union[str, NoneType], default None

    Hostname for redis server.

  • redis_port: typing.Union[int, NoneType], default None

    Port the redis server is available on

  • redis_password: typing.Union[str, NoneType], default None

    Password for the redis instance

  • conn: typing.Union[flowmachine.core.connection.Connection, NoneType], default None

    Optionally 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.