poiesis.core.ports package

Submodules

poiesis.core.ports.kubernetes module

Container orchestrator port.

class poiesis.core.ports.kubernetes.KubernetesPort[source]

Bases: ABC

Container orchestrator port.

abstractmethod async create_job(job)[source]

Create a Kubernetes Job.

Parameters:

job (V1Job) – The Kubernetes Job object.

Return type:

str

abstractmethod async create_pod(pod)[source]

Create a task execution pod.

Parameters:

pod (V1Pod) – The pod object.

Return type:

str

abstractmethod async create_pvc(pvc)[source]

Create a Persistent Volume Claim.

Parameters:

pvc (V1PersistentVolumeClaim) – The Persistent Volume Claim object.

Return type:

str

abstractmethod async delete_pvc(name)[source]

Delete a Persistent Volume Claim.

Parameters:

name (str) – The name of the Persistent Volume Claim.

Return type:

None

abstractmethod async get_job(name)[source]

Get a Kubernetes Job.

Parameters:

name (str) – The name of the Job.

Return type:

V1Job

abstractmethod async get_pod(name)[source]

Get a specific pod.

Parameters:

name (str) – The name of the pod.

Return type:

V1Pod

abstractmethod async get_pod_log(name)[source]

Get log of a pod.

Parameters:

name (str) – The name of the pod.

Return type:

str

abstractmethod async get_pods(label_selector)[source]

Get all pods matching the label selector.

Parameters:

label_selector (str) – The label selector.

Return type:

list[V1Pod]

poiesis.core.ports.message_broker module

Messaging/Eventing ports.

class poiesis.core.ports.message_broker.Message(message, status=<factory>, timestamp=<factory>)[source]

Bases: object

Base message class for all messages in the system.

message: str
status: MessageStatus
timestamp: datetime
to_json()[source]

Convert to json string.

Return type:

str

class poiesis.core.ports.message_broker.MessageBroker[source]

Bases: ABC

Abstract base class for message broker implementations.

abstractmethod close()[source]

Close the message broker.

Return type:

None

abstractmethod publish(channel, message)[source]

Publish a message to a specific channel.

Parameters:
  • channel (str) – The channel/topic to publish to

  • message (Message) – The message to publish

Return type:

None

abstractmethod subscribe(channel)[source]

Subscribe to a channel and yield messages as they arrive.

Parameters:

channel (str) – The channel/topic to subscribe to

Return type:

Iterator[Message]

Returns:

Iterator yielding messages as they arrive

class poiesis.core.ports.message_broker.MessageStatus(*values)[source]

Bases: Enum

Status of K8s job sent via message broker.

ERROR = 'ERROR'
SUCCESS = 'SUCCESS'

Module contents

Ports for the core components.