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 heartbeattimestamp- when the heartbeat was generatedregion- the geographic region of the proxy (e.g., "us-east", "eu-west")host- the hostname or IP address of the proxyport- the port the proxy is listening onplayerCount- current number of connected playersuptimeMillis- how long the proxy has been running in millisecondsshuttingDown- 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 Summary
ConstructorsConstructorDescriptionHeartbeatMessage(String sourceProxyId, Instant timestamp, String region, String host, int port, int playerCount, long uptimeMillis, boolean shuttingDown) Creates an instance of aHeartbeatMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.host()Returns the value of thehostrecord component.Get the message type identifier for serialization.intReturns the value of theplayerCountrecord component.intport()Returns the value of theportrecord component.region()Returns the value of theregionrecord component.booleanReturns the value of theshuttingDownrecord component.Returns the value of thesourceProxyIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.longReturns the value of theuptimeMillisrecord component.
-
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 aHeartbeatMessagerecord class.- Parameters:
sourceProxyId- the value for thesourceProxyIdrecord componenttimestamp- the value for thetimestamprecord componentregion- the value for theregionrecord componenthost- the value for thehostrecord componentport- the value for theportrecord componentplayerCount- the value for theplayerCountrecord componentuptimeMillis- the value for theuptimeMillisrecord componentshuttingDown- the value for theshuttingDownrecord component
-
-
Method Details
-
messageType
Description copied from interface:ChannelMessageGet the message type identifier for serialization.- Specified by:
messageTypein interfaceChannelMessage- Returns:
- the message type (e.g., "heartbeat", "chat", "plugin")
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
sourceProxyId
Returns the value of thesourceProxyIdrecord component.- Specified by:
sourceProxyIdin interfaceChannelMessage- Returns:
- the value of the
sourceProxyIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceChannelMessage- Returns:
- the value of the
timestamprecord component
-
region
-
host
-
port
-
playerCount
public int playerCount()Returns the value of theplayerCountrecord component.- Returns:
- the value of the
playerCountrecord component
-
uptimeMillis
public long uptimeMillis()Returns the value of theuptimeMillisrecord component.- Returns:
- the value of the
uptimeMillisrecord component
-
shuttingDown
public boolean shuttingDown()Returns the value of theshuttingDownrecord component.- Returns:
- the value of the
shuttingDownrecord component
-