Event Publisher
Description
A component in the Infrastructure layer responsible for publishing messages/events to a message bus or queue.
Definition Schema
The definition for a event_publisher
component expects the following structure:
{
"$defs": {
"ServiceDependencyInputDTO": {
"description": "Defines a dependency to be injected into the Service's __init__.",
"example": {
"assigned_attribute_name": "_emailer",
"param_name": "email_service",
"param_type_str": "EmailService"
},
"example_with_explicit_import": {
"param_import_from_module": "sqlalchemy.ext.asyncio",
"param_import_names": [
"AsyncSession"
],
"param_name": "async_session_factory",
"param_type_str": "AsyncSession"
},
"properties": {
"param_name": {
"description": "Name of the parameter in __init__ (e.g., 'user_repository')",
"title": "Param Name",
"type": "string"
},
"param_type_str": {
"description": "Type hint string for the parameter (e.g., 'UserRepository')",
"title": "Param Type Str",
"type": "string"
},
"assigned_attribute_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Name of the attribute to assign the dependency to on self (e.g., '_repo'). Defaults to '_' + param_name if None.",
"title": "Assigned Attribute Name"
},
"param_import_from_module": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional: Explicit module to import the dependency type from (e.g., 'sqlalchemy.ext.asyncio').",
"title": "Param Import From Module"
},
"param_import_names": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional: Explicit list of names to import from the module (e.g., ['AsyncSession']). Used if param_import_from_module is set.",
"title": "Param Import Names"
}
},
"required": [
"param_name",
"param_type_str"
],
"title": "ServiceDependencyInputDTO",
"type": "object"
}
},
"description": "DTO for defining an Event Publisher class.",
"example": {
"dependencies": [
{
"assigned_attribute_name": "_producer",
"param_name": "kafka_producer",
"param_type_str": "aiokafka.AIOKafkaProducer"
}
],
"name": "AuditLogEventPublisher"
},
"properties": {
"name": {
"description": "Name of the event publisher class (e.g., 'KafkaPostEventPublisher')",
"title": "Name",
"type": "string"
},
"dependencies": {
"description": "List of dependencies for the __init__ method.",
"items": {
"$ref": "#/$defs/ServiceDependencyInputDTO"
},
"title": "Dependencies",
"type": "array"
}
},
"required": [
"name"
],
"title": "EventPublisherInputDTO",
"type": "object"
}
Naming and Location Conventions
Class: PascalCase, typically ends with 'EventPublisher'. File: ${event_publisher_name}.py
(based on ${event_publisher_name}
). Location: app/infrastructure/messaging
.
Example Definition
{
"name": "AuditLogEventPublisher",
"dependencies": [
{
"param_name": "kafka_producer",
"param_type_str": "aiokafka.AIOKafkaProducer",
"assigned_attribute_name": "_producer"
}
]
}