router

package
v0.0.0-...-c283e9f Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2021 License: BSD-3-Clause Imports: 2 Imported by: 28

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Service string `json:"service"`
	Addr    string `json:"addr"`
	App     string `json:"app"`
	JobID   string `json:"job_id"`
}

type Certificate

type Certificate struct {
	// ID is the unique ID of this Certificate
	ID string `json:"id,omitempty"`
	// Routes contains the IDs of routes assigned to this cert
	Routes []string `json:"routes,omitempty"`
	// TLSCert is the optional TLS public certificate. It is only used for HTTP routes.
	Cert string `json:"cert,omitempty"`
	// TLSCert is the optional TLS private key. It is only used for HTTP routes.
	Key string `json:"key,omitempty"`
	// CreatedAt is the time this cert was created.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt is the time this cert was last updated.
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Certificate describes a TLS certificate for one or more routes

type Event

type Event struct {
	Event   EventType
	ID      string
	Route   *Route
	Backend *Backend
	Error   error
}

type EventType

type EventType string
const (
	EventTypeRouteSet       EventType = "set"
	EventTypeRouteRemove    EventType = "remove"
	EventTypeBackendUp      EventType = "backend-up"
	EventTypeBackendDown    EventType = "backend-down"
	EventTypeBackendDrained EventType = "backend-drained"
)

type HTTPRoute

type HTTPRoute struct {
	ID            string
	ParentRef     string
	Service       string
	Port          int
	Leader        bool
	DrainBackends bool
	CreatedAt     time.Time
	UpdatedAt     time.Time

	Domain            string
	Certificate       *Certificate `json:"certificate,omitempty"`
	LegacyTLSCert     string       `json:"tls_cert,omitempty"`
	LegacyTLSKey      string       `json:"tls_key,omitempty"`
	Sticky            bool
	Path              string
	DisableKeepAlives bool
}

HTTPRoute is an HTTP Route.

func (HTTPRoute) FormattedID

func (r HTTPRoute) FormattedID() string

func (HTTPRoute) MarshalJSON

func (r HTTPRoute) MarshalJSON() ([]byte, error)

func (HTTPRoute) ToRoute

func (r HTTPRoute) ToRoute() *Route

type Route

type Route struct {
	// Type is the type of Route, either "http" or "tcp".
	Type string `json:"type"`
	// ID is the unique ID of this route.
	ID string `json:"id,omitempty"`
	// ParentRef is an external opaque identifier used by the route creator for
	// filtering and correlation. It typically contains the app ID.
	ParentRef string `json:"parent_ref,omitempty"`
	// Service is the ID of the service.
	Service string `json:"service"`
	// Port is the TCP port to listen on.
	Port int32 `json:"port,omitempty"`
	// Leader is whether or not traffic should only be routed to the leader or
	// all instances
	Leader bool `json:"leader"`
	// CreatedAt is the time this Route was created.
	CreatedAt time.Time `json:"created_at,omitempty"`
	// UpdatedAt is the time this Route was last updated.
	UpdatedAt time.Time `json:"updated_at,omitempty"`

	// Domain is the domain name of this Route. It is only used for HTTP routes.
	Domain string `json:"domain,omitempty"`

	// Certificate contains TLSCert and TLSKey
	Certificate *Certificate `json:"certificate,omitempty"`

	// Deprecated in favor of Certificate
	LegacyTLSCert string `json:"tls_cert,omitempty"`
	LegacyTLSKey  string `json:"tls_key,omitempty"`

	// Sticky is whether or not to use sticky sessions for this route. It is only
	// used for HTTP routes.
	Sticky bool `json:"sticky,omitempty"`
	// Path is the optional prefix to route to this service. It's exclusive with
	// the TLS options and can only be set if a "default" route with the same domain
	// and no Path already exists in the route table.
	Path string `json:"path,omitempty"`

	// DrainBackends is whether or not to track requests and trigger
	// drain events on backend shutdown when all requests have completed
	// (used by the scheduler to only stop jobs once all requests have
	// completed).
	DrainBackends bool `json:"drain_backends,omitempty"`

	// DisableKeepAlives when set will disable keep-alives between the
	// router and backends for this route
	DisableKeepAlives bool `json:"disable_keep_alives,omitempty"`
}

Route is a struct that combines the fields of HTTPRoute and TCPRoute for easy JSON marshaling.

func (Route) FormattedID

func (r Route) FormattedID() string

func (Route) HTTPRoute

func (r Route) HTTPRoute() *HTTPRoute

func (Route) TCPRoute

func (r Route) TCPRoute() *TCPRoute

type StreamEvent

type StreamEvent struct {
	Event   EventType `json:"event"`
	Route   *Route    `json:"route,omitempty"`
	Backend *Backend  `json:"backend,omitempty"`
	Error   error     `json:"error,omitempty"`
}

type StreamEventsOptions

type StreamEventsOptions struct {
	EventTypes []EventType
}

type TCPRoute

type TCPRoute struct {
	ID            string
	ParentRef     string
	Service       string
	Port          int
	Leader        bool
	DrainBackends bool
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

TCPRoute is a TCP Route.

func (TCPRoute) FormattedID

func (r TCPRoute) FormattedID() string

func (TCPRoute) MarshalJSON

func (r TCPRoute) MarshalJSON() ([]byte, error)

func (TCPRoute) ToRoute

func (r TCPRoute) ToRoute() *Route

Jump to

Keyboard shortcuts

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