Record Class ClusterEvent

java.lang.Object
java.lang.Record
com.onec.cluster.ClusterEvent
Record Components:
kind - payload shape tag; see KIND_ENTITY_CHANGED.
originNodeId - the publishing node's id, used by receivers to filter out their own echoes.
changeType - created/updated/deleted/posted/unposted/changed.
entityType - catalog/document/register.
entityName - the entity's logical name, or * for a non-specific signal.
id - the affected row's id as a string, or null.
naturalKey - the business key (catalog code / document number), or null.

public record ClusterEvent(String kind, String originNodeId, String changeType, String entityType, String entityName, String id, String naturalKey) extends Record
Wire form of a cross-node change notice carried by a ClusterEventBus.

It mirrors the fields of com.onec.events.EntityChangedEvent (kept as plain strings so the record is trivial to serialize and the core module stays free of spring-context and Jackson annotations), plus two transport-only fields:

  • kind — a tag identifying the payload shape, so a future event kind can share the same channel without a wire break. Today the only value is KIND_ENTITY_CHANGED.
  • originNodeId — the id of the node that published the event. A bus delivers an event back to its own subscribers (Postgres NOTIFY echoes to the publisher's LISTEN), so receivers drop events whose origin equals their own node id: the originating node already fanned the change out to its local SSE clients synchronously.
  • Field Details

    • KIND_ENTITY_CHANGED

      public static final String KIND_ENTITY_CHANGED
      kind value for an entity-change notice mirroring EntityChangedEvent.
      See Also:
  • Constructor Details

    • ClusterEvent

      public ClusterEvent(String kind, String originNodeId, String changeType, String entityType, String entityName, String id, String naturalKey)
      Creates an instance of a ClusterEvent record class.
      Parameters:
      kind - the value for the kind record component
      originNodeId - the value for the originNodeId record component
      changeType - the value for the changeType record component
      entityType - the value for the entityType record component
      entityName - the value for the entityName record component
      id - the value for the id record component
      naturalKey - the value for the naturalKey record component
  • Method Details

    • entityChanged

      public static ClusterEvent entityChanged(String changeType, String entityType, String entityName, String id, String naturalKey)
      Build an KIND_ENTITY_CHANGED event with no originNodeId set — the publishing ClusterEventBus stamps that during ClusterEventBus.publish(com.onec.cluster.ClusterEvent). This is the form the change-relay constructs, so it never needs to know the local node id.
    • withOrigin

      public ClusterEvent withOrigin(String originNodeId)
      A copy of this event with originNodeId set — used by a bus to stamp its identity on send.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • kind

      public String kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • originNodeId

      public String originNodeId()
      Returns the value of the originNodeId record component.
      Returns:
      the value of the originNodeId record component
    • changeType

      public String changeType()
      Returns the value of the changeType record component.
      Returns:
      the value of the changeType record component
    • entityType

      public String entityType()
      Returns the value of the entityType record component.
      Returns:
      the value of the entityType record component
    • entityName

      public String entityName()
      Returns the value of the entityName record component.
      Returns:
      the value of the entityName record component
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • naturalKey

      public String naturalKey()
      Returns the value of the naturalKey record component.
      Returns:
      the value of the naturalKey record component