juju: github.com/juju/juju/worker/raft/rafttransport Index | Files

package rafttransport

import "github.com/juju/juju/worker/raft/rafttransport"

Index

Package Files

dialer.go doc.go errors.go handler.go manifold.go shim.go streamlayer.go worker.go

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")
)

func DialConn Uses

func DialConn(ctx context.Context, addr string, tlsConfig *tls.Config) (net.Conn, error)

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 Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run an apiserver-based raft transport worker.

func NewWorker Uses

func NewWorker(config Config) (worker.Worker, error)

NewWorker returns a new apiserver-based raft transport worker, with the given configuration. The worker itself implements raft.Transport.

func NewWorkerShim Uses

func NewWorkerShim(config Config) (worker.Worker, error)

NewWorkerShim calls straight through to NewWorker. This exists only to adapt to the signature of ManifoldConfig.NewWorker.

type Config Uses

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.

func (Config) Validate Uses

func (config Config) Validate() error

Validate validates the raft worker configuration.

type DialConnFunc Uses

type DialConnFunc func(ctx context.Context, addr string, tlsConfig *tls.Config) (net.Conn, error)

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 Uses

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.

func (*Dialer) Dial Uses

func (d *Dialer) Dial(addr raft.ServerAddress, timeout time.Duration) (net.Conn, error)

Dial dials a new raft network connection to the controller agent with the tag identified by the given address.

Based on code from https://github.com/CanonicalLtd/raft-http.

type Handler Uses

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 Uses

func NewHandler(
    connections chan<- net.Conn,
    abort <-chan struct{},
) *Handler

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 Uses

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 Uses

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 Uses

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type Worker Uses

type Worker struct {
    raft.Transport
    // contains filtered or unexported fields
}

Worker is a worker that manages a raft.Transport.

func (*Worker) Kill Uses

func (w *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Wait Uses

func (w *Worker) Wait() error

Wait is part of the worker.Worker interface.

Package rafttransport imports 26 packages (graph) and is imported by 3 packages. Updated 2019-08-24. Refresh now. Tools for package owners.