discovery

package
v0.0.0-...-2920ad6 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package discovery with client for service discovery

Package discovery to publish Hub services for discovery

Package discoclient with client for DNS-SD service discovery

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoClient

func DiscoClient(serviceName string, waitSec int) (
	address string, port uint, params map[string]string,
	records []*zeroconf.ServiceEntry, err error)

DiscoClient searches for services with the given name 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. For example, use 'idprov' for the provisioning service which DNS-SD will publish as _idprov._tcp.

serviceName is the name of the service to discover
waitSec is the time 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 DiscoServe

func DiscoServe(instanceID string, serviceName string,
	address string, port uint, params map[string]string) (*zeroconf.Server, error)

DiscoServe publishes a Hub service for discovery. See also 'DiscoClient' for discovery of this published service.

Hub 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, wotdir

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 "idprov"
address service listening IP address
port service listing port
params is a map of key-value pairs to include in discovery, for example {path:/idprov/}

Returns the discovery service instance. Use Shutdown() when done.

func DnsSDScan

func DnsSDScan(sdType string, waitSec int) ([]*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, or "" to discover all service types (not all services)

Types

This section is empty.

Jump to

Keyboard shortcuts

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