Documentation ¶
Index ¶
- Constants
- Variables
- func DialConn(ctx context.Context, addr string, tlsConfig *tls.Config) (net.Conn, error)
- func Manifold(config ManifoldConfig) dependency.Manifold
- func NewWorker(config Config) (worker.Worker, error)
- func NewWorkerShim(config Config) (worker.Worker, error)
- type Config
- type DialConnFunc
- type Dialer
- type Handler
- type ManifoldConfig
- type Worker
Constants ¶
const ( // AddrTimeout is how long we'll wait for a good address to be // sent before timing out in the Addr call - this is better than // hanging indefinitely. AddrTimeout = 1 * time.Minute )
Variables ¶
var ( // ErrAddressTimeout is used as the death reason when this transport dies because no good API address has been sent. ErrAddressTimeout = errors.New("timed out waiting for API address") )
Functions ¶
func DialConn ¶
DialConn dials a TLS connection to the API server with the given address, using the given TLS configuration. This will be used for requesting the raft endpoint, upgrading to a raw connection for inter-node raft communications.
TODO: this function needs to be made proxy-aware.
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a dependency.Manifold that will run an apiserver-based raft transport worker.
func NewWorker ¶
NewWorker returns a new apiserver-based raft transport worker, with the given configuration. The worker itself implements raft.Transport.
func NewWorkerShim ¶
NewWorkerShim calls straight through to NewWorker. This exists only to adapt to the signature of ManifoldConfig.NewWorker.
Types ¶
type Config ¶
type Config struct { // APIInfo contains the information, excluding addresses, // required to connect to an API server. APIInfo *api.Info // Authenticator is the HTTP request authenticator to use for // the raft endpoint. Authenticator httpcontext.Authenticator // DialConn is the function to use for dialing connections to // other API servers. DialConn DialConnFunc // Hub is the central hub to which the worker will subscribe // for notification of local address changes. Hub *pubsub.StructuredHub // Mux is the API server HTTP mux into which the handler will // be installed. Mux *apiserverhttp.Mux // Path is the path of the raft HTTP endpoint. Path string // LocalID is the raft.ServerID of the agent running this worker. LocalID raft.ServerID // Timeout, if non-zero, is the timeout to apply to transport // operations. See raft.NetworkTransportConfig.Timeout for more // details. Timeout time.Duration // TLSConfig is the TLS configuration to use for making // connections to API servers. TLSConfig *tls.Config // Clock is used for timing out the Addr getter - if the // peergrouper isn't publishing good API addresses in a timely // fashion it's better to fail and log than to hang indefinitely. Clock clock.Clock }
Config is the configuration required for running an apiserver-based raft transport worker.
type DialConnFunc ¶
DialConnFunc is type of function used by the transport for dialing a TLS connection to another API server. The worker will send an HTTP request over the connection to upgrade it.
type Dialer ¶
type Dialer struct { // APIInfo is used for authentication. APIInfo *api.Info // DialRaw returns a connection to the HTTP server // that is serving the raft endpoint. DialRaw func(raft.ServerAddress, time.Duration) (net.Conn, error) // Path is the path of the raft HTTP endpoint. Path string }
Dialer is a type that can be used for dialling a connection connecting to a raft endpoint using the configured path, and upgrading to a raft connection.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is an http.Handler suitable for serving an endpoint that upgrades to raft transport connections.
func NewHandler ¶
NewHandler returns a new Handler that sends connections to the given connections channel, and stops accepting connections after the abort channel is closed.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is part of the http.Handler interface.
ServeHTTP checks for "raft" upgrade requests, and hijacks those connections for use as a raw connection for raft communications.
Based on code from https://github.com/CanonicalLtd/raft-http.
type ManifoldConfig ¶
type ManifoldConfig struct { ClockName string AgentName string AuthenticatorName string HubName string MuxName string DialConn DialConnFunc NewWorker func(Config) (worker.Worker, error) // Path is the path of the raft HTTP endpoint. Path string }
ManifoldConfig holds the information necessary to run an apiserver-based raft transport worker in a dependency.Engine.
func (ManifoldConfig) Validate ¶
func (config ManifoldConfig) Validate() error
Validate validates the manifold configuration.