asphalt.redis.component

class asphalt.redis.component.RedisComponent(*, resource_name='default', validate_connection=True, **kwargs)

Bases: Component

Provides a redis.asyncio.Redis client as a resource.

Parameters:
  • resource_name (str) – name of the client resource to be added

  • validate_connection (bool) – if true, check that the server can be connected to before adding the client resource

  • kwargs (Any) – keyword arguments passed to redis.asyncio.Redis

async start(ctx)

Perform any necessary tasks to start the services provided by this component.

In this method, components typically use the context to:

It is advisable for Components to first add all the resources they can to the context before requesting any from it. This will speed up the dependency resolution and prevent deadlocks.

Parameters:

ctx (Context) – the containing context for this component

Return type:

AsyncGenerator[None, Exception | None]