Improve auth flow
This commit is contained in:
41
services/tenant/app/services/messaging.py
Normal file
41
services/tenant/app/services/messaging.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# services/tenant/app/services/messaging.py
|
||||
"""
|
||||
Tenant service messaging for event publishing
|
||||
"""
|
||||
|
||||
import structlog
|
||||
from shared.messaging.rabbitmq import RabbitMQPublisher
|
||||
|
||||
logger = structlog.get_logger()
|
||||
|
||||
async def publish_tenant_created(tenant_id: str, owner_id: str, tenant_name: str):
|
||||
"""Publish tenant created event"""
|
||||
try:
|
||||
publisher = RabbitMQPublisher()
|
||||
await publisher.publish_event(
|
||||
"tenant.created",
|
||||
{
|
||||
"tenant_id": tenant_id,
|
||||
"owner_id": owner_id,
|
||||
"tenant_name": tenant_name,
|
||||
"timestamp": datetime.utcnow().isoformat()
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to publish tenant.created event: {e}")
|
||||
|
||||
async def publish_member_added(tenant_id: str, user_id: str, role: str):
|
||||
"""Publish member added event"""
|
||||
try:
|
||||
publisher = RabbitMQPublisher()
|
||||
await publisher.publish_event(
|
||||
"tenant.member.added",
|
||||
{
|
||||
"tenant_id": tenant_id,
|
||||
"user_id": user_id,
|
||||
"role": role,
|
||||
"timestamp": datetime.utcnow().isoformat()
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to publish tenant.member.added event: {e}")
|
||||
Reference in New Issue
Block a user