discovery

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: UPL-1.0 Imports: 8 Imported by: 1

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

View Source
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

type NSLookup struct {
	Host string
	Port int
	// contains filtered or unexported fields
}

NSLookup defines a structure to hold NSLookup connections.

func Open

func Open(hostPort string, timeout int32) (*NSLookup, error)

Open returns a NSLookup instance which represents a connection to the NameService of a Coherence cluster, identified by an internal Channel ID.

func (*NSLookup) Close

func (n *NSLookup) Close() error

Close closes the connection.

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.

func (*NSLookup) GetHost

func (n *NSLookup) GetHost() string

GetHost returns the host.

func (*NSLookup) GetPort

func (n *NSLookup) GetPort() int

GetPort returns the port.

func (*NSLookup) Lookup

func (n *NSLookup) Lookup(name string) (string, error)

Lookup looks up a name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL