refactor: rename CloudEvents extension attributes hub* → central*

Rename extension attributes for consistency with project naming:
- hubschemaversion → centralschemaversion
- hubcategory → centralcategory
- hubseverity → centralseverity

Non-breaking change - no consumers depend on these names yet.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson 2026-05-15 21:47:06 +00:00 committed by Ubuntu
commit 4a7f1a76c7
2 changed files with 33 additions and 33 deletions

View file

@ -11,27 +11,27 @@ from central.models import Event
def wrap_event(event: Event, config: Config) -> tuple[dict[str, Any], str]:
"""
Wrap an Event into a CNCF CloudEvents v1.0 JSON envelope.
Returns:
A tuple of (envelope_dict, msg_id) where msg_id is the
CloudEvent id for use as Nats-Msg-Id header.
"""
# Build CE type: {prefix}.{category}.v1
ce_type = f"{config.cloudevents.type_prefix}.{event.category}.v1"
# Serialize event data
event_data = event.model_dump(mode="json")
# Build extension attributes - lowercase, no underscores per CE spec
extensions: dict[str, Any] = {
"hubschemaversion": config.cloudevents.schema_version,
"hubcategory": event.category,
"centralschemaversion": config.cloudevents.schema_version,
"centralcategory": event.category,
}
# Only include hubseverity if severity is present
# Only include centralseverity if severity is present
if event.severity is not None:
extensions["hubseverity"] = event.severity
extensions["centralseverity"] = event.severity
# Create CloudEvent
ce = CloudEvent(
attributes={
@ -44,9 +44,9 @@ def wrap_event(event: Event, config: Config) -> tuple[dict[str, Any], str]:
},
data=event_data,
)
# Build envelope dict from CloudEvent
envelope: dict[str, Any] = dict(ce.get_attributes())
envelope["data"] = ce.data
return envelope, event.id