Documentation ¶
Overview ¶
Functions for abstracting target resolution for establishing new network connections by using URLs.
Index ¶
- func Connect(tourl string) (net.Conn, error)
- func ConnectContext(ctx context.Context, tourl string) (net.Conn, error)
- func ConnectTimeout(tourl string, timeout time.Duration) (net.Conn, error)
- func RegisterConnectionHandler(name string, handler ConnectionHandler)
- func SetupEtcd(servers []string, cert, key, ca string) error
- func UseExistingEtcd(client *clientv3.Client)
- type ConnectionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
Connect establishes a new connection to the URL, determining the correct handler to use for the schema. For example, tcp://[::1]:8080 will establish a TCP connection to port 8080 on localhost, as will tcp://[::1]/8080.
func ConnectContext ¶
ConnectContext establishes a new connection to the URL, passing the context down to the handler and determining the correct handler to use for the schema. For example, tcp://[::1]:8080 will establish a TCP connection to port 8080 on localhost, as will tcp://[::1]/8080.
func ConnectTimeout ¶
ConnectTimeout establishes a new connection to the URL, waiting at most the specified timeout for the connection to be established, determining the correct handler to use for the schema. For example, tcp://[::1]:8080 will establish a TCP connection to port 8080 on localhost, as will tcp://[::1]/8080.
func RegisterConnectionHandler ¶
func RegisterConnectionHandler(name string, handler ConnectionHandler)
RegisterConnectionHandler is used by connection APIs to register their handlers. The URL schema "name" (the part before the dot, i.e. name://...) will be associated with the "handler", which creates connections.
func SetupEtcd ¶
SetupEtcd instantiates an etcd connection handler with a new etcd client configured from the parameters passed.
cert, key and ca are optional; if empty strings are passed, an unencrypted connection will be used.
func UseExistingEtcd ¶
UseExistingEtcd instantiates an etcd connection handler pointing at a preconfigured etcd client.
Types ¶
type ConnectionHandler ¶
type ConnectionHandler interface { Connect(ctx context.Context, dest *url.URL) (net.Conn, error) ConnectTimeout(ctx context.Context, dest *url.URL, timeout time.Duration) (net.Conn, error) }
ConnectionHandler specifies the basic functionality which must be provided by any connection setup handlers in order to be registered.