Record Class MembershipManager.MemberInfo

java.lang.Object
java.lang.Record
com.tnsai.agents.groups.MembershipManager.MemberInfo
Enclosing interface:
MembershipManager

public static record MembershipManager.MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String,Object> metadata, int priority, int maxConcurrentTasks, int activeTasks, String role) extends Record
Information about a group member.
  • Constructor Details

    • MemberInfo

      public MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String,Object> metadata)
      Creates MemberInfo with defaults for priority/concurrency.
    • MemberInfo

      public MemberInfo(String agentId, String agentName, List<String> capabilities, Instant joinedAt, Instant lastHeartbeat, MembershipManager.MemberHealth health, Map<String,Object> metadata, int priority, int maxConcurrentTasks, int activeTasks, String role)
      Creates an instance of a MemberInfo record class.
      Parameters:
      agentId - the value for the agentId record component
      agentName - the value for the agentName record component
      capabilities - the value for the capabilities record component
      joinedAt - the value for the joinedAt record component
      lastHeartbeat - the value for the lastHeartbeat record component
      health - the value for the health record component
      metadata - the value for the metadata record component
      priority - the value for the priority record component
      maxConcurrentTasks - the value for the maxConcurrentTasks record component
      activeTasks - the value for the activeTasks record component
      role - the value for the role record component
  • Method Details

    • isHealthy

      public boolean isHealthy()
    • getMembershipDuration

      public Duration getMembershipDuration()
    • canAcceptTask

      public boolean canAcceptTask()
      Checks if this member can accept more tasks.
      Returns:
      true if activeTasks invalid input: '<' maxConcurrentTasks
    • withTaskStarted

      public MembershipManager.MemberInfo withTaskStarted()
      Returns a new MemberInfo with incremented active tasks.
      Returns:
      new MemberInfo with activeTasks + 1
    • withTaskCompleted

      public MembershipManager.MemberInfo withTaskCompleted()
      Returns a new MemberInfo with decremented active tasks.
      Returns:
      new MemberInfo with activeTasks - 1
    • withHeartbeat

      public MembershipManager.MemberInfo withHeartbeat(Instant newHeartbeat)
      Returns a new MemberInfo with updated heartbeat.
      Parameters:
      newHeartbeat - new heartbeat time
      Returns:
      new MemberInfo
    • withHealth

      Returns a new MemberInfo with updated health.
      Parameters:
      newHealth - new health status
      Returns:
      new MemberInfo
    • 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 '=='.
      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.
    • agentId

      public String agentId()
      Returns the value of the agentId record component.
      Returns:
      the value of the agentId record component
    • agentName

      public String agentName()
      Returns the value of the agentName record component.
      Returns:
      the value of the agentName record component
    • capabilities

      public List<String> capabilities()
      Returns the value of the capabilities record component.
      Returns:
      the value of the capabilities record component
    • joinedAt

      public Instant joinedAt()
      Returns the value of the joinedAt record component.
      Returns:
      the value of the joinedAt record component
    • lastHeartbeat

      public Instant lastHeartbeat()
      Returns the value of the lastHeartbeat record component.
      Returns:
      the value of the lastHeartbeat record component
    • health

      Returns the value of the health record component.
      Returns:
      the value of the health record component
    • metadata

      public Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component
    • priority

      public int priority()
      Returns the value of the priority record component.
      Returns:
      the value of the priority record component
    • maxConcurrentTasks

      public int maxConcurrentTasks()
      Returns the value of the maxConcurrentTasks record component.
      Returns:
      the value of the maxConcurrentTasks record component
    • activeTasks

      public int activeTasks()
      Returns the value of the activeTasks record component.
      Returns:
      the value of the activeTasks record component
    • role

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