Package io.vertx.ext.consul
Class PreparedQueryDefinition
- java.lang.Object
-
- io.vertx.ext.consul.PreparedQueryDefinition
-
public class PreparedQueryDefinition extends Object
Defines a prepared query.- Author:
- Ruslan Sennov
-
-
Constructor Summary
Constructors Constructor Description PreparedQueryDefinition()
Default constructorPreparedQueryDefinition(JsonObject json)
Constructor from JSON
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getDcs()
Specifies a fixed list of remote datacenters to forward the query to if there are no healthy nodes in the local datacenter.String
getDnsTtl()
Get the TTL duration when query results are served over DNS.String
getId()
Get ID of the queryMap<String,String>
getMeta()
Get a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.String
getName()
Get an optional friendly name that can be used to execute a query instead of using its IDint
getNearestN()
Specifies that the query will be forwarded to up to NearestN other datacenters based on their estimated network round trip time using Network Coordinates from the WAN gossip pool.boolean
getPassing()
Specifies the behavior of the query's health check filtering.String
getService()
Get the name of the service to queryString
getSession()
Get the ID of an existing session.List<String>
getTags()
Get a list of service tags to filter the query results.String
getTemplateRegexp()
Get regular expression which is used to extract fields from the entire name, once this template is selected.String
getTemplateType()
The template type, which must bename_prefix_match
.String
getToken()
Get the ACL token to use each time the query is executed.PreparedQueryDefinition
setDcs(List<String> dcs)
Specifies a fixed list of remote datacenters to forward the query to if there are no healthy nodes in the local datacenter.PreparedQueryDefinition
setDnsTtl(String dnsTtl)
Set the TTL duration when query results are served over DNS.PreparedQueryDefinition
setId(String id)
Set ID of the query, always generated by ConsulPreparedQueryDefinition
setMeta(Map<String,String> meta)
Set a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.PreparedQueryDefinition
setName(String name)
Set an optional friendly name that can be used to execute a query instead of using its IDPreparedQueryDefinition
setNearestN(int nearestN)
Specifies that the query will be forwarded to up to NearestN other datacenters based on their estimated network round trip time using Network Coordinates from the WAN gossip pool.PreparedQueryDefinition
setPassing(boolean passing)
Specifies the behavior of the query's health check filtering.PreparedQueryDefinition
setService(String service)
Set the name of the service to queryPreparedQueryDefinition
setSession(String session)
Set the ID of an existing session.PreparedQueryDefinition
setTags(List<String> tags)
Set a list of service tags to filter the query results.PreparedQueryDefinition
setTemplateRegexp(String templateRegexp)
Set regular expression which is used to extract fields from the entire name, once this template is selected.PreparedQueryDefinition
setTemplateType(String templateType)
The template type, which must bename_prefix_match
.PreparedQueryDefinition
setToken(String token)
Set the ACL token to use each time the query is executed.JsonObject
toJson()
Convert to JSON
-
-
-
Constructor Detail
-
PreparedQueryDefinition
public PreparedQueryDefinition()
Default constructor
-
PreparedQueryDefinition
public PreparedQueryDefinition(JsonObject json)
Constructor from JSON- Parameters:
json
- the JSON
-
-
Method Detail
-
toJson
public JsonObject toJson()
Convert to JSON- Returns:
- the JSON
-
getId
public String getId()
Get ID of the query- Returns:
- ID of the query
-
setId
public PreparedQueryDefinition setId(String id)
Set ID of the query, always generated by Consul- Parameters:
id
- ID of the query- Returns:
- reference to this, for fluency
-
getName
public String getName()
Get an optional friendly name that can be used to execute a query instead of using its ID- Returns:
- name of the query
-
setName
public PreparedQueryDefinition setName(String name)
Set an optional friendly name that can be used to execute a query instead of using its ID- Parameters:
name
- name of the query- Returns:
- reference to this, for fluency
-
getSession
public String getSession()
Get the ID of an existing session. This provides a way to automatically remove a prepared query when the given session is invalidated. If not given the prepared query must be manually removed when no longer needed.- Returns:
- id of session
-
setSession
public PreparedQueryDefinition setSession(String session)
Set the ID of an existing session. This provides a way to automatically remove a prepared query when the given session is invalidated. If not given the prepared query must be manually removed when no longer needed.- Parameters:
session
- id of session- Returns:
- reference to this, for fluency
-
getService
public String getService()
Get the name of the service to query- Returns:
- service name
-
setService
public PreparedQueryDefinition setService(String service)
Set the name of the service to query- Parameters:
service
- service name- Returns:
- reference to this, for fluency
-
getToken
public String getToken()
Get the ACL token to use each time the query is executed. This allows queries to be executed by clients with lesser or even no ACL Token, so this should be used with care.- Returns:
- the ACL token
-
setToken
public PreparedQueryDefinition setToken(String token)
Set the ACL token to use each time the query is executed. This allows queries to be executed by clients with lesser or even no ACL Token, so this should be used with care.- Parameters:
token
- the ACL token- Returns:
- reference to this, for fluency
-
getDnsTtl
public String getDnsTtl()
Get the TTL duration when query results are served over DNS. If this is specified, it will take precedence over any Consul agent-specific configuration.- Returns:
- the TTL duration
-
setDnsTtl
public PreparedQueryDefinition setDnsTtl(String dnsTtl)
Set the TTL duration when query results are served over DNS. If this is specified, it will take precedence over any Consul agent-specific configuration.- Parameters:
dnsTtl
- the TTL duration- Returns:
- reference to this, for fluency
-
getNearestN
public int getNearestN()
Specifies that the query will be forwarded to up to NearestN other datacenters based on their estimated network round trip time using Network Coordinates from the WAN gossip pool. The median round trip time from the server handling the query to the servers in the remote datacenter is used to determine the priority.- Returns:
- number of nearest datacenters to query
-
setNearestN
public PreparedQueryDefinition setNearestN(int nearestN)
Specifies that the query will be forwarded to up to NearestN other datacenters based on their estimated network round trip time using Network Coordinates from the WAN gossip pool. The median round trip time from the server handling the query to the servers in the remote datacenter is used to determine the priority.- Parameters:
nearestN
- number of nearest datacenters to query- Returns:
- reference to this, for fluency
-
getDcs
public List<String> getDcs()
Specifies a fixed list of remote datacenters to forward the query to if there are no healthy nodes in the local datacenter. Datacenters are queried in the order given in the list. If this option is combined with NearestN, then the NearestN queries will be performed first, followed by the list given by Datacenters. A given datacenter will only be queried one time during a failover, even if it is selected by both NearestN and is listed in Datacenters.- Returns:
- the list of remote datacenters
-
setDcs
public PreparedQueryDefinition setDcs(List<String> dcs)
Specifies a fixed list of remote datacenters to forward the query to if there are no healthy nodes in the local datacenter. Datacenters are queried in the order given in the list. If this option is combined with NearestN, then the NearestN queries will be performed first, followed by the list given by Datacenters. A given datacenter will only be queried one time during a failover, even if it is selected by both NearestN and is listed in Datacenters.- Parameters:
dcs
- the list of remote datacenters- Returns:
- reference to this, for fluency
-
getTags
public List<String> getTags()
Get a list of service tags to filter the query results. For a service to pass the tag filter it must have all of the required tags, and none of the excluded tags (prefixed with `!`).- Returns:
- list of service tags
-
setTags
public PreparedQueryDefinition setTags(List<String> tags)
Set a list of service tags to filter the query results. For a service to pass the tag filter it must have all of the required tags, and none of the excluded tags (prefixed with `!`).- Parameters:
tags
- list of service tags- Returns:
- reference to this, for fluency
-
getPassing
public boolean getPassing()
Specifies the behavior of the query's health check filtering. If this is set to false, the results will include nodes with checks in the passing as well as the warning states. If this is set to true, only nodes with checks in the passing state will be returned.- Returns:
- the passing flag
-
setPassing
public PreparedQueryDefinition setPassing(boolean passing)
Specifies the behavior of the query's health check filtering. If this is set to false, the results will include nodes with checks in the passing as well as the warning states. If this is set to true, only nodes with checks in the passing state will be returned.- Parameters:
passing
- the passing flag- Returns:
- reference to this, for fluency
-
getMeta
public Map<String,String> getMeta()
Get a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.- Returns:
- list of key/value pairs
-
setMeta
public PreparedQueryDefinition setMeta(Map<String,String> meta)
Set a list of user-defined key/value pairs that will be used for filtering the query results to nodes with the given metadata values present.- Parameters:
meta
- list of key/value pairs- Returns:
- reference to this, for fluency
-
getTemplateType
public String getTemplateType()
The template type, which must bename_prefix_match
. This means that the template will apply to any query lookup with a name whose prefix matches the Name field of the template.- Returns:
- the query type
- See Also:
- Prepared Query Templates endpoint
-
setTemplateType
public PreparedQueryDefinition setTemplateType(String templateType)
The template type, which must bename_prefix_match
. This means that the template will apply to any query lookup with a name whose prefix matches the Name field of the template.- Parameters:
templateType
- the query type- Returns:
- reference to this, for fluency
- See Also:
- Prepared Query Templates endpoint
-
getTemplateRegexp
public String getTemplateRegexp()
Get regular expression which is used to extract fields from the entire name, once this template is selected.- Returns:
- a regular expression
- See Also:
- Prepared Query Templates endpoint
-
setTemplateRegexp
public PreparedQueryDefinition setTemplateRegexp(String templateRegexp)
Set regular expression which is used to extract fields from the entire name, once this template is selected.- Parameters:
templateRegexp
- a regular expression- Returns:
- reference to this, for fluency
- See Also:
- Prepared Query Templates endpoint
-
-