ProcessContext

class gafaelfawr.factory.ProcessContext(config, firestore, http_client, ldap_pool, redis, uid_cache, gid_cache, ldap_group_cache, ldap_group_name_cache, ldap_user_cache, internal_token_cache, notebook_token_cache)

Bases: object

Per-process application context.

This object caches all of the per-process singletons that can be reused for every request and only need to be recreated if the application configuration changes. This does not include the database session; each request creates a new scoped session that’s removed at the end of the session to ensure that all transactions are committed or abandoned.

Parameters:

Attributes Summary

config

Gafaelfawr's configuration.

firestore

Client to talk to Firestore, if configured.

gid_cache

Shared GID cache.

http_client

Shared HTTP client.

internal_token_cache

Shared internal token cache.

ldap_group_cache

Cache of LDAP group information.

ldap_group_name_cache

Cache of LDAP group names.

ldap_pool

Connection pool to talk to LDAP, if configured.

ldap_user_cache

Cache of LDAP user data.

notebook_token_cache

Shared notebook token cache.

redis

Connection pool to use to talk to Redis.

uid_cache

Shared UID cache.

Methods Summary

aclose()

Clean up a process context.

from_config(config)

Create a new process context from the Gafaelfawr configuration.

Attributes Documentation

config: Config

Gafaelfawr’s configuration.

firestore: AsyncClient | None

Client to talk to Firestore, if configured.

gid_cache: IdCache

Shared GID cache.

http_client: AsyncClient

Shared HTTP client.

internal_token_cache: InternalTokenCache

Shared internal token cache.

ldap_group_cache: LDAPCache[list[Group]]

Cache of LDAP group information.

ldap_group_name_cache: LDAPCache[list[str]]

Cache of LDAP group names.

ldap_pool: AIOConnectionPool | None

Connection pool to talk to LDAP, if configured.

ldap_user_cache: LDAPCache[LDAPUserData]

Cache of LDAP user data.

notebook_token_cache: NotebookTokenCache

Shared notebook token cache.

redis: Redis

Connection pool to use to talk to Redis.

uid_cache: IdCache

Shared UID cache.

Methods Documentation

async aclose()

Clean up a process context.

Called during shutdown, or before recreating the process context using a different configuration.

Return type:

None

async classmethod from_config(config)

Create a new process context from the Gafaelfawr configuration.

Parameters:

config (Config) – The Gafaelfawr configuration.

Returns:

Shared context for a Gafaelfawr process.

Return type:

ProcessContext