[ADP-608] Temporary Events
Overview
In distributed systems, events may become irrelevant after a certain point in time. This ADP defines a standard method for marking events as temporary using the CloudEvents Expiry Time Extension, allowing consumers and intermediaries to handle time-sensitive events appropriately.
Guidelines
MUST use the CloudEvents Expiry Time Extension to mark temporary events.
Event producers MUST set the
expirytime
attribute for temporary events.The
expirytime
attribute MUST be of typeTimestamp
.The
expirytime
value SHOULD be equal to or later than thetime
attribute, if present.Intermediaries and consumers MAY ignore and discard events that have reached or passed their
expirytime
.Intermediaries MAY modify the
expirytime
attribute but MUST NOT remove it.Systems interacting with consumers SHOULD NOT make assumptions about whether a consumer will keep or discard an event based solely on this extension.
CloudEvents Expiry Time Extension
The Expiry Time Extension adds one attribute to CloudEvents:
expirytime
: A timestamp indicating when an event is no longer useful.
Example CloudEvent with expirytime
:
{
"specversion" : "1.0",
"type" : "com.example.temporaryevent",
"source" : "/mycontext",
"id" : "C234-1234-1234",
"time" : "2023-06-01T10:30:00Z",
"expirytime": "2023-06-01T11:30:00Z",
"data" : {
"message" : "This event expires in one hour"
}
}
Implementation Recommendations
Use consistent time synchronization across systems to ensure accurate expiry time comparisons.
Implement efficient event filtering mechanisms based on the
expirytime
attribute.Consider implementing a cleanup process for expired events in event stores or message queues.
Provide clear documentation on how your system handles expired events.
Consider logging or monitoring discarded expired events for system health checks and debugging.
Use Cases
Real-time Dashboards: Discard outdated sensor data in web dashboards to display only the most recent information.
Time-limited Offers: Send promotional events with an expiry time for limited-time offers.
Temporary System States: Use temporary events to represent transient system states that are only relevant for a specific duration.
Job Scheduling: Set expiry times for job requests in distributed job processing systems.
Security Considerations
Ensure that time-based event filtering doesn't introduce vulnerabilities (e.g., time-of-check to time-of-use issues).
Be aware that malicious actors might try to manipulate system behavior by sending events with crafted expiry times.
Consider the implications of time synchronization issues on event expiry handling.