Documentation ¶
Overview ¶
Package hubclient with client for Hub gateway service discovery
Package hubclient with client for DNS-SD service discovery ¶
Package discovery to publish Hub services for discovery
Index ¶
- Constants
- func DiscoverService(serviceType string, waitTime time.Duration, firstResult bool) (address string, port int, params map[string]string, ...)
- func DnsSDScan(serviceType string, waitTime time.Duration, firstResult bool) ([]*zeroconf.ServiceEntry, error)
- func LocateHub(searchTime time.Duration, firstResult bool) (fullURL string, core string)
- func ServeDiscovery(instanceID string, serviceName string, address string, port int, ...) (*zeroconf.Server, error)
Constants ¶
const HIVEOT_DNSSD_TYPE = "_hiveot._tcp"
Variables ¶
This section is empty.
Functions ¶
func DiscoverService ¶
func DiscoverService(serviceType string, waitTime time.Duration, firstResult bool) ( address string, port int, params map[string]string, records []*zeroconf.ServiceEntry, err error)
DiscoverService searches for services with the given type and returns all its instances. This is a wrapper around various means of discovering services and supports the discovery of multiple instances of the same service (name). The serviceName must contain the simple name of the Hub service.
serviceType is the type of service to discover without the "_", eg "hiveot" in "_hiveot._tcp" waitTime is the duration to wait for the result
Returns the first instance address, port and discovery parameters, plus records of additional discoveries, or an error if nothing is found
func DnsSDScan ¶
func DnsSDScan(serviceType string, waitTime time.Duration, firstResult bool) ([]*zeroconf.ServiceEntry, error)
DnsSDScan scans zeroconf publications on local domain The zeroconf library does not support browsing of all services, but a workaround is to search the service types with "_services._dns-sd._udp" then query each of the service types.
serviceType to look for in format "_name._tcp", or "" to discover all service types (not all services) waitTime with duration to wait while collecting results. 0 means exit on the first result. firstResult return immediatel
func LocateHub ¶
LocateHub determines the nats URL to use. This first checks if a local connection can be made on the default port. Secondly, perform a DNS-SD search. If firstResult is set then return immediately after the first result or searchTime
func ServeDiscovery ¶
func ServeDiscovery(instanceID string, serviceName string, address string, port int, params map[string]string) (*zeroconf.Server, error)
ServeDiscovery publishes a service for discovery. See also 'DiscoverService' for discovery of this published service.
WoST services use this to announce the service instance and how they can be reached on the local domain.
Instance = instance name of the service. Used to differentiate between services with the same name (type) DiscoveryServiceName = name of the provided service, for example, ipp, idprov, hiveot
This is a wrapper around one or more discovery methods. Internally this uses DNS-SD but can be expanded with additional protocols in the future.
DNS-SD will publish this as _<instance>._<serviceName>._tcp instanceID is the unique ID of the service instance, usually the plugin-ID serviceName is the discover name. For example "hiveot" address service listening IP address port service listing port params is a map of key-value pairs to include in discovery, eg rawURL
Returns the discovery service instance. Use Shutdown() when done.
Types ¶
This section is empty.