Record Class Member

java.lang.Object
java.lang.Record
io.axoniq.framework.springcloud.routing.Member
Record Components:
name - the node id of this member, unique to the application process it represents. It is also what decides the member's positions on the ConsistentHash ring, so every member of the cluster places it the same way
endpoint - the base URI to reach this member over HTTP, or null for a local member
local - true when this member represents the application it is constructed in, false when it represents another node

public record Member(String name, @Nullable URI endpoint, boolean local) extends Record
A single node in the cluster of applications distributing messages through Spring Cloud Discovery.

A Member is identified by the node id the application reports about itself, rather than by anything the discovery client reports about it, so that an application reported more than once is still one member. Its endpoint comes from the ServiceInstance the discovery client reported it as. A Member is what the ConsistentHash ring resolves a command's routing key to, and what a query name resolves to when the members advertising it are rotated over. The local flag decides how a message addressed to this member is delivered: a local member is handled through the registered handler of this application's own connector, while a remote member is reached over HTTP at its endpoint.

A local member has no endpoint, since it is never reached over HTTP. A remote member without an endpoint cannot be reached at all, and is rejected on construction.

Since:
5.4.0
Author:
Allard Buijze
  • Constructor Summary

    Constructors
    Constructor
    Description
    Member(String name, @Nullable URI endpoint, boolean local)
    Compact constructor validating that the name is present, and that a non-local member carries an endpoint to reach it at.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable URI
    Returns the value of the endpoint record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the local record component.
    static Member
    Constructs the local Member representing the application it is constructed in.
    Returns the value of the name record component.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Member

      public Member(String name, @Nullable URI endpoint, boolean local)
      Compact constructor validating that the name is present, and that a non-local member carries an endpoint to reach it at.
      Parameters:
      name - the node id of this member, unique to the application process it represents
      endpoint - the base URI to reach this member over HTTP, or null for a local member
      local - true when this member represents the application it is constructed in, false
  • Method Details

    • localMember

      public static Member localMember(String name)
      Constructs the local Member representing the application it is constructed in.
      Parameters:
      name - the node id of this application
      Returns:
      a local Member without an endpoint
    • toString

      public 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • endpoint

      public @Nullable URI endpoint()
      Returns the value of the endpoint record component.
      Returns:
      the value of the endpoint record component
    • local

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