- CPS-470Getting issue details... STATUS
Overview
The CPS-core notification system only sends data-update events when a root data node is created or the anchor is updated. There is no support for delete change. And, the existing supported operations are also not differentiated in the event. To define the operation type, we need to change the existing event structure and the changes on both the cps-core and cps-temporal sides to have backward compatibility.
Proposal
Operation
Operation | Scenario |
---|---|
CREATE |
|
UPDATE |
|
DELETE |
|
Event
Event Structure
The event V1 schema definition is strict and it is not possible to add any optional fields without breaking the old schema contract. To have the flexibility of adding optional fields in future, we are setting the value of 'additionalProperties' to true in both 'CpsDataUpdatedEvent' and 'Content' definitions.
{ "definitions": { "CpsDataUpdatedEvent": { ... "additionalProperties": true }, "Content": { ... "additionalProperties": true }, ... } }
The new 'operation' field is added to the event in the content section. The field can be marked as
- optional: It makes the event v2 backwards compatible and the user can upgrade cps-temporal before cps-core. As it is a field that should be mandatory, it should be set as mandatory in the v3 which gives the user a release to upgrade cps-core to v2.
- mandatory: No compatibility with the future change. Both cps-core and cps-temporal have to be updated at the same time.
The team decided to mark it as
The existing 'data' section in the content can be set as null for the delete event. As we are deleting a mandatory field, the change is still backwards compatible.
{ "definitions": { ... "Content": { "properties": { "operation": { "description": "The operation supported by the ", "type": "string", "enum": ["CREATE", "UPDATE", "DELETE"] } ... } } } }
CPS-Core
cps core should send the event with the 'operation' information for all the events. The scenarios are defined in the Operation section of the proposal.
In the case of the 'delete' event, the 'data' section should be empty.
{ "schema": "urn:cps:org.onap.cps:data-updated-event-schema:v1", "id": "77b8f114-4562-4069-8234-6d059ff742ac", "source": "urn:cps:org.onap.cps", "type": "org.onap.cps.data-updated-event", "content": { "observedTimestamp": "2020-12-01T00:00:00.000+0000", "dataspaceName": "my-dataspace", "schemaSetName": "bookstore-schemaset", "anchorName": "chapters", "operation": "DELETE", } }
CPS-Temporal
It will store the new 'operation' field in the newly added column in the network_data table. if this field is optional in the event, the default value of UPDATE will be set on the temporal side.
Database Schema
A new field 'operation' of type varchar(20) is added in the network_data table.
Migration
The newly added field 'operation' should have a value of 'UPDATE' for the existing field.