Documentation ¶
Overview ¶
Package discovery provides an implementation of Coherence NSLookup.
Example:
// open a connection to the default NameService port of 7574 providing a timeout of 5 seconds ns, err := discovery.Open("127.0.0.1:7574", 5) if err != nil { log.Fatal(err) } defer ns.Close() // return the cluster name of the cluster on this port clusterName, err = ns.Lookup(discovery.ClusterNameLookup) if err != nil { log.Fatal(err) } fmt.Println("Cluster name is", clusterName) // lookup other information such as management ports, metrics ports, etc var discoveredCluster discovery.DiscoveredCluster discoveredCluster, err = ns.DiscoverClusterInfo() if err != nil { log.Fatal(err) } fmt.Println("Management URLS", discoveredCluster.ManagementURLs) // lookup any foreign clusters also registered with this port clusterNames, err = ns.Lookup(discovery.NSPrefix + discovery.ClusterForeignLookup) if err != nil { log.Fatal(err) } fmt.Println("Foreign clusters are", clusterNames)
Index ¶
Constants ¶
const ( DefaultPort = 7574 ClusterNameLookup = "Cluster/name" ClusterInfoLookup = "Cluster/info" ClusterForeignLookup = "Cluster/foreign" ManagementLookup = "management/HTTPManagementURL" JMXLookup = "management/JMXServiceURL" MetricsLookup = "metrics/HTTPMetricsURL" GrpcProxyLookup = "$GRPC:GrpcProxy" NSPrefix = "NameService/string/" NSLocalPort = "/NameService/localPort" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterNSPort ¶
type ClusterNSPort struct { HostName string ClusterName string Port int IsLocal bool // indicates this is the cluster owning the NS port queried }
ClusterNSPort defines the cluster Name and local NS lookup ports.
type DiscoveredCluster ¶
type DiscoveredCluster struct { ClusterName string ConnectionName string NSPort int Host string ManagementURLs []string SelectedURL string MetricsURLs []string JMXURLs []string }
DiscoveredCluster defines a discovered cluster.
type NSLookup ¶
NSLookup defines a structure to hold NSLookup connections.
func Open ¶
Open returns a NSLookup instance which represents a connection to the NameService of a Coherence cluster, identified by an internal Channel ID.
func (*NSLookup) DiscoverClusterInfo ¶
func (n *NSLookup) DiscoverClusterInfo() (DiscoveredCluster, error)
DiscoverClusterInfo discovers cluster information for the specific NS this method assumes that we are only interested in the local information as foreign clusters will have already had their ephemeral NS port retrieved.
func (*NSLookup) DiscoverNameServicePorts ¶
func (n *NSLookup) DiscoverNameServicePorts() ([]ClusterNSPort, error)
DiscoverNameServicePorts discovers any clusters bound to the NS port and returns a struct containing each of the ports and the clusters.