Last active
November 9, 2017 16:33
-
-
Save yellowbrickc/af556571a733fc5c20be01ea9ae487dc to your computer and use it in GitHub Desktop.
Domain event documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Scenario: different business teams building parts of a product, splitted by business domains. We are anly communicate via domain events published to a message bus and sometimes via published links. | |
| As the domain events are the "contracts" between the business domains we want to declare and enforce the schemas of the events. | |
| Our solution is built in node but the concept could work in any stack. |
Author
Wow! There is a lot of complexity in this workflow proposal. The schema looks pretty common. Maybe you are doing something too unclear / much things with this kind of "messaging"?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Components:
"build": "doca init -i node_modules/domain-events/json-schema"This solve the problem of the documentation but we want to enforce that only events published as domain-event are allowed on the message bus. On the other hand all we have shared packages to produce respectively consumer events from our bus. After this it was the easy and logical step to include the domain-event package in the consumer/producer packages and use it there in the validation step. Additionally in order to be backward compatible we allow unknown properties in the consumer validation but not in the producer validation.
Regarding the (current) process:
{ "id": "event.json", "title": "Event", "$schema": "http://json-schema.org/draft-04/schema#", "description": "Schema for the domain event envelope that is used by every event.", "type": "object", "properties": { "eventId": { "type": "string", "description": "An Id which is unique for the entityId. Shall be a v1-uuid (time-based).", "example": "4a4c0290-354f-11e7-a919-92ebcb67fe33" }, "eventType": { "type": "string", "enum": [ "offer.accepted" ], "example": "offer.accepted" }, "entityId": { "type": "string", "description": "An Id which is unique among all the entities of the same entityType. Shall be a v1-uuid (time-based).", "example": "4a4c0290-354f-11e7-a919-92ebcb67fe33" }, "createdAt": { "type": "string", "format": "date-time", "description": "ISO 8601 DateTimeStamp in UTC with millisecond precision.", "example": "2017-01-01T12:00:00.123Z" }, "version": { "type": "integer", "example": 1 }, "correlationId": { "type": "string", "description": "A unique ID used to track the flow of data, commands, events and alike through the whole domain.", "example": "4a4c0290-354f-11e7-a919-92ebcb67fe33" }, "payload": { "type": "object", "description": "Must contain the entityId plus other fields that have changed in the entity. 'Flat' payloads shall be preferred....", "properties": { "id": {... }, ... }, "required": [ ... ], "additionalProperties": false } }, "required": [ "eventId", "eventType", "entityId", "createdAt", "version", "payload", "correlationId" ], "additionalProperties": false }