Record Class HeartbeatMessage

java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.HeartbeatMessage
Record Components:
sourceProxyId - the unique identifier of the proxy sending the heartbeat
timestamp - when the heartbeat was generated
region - the geographic region of the proxy (e.g., "us-east", "eu-west")
host - the hostname or IP address of the proxy
port - the port the proxy is listening on
playerCount - current number of connected players
uptimeMillis - how long the proxy has been running in milliseconds
shuttingDown - true if the proxy is in the process of shutting down
All Implemented Interfaces:
ChannelMessage

public record HeartbeatMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String region, @Nonnull String host, int port, int playerCount, long uptimeMillis, boolean shuttingDown) extends Record implements ChannelMessage
Heartbeat message for proxy health monitoring and discovery.

Proxies periodically publish heartbeats to announce their presence and current state. Other proxies use this information to:

  • Track which proxies are online
  • Aggregate player counts across the cluster
  • Detect proxy failures (missed heartbeats)
  • Route players to available proxies

Usage

@Subscribe(SystemChannel.HEARTBEAT)
public void onHeartbeat(HeartbeatMessage heartbeat) {
    logger.info("Proxy {} in {} has {} players (uptime: {}ms)",
        heartbeat.sourceProxyId(),
        heartbeat.region(),
        heartbeat.playerCount(),
        heartbeat.uptimeMillis());
}
  • Constructor Details

    • HeartbeatMessage

      public HeartbeatMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String region, @Nonnull String host, int port, int playerCount, long uptimeMillis, boolean shuttingDown)
      Creates an instance of a HeartbeatMessage record class.
      Parameters:
      sourceProxyId - the value for the sourceProxyId record component
      timestamp - the value for the timestamp record component
      region - the value for the region record component
      host - the value for the host record component
      port - the value for the port record component
      playerCount - the value for the playerCount record component
      uptimeMillis - the value for the uptimeMillis record component
      shuttingDown - the value for the shuttingDown record component
  • Method Details

    • messageType

      @Nonnull public String messageType()
      Description copied from interface: ChannelMessage
      Get the message type identifier for serialization.
      Specified by:
      messageType in interface ChannelMessage
      Returns:
      the message type (e.g., "heartbeat", "chat", "plugin")
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • sourceProxyId

      @Nonnull public String sourceProxyId()
      Returns the value of the sourceProxyId record component.
      Specified by:
      sourceProxyId in interface ChannelMessage
      Returns:
      the value of the sourceProxyId record component
    • timestamp

      @Nonnull public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface ChannelMessage
      Returns:
      the value of the timestamp record component
    • region

      @Nonnull public String region()
      Returns the value of the region record component.
      Returns:
      the value of the region record component
    • host

      @Nonnull public String host()
      Returns the value of the host record component.
      Returns:
      the value of the host record component
    • port

      public int port()
      Returns the value of the port record component.
      Returns:
      the value of the port record component
    • playerCount

      public int playerCount()
      Returns the value of the playerCount record component.
      Returns:
      the value of the playerCount record component
    • uptimeMillis

      public long uptimeMillis()
      Returns the value of the uptimeMillis record component.
      Returns:
      the value of the uptimeMillis record component
    • shuttingDown

      public boolean shuttingDown()
      Returns the value of the shuttingDown record component.
      Returns:
      the value of the shuttingDown record component