teal.redis – Redis related utilities for TeaL#

class teal.redis.RedisSettings(_env_file: str | PathLike | List[str | PathLike] | Tuple[str | PathLike, ...] | None = '<object object>', _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | PathLike | None = None, *, redis_dsn: RedisDsn)#

Bases: BaseSettings

RabbitMQ related settings.

redis_dsn: RedisDsn#

Redis connection URI to use.

An example Redis URI for localhost is the following:

redis://localhost:6379/0
class teal.redis.StoredState(*, expires_at: datetime | None = None, final_redirect_url: HttpUrl | None = None, with_fragment: bool = False)#

Bases: BaseModel

Storage model as found in Redis for callbacks.

expires_at: datetime | None#

UTC date and time at which the stored state should expire.

final_redirect_url: HttpUrl | None#

The complete redirect URL to redirect the end user to.

This can be non-specified; in such cases, instead of redirecting the end user, we just return an HTTP 2xx response.

with_fragment: bool#

Whether to read the fragment.

async teal.redis.get_stored_state(state: str, /, *, settings: RedisSettings) StoredState | None#

Get the stored state.

Parameters:
  • state – The state identifier to look for.

  • settings – The Redis settings to use to find the stored state.

Returns:

The stored state, or None if the state wasn’t found.’

async teal.redis.store_state(state: str, /, *, final_redirect_url: str | None, with_fragment: bool = False, expires_at: datetime | None = None, settings: RedisSettings) None#

Store a callback state.

Parameters:
  • state – The state to register.

  • final_redirect_url – The complete redirect URL to redirect the end user to.

  • with_fragment – Whether to read the fragment or not.