Documentation ¶
Index ¶
- func AddressesForApplication(upstreamMap map[Upstream][]Application, app Application) (addresses []string)
- type Application
- type BackendConfig
- type BackendDelegate
- type BackendMetadata
- type BackendResponder
- type DummyGenerator
- type Generator
- type JSONApplication
- type LoadBalancerConfig
- type LoadBalancerDelegate
- func (d *LoadBalancerDelegate) GetBroadcasts(overhead int, limit int) [][]byte
- func (d *LoadBalancerDelegate) LocalState(join bool) []byte
- func (d *LoadBalancerDelegate) MergeRemoteState(buf []byte, join bool)
- func (d *LoadBalancerDelegate) NodeMeta(limit int) []byte
- func (d *LoadBalancerDelegate) NotifyMsg(msg []byte)
- type LoadBalancerEventDelegate
- type LoadBalancerState
- type NginxGenerator
- type PushTask
- type ScrimpConfig
- type Upstream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressesForApplication ¶
func AddressesForApplication(upstreamMap map[Upstream][]Application, app Application) (addresses []string)
AddressesForApplication returns a string slice which details all backend addresses for the given application in an UpstreamApplicationMap.
Types ¶
type Application ¶
type Application struct { Name string ListenPort string ApplicationPort string Protocol string // contains filtered or unexported fields }
Application is a service running on a backend. A backend will respond with a list of Applications when queried by a load balancer.
func (*Application) DomainSlice ¶
func (a *Application) DomainSlice() []string
DomainSlice returns domains as a []string
func (*Application) DomainString ¶
func (a *Application) DomainString(sep string) string
DomainString returns the domain list as a string separated by `sep`
func (*Application) Equal ¶
func (a *Application) Equal(other Application) bool
Equal implements an equality check for two Applications
type BackendConfig ¶
type BackendConfig struct { Applications []JSONApplication `json:"applications"` ApplicationConfigDir string `json:"application-config-dir"` }
BackendConfig describes configuration for backend instances
type BackendDelegate ¶
type BackendDelegate struct {
// contains filtered or unexported fields
}
BackendDelegate listens for messages from other cluster members requesting details about a backend.
func NewBackendDelegate ¶
func NewBackendDelegate(config *BackendConfig) (*BackendDelegate, error)
NewBackendDelegate creates a BackendDelegate from a channel which receives work tasks
func (*BackendDelegate) GetBroadcasts ¶
func (b *BackendDelegate) GetBroadcasts(overhead int, limit int) [][]byte
GetBroadcasts is ingored for BackendDelegate
func (*BackendDelegate) LocalState ¶
func (b *BackendDelegate) LocalState(join bool) []byte
LocalState is ignored for a BackendDelegate
func (*BackendDelegate) MergeRemoteState ¶
func (b *BackendDelegate) MergeRemoteState(buf []byte, join bool)
MergeRemoteState is ignored for BackendDelegate
func (*BackendDelegate) NodeMeta ¶
func (b *BackendDelegate) NodeMeta(limit int) []byte
NodeMeta returns metadata about this backend, including a list of supported applications
func (*BackendDelegate) NotifyMsg ¶
func (b *BackendDelegate) NotifyMsg(msg []byte)
NotifyMsg receives messages from other cluster members. If the message was intended for a backend, it is processed and a reply is scheduled if needed.
type BackendMetadata ¶
type BackendMetadata struct { Type string `json:"type"` Applications []JSONApplication `json:"applications"` }
BackendMetadata is returned by node metadata in the cluster, and describes supported applications on the backend.
type BackendResponder ¶
type BackendResponder struct {
Config *BackendConfig
}
BackendResponder responds to queries from load balancers about running applications
func NewBackendResponder ¶
func NewBackendResponder(config *BackendConfig) *BackendResponder
NewBackendResponder creates a new BackendResponder from given config.
type DummyGenerator ¶
type DummyGenerator struct { }
DummyGenerator produces only dummy config.
func (DummyGenerator) GenerateConfig ¶
func (d DummyGenerator) GenerateConfig(upstreamMap map[Upstream][]Application, config *ScrimpConfig) (string, error)
GenerateConfig returns a stable string and never an error
func (DummyGenerator) HandleRestart ¶
func (d DummyGenerator) HandleRestart() error
HandleRestart returns no error and does nothing
type Generator ¶
type Generator interface { GenerateConfig(map[Upstream][]Application, *ScrimpConfig) (string, error) HandleRestart() error }
Generator provides an interface for generating configuration values based on backend configuration
type JSONApplication ¶
type JSONApplication struct { Name string `json:"name"` ListenPort string `json:"listen-port"` ApplicationPort string `json:"application-port"` Protocol string `json:"protocol"` Domains []string `json:"domains"` }
JSONApplication is a helper for loading applications with string slices for Domains
func (*JSONApplication) ToApplication ¶
func (a *JSONApplication) ToApplication() Application
ToApplication turns a JSON loaded application into an application. This is needed to keep Applications comparable (since slices aren't) and therefore usable as map keys.
type LoadBalancerConfig ¶
type LoadBalancerConfig struct { PushPeriodRaw string `json:"push-period"` PushJitterRaw string `json:"jitter"` GeneratorType string `json:"generator"` GeneratorTarget string `json:"generator-target"` GeneratorPrintStdout bool `json:"generator-stdout"` TLSChainLocation string `json:"tls-chain-location"` TLSKeyLocation string `json:"tls-key-location"` Generator Generator PushPeriod time.Duration PushJitter time.Duration }
LoadBalancerConfig describes configuration options specific to load balancers.
type LoadBalancerDelegate ¶
type LoadBalancerDelegate struct {
// contains filtered or unexported fields
}
LoadBalancerDelegate listens for requests from backend instances for information and schedules replies
func NewLoadBalancerDelegate ¶
func NewLoadBalancerDelegate(ch chan<- string) (*LoadBalancerDelegate, error)
NewLoadBalancerDelegate creates a LoadBalancerDelegate from a channel which is used to receive work tasks
func (*LoadBalancerDelegate) GetBroadcasts ¶
func (d *LoadBalancerDelegate) GetBroadcasts(overhead int, limit int) [][]byte
GetBroadcasts is ignored for LoadBalancerDelegate
func (*LoadBalancerDelegate) LocalState ¶
func (d *LoadBalancerDelegate) LocalState(join bool) []byte
LocalState is ignored for LoadBalancerDelegate
func (*LoadBalancerDelegate) MergeRemoteState ¶
func (d *LoadBalancerDelegate) MergeRemoteState(buf []byte, join bool)
MergeRemoteState is ignored for LoadBalancerDelegate
func (*LoadBalancerDelegate) NodeMeta ¶
func (d *LoadBalancerDelegate) NodeMeta(limit int) []byte
NodeMeta returns metadata about this node
func (*LoadBalancerDelegate) NotifyMsg ¶
func (d *LoadBalancerDelegate) NotifyMsg(msg []byte)
NotifyMsg receives messages from other cluster members. If the message was intended for a Load Balancer, it is processed and a reply is scheduled if needed.
type LoadBalancerEventDelegate ¶
type LoadBalancerEventDelegate struct { State LoadBalancerState UpstreamNotificationChannel chan<- *LoadBalancerState }
LoadBalancerEventDelegate listens for events and updates load balancer state based on node metadata
func NewLoadBalancerEventDelegate ¶
func NewLoadBalancerEventDelegate(notificationChannel chan<- *LoadBalancerState) LoadBalancerEventDelegate
NewLoadBalancerEventDelegate creates a new LoadBalancerEventDelegate
func (*LoadBalancerEventDelegate) NotifyJoin ¶
func (d *LoadBalancerEventDelegate) NotifyJoin(node *memberlist.Node)
NotifyJoin adds new nodes to load balancer state
func (*LoadBalancerEventDelegate) NotifyLeave ¶
func (d *LoadBalancerEventDelegate) NotifyLeave(node *memberlist.Node)
NotifyLeave removes existing nodes from load balancer state
func (*LoadBalancerEventDelegate) NotifyUpdate ¶
func (d *LoadBalancerEventDelegate) NotifyUpdate(node *memberlist.Node)
NotifyUpdate updates existing nodes in load balancer state
type LoadBalancerState ¶
type LoadBalancerState struct { MemberMap map[Upstream][]Application // contains filtered or unexported fields }
LoadBalancerState provides state which is maintained by a load balancer relating to the nodes in the cluster that it might forward on to.
func NewLoadBalancerState ¶
func NewLoadBalancerState() LoadBalancerState
NewLoadBalancerState creates a load balancer state
type NginxGenerator ¶
type NginxGenerator struct { }
NginxGenerator produces nginx upstream blocks for use for by an nginx load balancer
func (NginxGenerator) GenerateConfig ¶
func (n NginxGenerator) GenerateConfig(upstreamMap map[Upstream][]Application, config *ScrimpConfig) (string, error)
GenerateConfig returns nginx upstream config for the given UpstreamApplicationMap
func (NginxGenerator) HandleRestart ¶
func (n NginxGenerator) HandleRestart() error
HandleRestart assumes we're running on a systemd system and that we have access via sudo to restart nginx
type PushTask ¶
type PushTask struct {
// contains filtered or unexported fields
}
PushTask runs a Pusher on a regular, config-defined basis
func NewPushTask ¶
func NewPushTask(config *ScrimpConfig) *PushTask
NewPushTask creates a new PushTask with the given config
type ScrimpConfig ¶
type ScrimpConfig struct { IsLoadBalancer bool `json:"lb"` BindAddress string `json:"bind-address"` PortRaw string `json:"port"` ProviderName string `json:"provider"` ProviderConfig map[string]interface{} `json:"provider-config"` ResolverName string `json:"resolver"` LoadBalancerConfig *LoadBalancerConfig `json:"load-balancer-config"` BackendConfig *BackendConfig `json:"backend-config"` Port int Provider seed.Provider Resolver resolver.IPResolver }
ScrimpConfig describes JSON configuration options for Scrimp overall.
func LoadScrimpConfig ¶
func LoadScrimpConfig(configFile string) (*ScrimpConfig, error)
LoadScrimpConfig loads the given config file and parses fields which need to be parsed