client

package
v0.2.33 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SRVResolver = func(serviceName, srvName string) ([]*url.URL, error) {
	_, records, err := net.LookupSRV(serviceName, "udp", srvName)
	if err != nil {
		return nil, err
	}
	urls := make([]*url.URL, len(records))
	for i := range records {
		urls[i] = &url.URL{Scheme: util.DiscoveryDirectProtocol, Host: net.JoinHostPort(strings.TrimSuffix(records[i].Target, "."), fmt.Sprint(records[i].Port))}
	}
	return urls, nil
}

Functions

This section is empty.

Types

type Dialer

type Dialer map[string]Protocol

func New

func New() *Dialer

func (*Dialer) Dial

func (d *Dialer) Dial(Context context.Context, URL *url.URL) (net.Conn, error)

Dial creates a connection to a channel with "URL". This URL can be a URL from a discovery server, or a protocol registered in `RegisterProtocol`.

func (*Dialer) RegisterProtocol

func (d *Dialer) RegisterProtocol(Name string, Protocol Protocol)

RegisterProtocol registers a protocol handler in the dialer.

type DialerContext

type DialerContext interface {
	DialContext(context.Context, string, string) (net.Conn, error)
}

type DiscoveryConfig

type DiscoveryConfig struct {
	UnderlyingDialer *Dialer

	ProbeTimeout                   time.Duration
	CachedDiscoveryConnIdleTimeout time.Duration
	// contains filtered or unexported fields
}

type Protocol

type Protocol interface {
	DialContext(context.Context, *url.URL) (net.Conn, error)
}

func DiscoveryProtocol

func DiscoveryProtocol(TransportProtocol string, Config *DiscoveryConfig) Protocol

Dial to an empty path means dial to the discovery server itself.

func NetDialerProtocol

func NetDialerProtocol(network string, dialer DialerContext) Protocol

Jump to

Keyboard shortcuts

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