Record Class ClusterEvent.Presence

java.lang.Object
java.lang.Record
su.onno.cluster.ClusterEvent.Presence
Record Components:
originNodeId - the publishing node's id, or null before a bus stamps it.
action - ENTER, HEARTBEAT, or LEAVE.
entityType - the viewed record's entity type (catalog/document).
entityName - the viewed record's logical name.
id - the viewed record's id as a string.
userId - a stable id for the viewing user (their domain record id, or username).
displayName - the viewing user's display name, for rendering the avatar/marker.
avatarUrl - the viewing user's avatar image URL, or null (the marker then falls back to initials).
All Implemented Interfaces:
ClusterEvent
Enclosing interface:
ClusterEvent

public static record ClusterEvent.Presence(String originNodeId, String action, String entityType, String entityName, String id, String userId, String displayName, String avatarUrl) extends Record implements ClusterEvent
A user-presence notice for record-level collaboration markers: one user has entered, refreshed, or left the live view of a specific record. Receivers mirror the (entityType, entityName, id) record's viewer set into their own presence registry so a viewer on any node sees who else is here.

It carries no timestamp: a receiver stamps lastSeen from its own clock on receipt, so a stale entry expires by local TTL without depending on cross-node clock agreement. ENTER and HEARTBEAT are both an upsert (refresh the viewer); LEAVE removes them. Like every event on this bus it is best-effort — a missed ping self-heals on the next heartbeat or by TTL.

  • Field Details

    • ENTER

      public static final String ENTER
      A user opened the record's live view. Treated as an upsert by the registry.
      See Also:
    • HEARTBEAT

      public static final String HEARTBEAT
      A periodic liveness refresh from a user still on the record. Treated as an upsert.
      See Also:
    • LEAVE

      public static final String LEAVE
      A user left the record's live view. Removes them from the registry.
      See Also:
  • Constructor Details

    • Presence

      public Presence(String originNodeId, String action, String entityType, String entityName, String id, String userId, String displayName, String avatarUrl)
      Creates an instance of a Presence record class.
      Parameters:
      originNodeId - the value for the originNodeId record component
      action - the value for the action 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
      userId - the value for the userId record component
      displayName - the value for the displayName record component
      avatarUrl - the value for the avatarUrl record component
  • Method Details

    • kind

      public String kind()
      Description copied from interface: ClusterEvent
      The payload-shape tag identifying which permitted variant this event is.
      Specified by:
      kind in interface ClusterEvent
    • withOrigin

      public ClusterEvent.Presence withOrigin(String originNodeId)
      Description copied from interface: ClusterEvent
      A copy of this event with ClusterEvent.originNodeId() set — used by a bus to stamp its identity on send.
      Specified by:
      withOrigin in interface ClusterEvent
    • 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.
    • originNodeId

      public String originNodeId()
      Returns the value of the originNodeId record component.
      Specified by:
      originNodeId in interface ClusterEvent
      Returns:
      the value of the originNodeId record component
    • action

      public String action()
      Returns the value of the action record component.
      Returns:
      the value of the action 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
    • userId

      public String userId()
      Returns the value of the userId record component.
      Returns:
      the value of the userId record component
    • displayName

      public String displayName()
      Returns the value of the displayName record component.
      Returns:
      the value of the displayName record component
    • avatarUrl

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