Package io.vertx.servicediscovery
Class Record
- java.lang.Object
-
- io.vertx.servicediscovery.Record
-
public class Record extends Object
Describes a `service`. The record is the only piece of information shared between consumer and provider. It should contains enough metadata to let consumer find the service they want.- Author:
- Clement Escoffier
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Checks whether or not the current object is equal to the given object.JsonObject
getLocation()
JsonObject
getMetadata()
Gets the metadata attached to the record.String
getName()
Gets the name of the service.String
getRegistration()
Gets the registration id if any.Status
getStatus()
Gets the current status of the service.String
getType()
Gets the service type.int
hashCode()
boolean
match(JsonObject filter)
Checks whether or not the currentRecord
matches the filter.Record
setLocation(JsonObject location)
Sets the json object describing the location of the service.Record
setMetadata(JsonObject metadata)
Record
setName(String name)
Sets the name of the service.Record
setRegistration(String reg)
Sets the registration id.Record
setStatus(Status status)
Sets the status of the service.Record
setType(String type)
Sets the type of service.JsonObject
toJson()
String
toString()
-
-
-
Field Detail
-
ENDPOINT
public static final String ENDPOINT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Record
public Record()
Creates a newRecord
.
-
Record
public Record(JsonObject json)
Creates a newRecord
from its json representation.- Parameters:
json
- the json object
-
Record
public Record(Record other)
- Parameters:
other
- the record to copy
-
-
Method Detail
-
toJson
public JsonObject toJson()
- Returns:
- the JSON representation of the current
Record
.
-
getLocation
public JsonObject getLocation()
- Returns:
- the json object describing the location of the service. By convention, this json object should contain
the
ENDPOINT
entry.
-
setLocation
public Record setLocation(JsonObject location)
Sets the json object describing the location of the service. By convention, this json object should contain theENDPOINT
entry.- Parameters:
location
- the location- Returns:
- the current
Record
-
getMetadata
public JsonObject getMetadata()
Gets the metadata attached to the record.- Returns:
- the metadata, cannot be
null
.
-
setMetadata
public Record setMetadata(JsonObject metadata)
-
getName
public String getName()
Gets the name of the service. It can reflect the service name of the name of the provider.- Returns:
- the name
-
setName
public Record setName(String name)
Sets the name of the service. It can reflect the service name of the name of the provider.- Parameters:
name
- the name- Returns:
- the current
Record
-
getStatus
public Status getStatus()
Gets the current status of the service.- Returns:
- the status.
-
setStatus
public Record setStatus(Status status)
Sets the status of the service. When published, the status is set toStatus.UP
. When withdrawn, the status is set toStatus.DOWN
.- Parameters:
status
- the status, must not benull
- Returns:
- the current
Record
-
setRegistration
public Record setRegistration(String reg)
Sets the registration id. This method is called when the service is published.- Parameters:
reg
- the registration id- Returns:
- the current
Record
-
getRegistration
public String getRegistration()
Gets the registration id if any. Getting anull
result means that the record has not been published.- Returns:
- the registration id.
-
getType
public String getType()
Gets the service type. The type represents what kind of "resource" is represented by this record. For example it can be "http-endpoint", "database", "message-source"... The set of types is extensible.The type defines how the the service object is retrieved, and also manages the binding. Some records may have no type and let the consumer manage how the service is used.
- Returns:
- the type
-
setType
public Record setType(String type)
Sets the type of service.- Parameters:
type
- the type- Returns:
- the current
Record
-
match
public boolean match(JsonObject filter)
Checks whether or not the currentRecord
matches the filter.- Parameters:
filter
- the filter- Returns:
- whether or not the record matches the filter
-
equals
public boolean equals(Object o)
Checks whether or not the current object is equal to the given object.
-
hashCode
public int hashCode()
-
-