Index
pyvider.ephemerals
¶
This package defines the core abstractions for implementing ephemeral resources, which are temporary, stateful components like API clients or database connections.
Classes¶
BaseEphemeralResource
¶
Bases: ABC, Generic[ResultType, PrivateStateType, ConfigType]
Abstract base class for an ephemeral resource.
Ephemeral resources manage temporary, stateful objects like API clients or database connections that have a limited lifetime and may need to be periodically renewed.
Functions¶
close
abstractmethod
async
¶
Closes the ephemeral resource and cleans up any connections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
EphemeralResourceContext[None, PrivateStateType]
|
The context containing the final private state. |
required |
Source code in pyvider/ephemerals/base.py
get_schema
abstractmethod
classmethod
¶
open
abstractmethod
async
¶
open(
ctx: EphemeralResourceContext[ConfigType, None],
) -> tuple[ResultType, PrivateStateType, datetime]
Opens the ephemeral resource.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
EphemeralResourceContext[ConfigType, None]
|
The context containing the resource's configuration. |
required |
Returns:
| Type | Description |
|---|---|
ResultType
|
A tuple containing: |
PrivateStateType
|
|
datetime
|
|
tuple[ResultType, PrivateStateType, datetime]
|
|
Source code in pyvider/ephemerals/base.py
renew
abstractmethod
async
¶
renew(
ctx: EphemeralResourceContext[None, PrivateStateType],
) -> tuple[PrivateStateType, datetime]
Renews the ephemeral resource's lease or session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
EphemeralResourceContext[None, PrivateStateType]
|
The context containing the current private state. |
required |
Returns:
| Type | Description |
|---|---|
PrivateStateType
|
A tuple containing: |
datetime
|
|
tuple[PrivateStateType, datetime]
|
|
Source code in pyvider/ephemerals/base.py
EphemeralResourceContext
¶
Bases: BaseContext, Generic[ConfigType, PrivateStateType]
Context for ephemeral resource operations. Inherits diagnostic reporting capabilities from BaseContext.
Functions¶
register_ephemeral_resource
¶
Decorator to register an ephemeral resource under the 'ephemeral_resources' component type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The unique name of the ephemeral resource to register. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
class |
Callable[[type], type]
|
The decorated ephemeral resource class. |