Documentation ¶
Index ¶
- Constants
- type Manager
- func (m *Manager) AcquireLock(name string, timeout bool) (interface{}, error)
- func (m *Manager) AddSite(site *SiteState) error
- func (m *Manager) ClusterHealth() (map[string]*utils.NodeStatus, error)
- func (m *Manager) DeleteSecret(key string) error
- func (m *Manager) DeleteSite(domain string) error
- func (m *Manager) DumpState() (*NodeState, error)
- func (m *Manager) GetAllSiteHealth() SiteHealth
- func (m *Manager) GetCertificate(typ string, nameOrDomains []string) (key []byte, cert []byte, err error)
- func (m *Manager) GetDHParams() (string, *time.Time)
- func (m *Manager) GetNodeHealth() *utils.NodeStatus
- func (m *Manager) GetSecret(key string) ([]byte, error)
- func (m *Manager) GetSite(domain string) *SiteState
- func (m *Manager) GetSiteHealth(domain string) error
- func (m *Manager) GetSites() []SiteState
- func (m *Manager) GetStore() StateStore
- func (m *Manager) GetStoreType() string
- func (m *Manager) Init() (err error)
- func (m *Manager) LastUpdated() *time.Time
- func (m *Manager) ListImportedCertificates() (res []string)
- func (m *Manager) OnStateUpdate(callback func())
- func (m *Manager) ReleaseLock(leaseID interface{}) error
- func (m *Manager) RemoveCertificate(typ string, nameOrDomains []string) (err error)
- func (m *Manager) ReplaceState(state *NodeState) error
- func (m *Manager) SetCertificate(typ string, nameOrDomains []string, key []byte, cert []byte) (err error)
- func (m *Manager) SetDHParams(val string) error
- func (m *Manager) SetNodeHealth(health *utils.NodeStatus) error
- func (m *Manager) SetSecret(key string, value []byte) error
- func (m *Manager) SetSiteHealth(domain string, err error)
- func (m *Manager) StoreHealth() (healthy bool, err error)
- func (m *Manager) TriggerRefreshCerts()
- func (m *Manager) TriggerRefreshHealth()
- func (m *Manager) UpdateSite(site *SiteState, setUpdated bool) error
- type NodeDHParams
- type NodeState
- type SiteApp
- type SiteHealth
- type SiteState
- type SiteTLS
- type StateStore
- type StateStoreEtcd
- func (s *StateStoreEtcd) AcquireLock(name string, timeout bool) (interface{}, error)
- func (s *StateStoreEtcd) ClusterHealth() (map[string]*utils.NodeStatus, error)
- func (s *StateStoreEtcd) GetClient() *clientv3.Client
- func (s *StateStoreEtcd) GetContext() (context.Context, context.CancelFunc)
- func (s *StateStoreEtcd) GetMemberId() string
- func (s *StateStoreEtcd) GetState() *NodeState
- func (s *StateStoreEtcd) Healthy() (healthy bool, err error)
- func (s *StateStoreEtcd) Init() (err error)
- func (s *StateStoreEtcd) OnStateUpdate(callback func())
- func (s *StateStoreEtcd) ReadState() (err error)
- func (s *StateStoreEtcd) ReleaseLock(leaseID interface{}) error
- func (s *StateStoreEtcd) SetState(state *NodeState) (err error)
- func (s *StateStoreEtcd) StoreNodeHealth(health *utils.NodeStatus) error
- func (s *StateStoreEtcd) WriteState() (err error)
- type StateStoreFile
- func (s *StateStoreFile) AcquireLock(name string, timeout bool) (interface{}, error)
- func (s *StateStoreFile) ClusterHealth() (map[string]*utils.NodeStatus, error)
- func (s *StateStoreFile) GetState() *NodeState
- func (s *StateStoreFile) Healthy() (bool, error)
- func (s *StateStoreFile) Init() (err error)
- func (s *StateStoreFile) OnStateUpdate(callback func())
- func (s *StateStoreFile) ReadState() (err error)
- func (s *StateStoreFile) ReleaseLock(leaseID interface{}) error
- func (s *StateStoreFile) SetState(state *NodeState) (err error)
- func (s *StateStoreFile) StoreNodeHealth(health *utils.NodeStatus) error
- func (s *StateStoreFile) WriteState() (err error)
- type WorkerController
Constants ¶
const ( StoreTypeFile = "file" StoreTypeEtcd = "etcd" )
const ( TLSCertificateImported = "imported" TLSCertificateAzureKeyVault = "akv" TLSCertificateSelfSigned = "selfsigned" TLSCertificateACME = "acme" )
const EtcdLockDuration = 20
Maximum lock duration, in seconds
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { RefreshHealth chan int RefreshCerts chan int DHParamsGenerating bool // contains filtered or unexported fields }
Manager is the state manager class
var Instance *Manager
Instance is a singleton for Manager
func (*Manager) AcquireLock ¶
AcquireLock acquires a lock on the sync semaphore, ensuring that only one node at a time can be syncing
func (*Manager) ClusterHealth ¶
func (m *Manager) ClusterHealth() (map[string]*utils.NodeStatus, error)
ClusterHealth returns the health of all members in the cluster
func (*Manager) DeleteSecret ¶
DeleteSecret deletes a secret
func (*Manager) DeleteSite ¶
DeleteSite remvoes a site from the store
func (*Manager) GetAllSiteHealth ¶
func (m *Manager) GetAllSiteHealth() SiteHealth
GetAllSiteHealth returns the health of all objects
func (*Manager) GetCertificate ¶
func (m *Manager) GetCertificate(typ string, nameOrDomains []string) (key []byte, cert []byte, err error)
GetCertificate returns a certificate pair (key and certificate) stored as secrets, PEM-encoded
func (*Manager) GetDHParams ¶
GetDHParams returns the PEM-encoded DH parameters and their date
func (*Manager) GetNodeHealth ¶
func (m *Manager) GetNodeHealth() *utils.NodeStatus
GetNodeHealth gets the node status object
func (*Manager) GetSiteHealth ¶
GetSiteHealth returns the health of a site
func (*Manager) GetStore ¶
func (m *Manager) GetStore() StateStore
GetStore returns the instance of the store in use
func (*Manager) GetStoreType ¶
GetStoreType returns the type of the store in use
func (*Manager) LastUpdated ¶
LastUpdated returns the time the state was updated last
func (*Manager) ListImportedCertificates ¶
ListImportedCertificates returns a list of the names of all imported certificates
func (*Manager) OnStateUpdate ¶
func (m *Manager) OnStateUpdate(callback func())
OnStateUpdate stores the callback to invoke if the state is updated because of an external event
func (*Manager) ReleaseLock ¶
ReleaseSyncLock releases the lock on the sync semaphore
func (*Manager) RemoveCertificate ¶
RemoveCertificate removes a certificate from the store
func (*Manager) ReplaceState ¶
ReplaceState replaces the full state for the node with the provided one
func (*Manager) SetCertificate ¶
func (m *Manager) SetCertificate(typ string, nameOrDomains []string, key []byte, cert []byte) (err error)
SetCertificate stores a PEM-encoded certificate pair (key and certificate) as a secret
func (*Manager) SetDHParams ¶
SetDHParams stores new PEM-encoded DH parameters
func (*Manager) SetNodeHealth ¶
func (m *Manager) SetNodeHealth(health *utils.NodeStatus) error
SetNodeHealth stores the node status object
func (*Manager) SetSiteHealth ¶
SetSiteHealth sets the health of a site
func (*Manager) StoreHealth ¶
StoreHealth returns true if the store is healthy
func (*Manager) TriggerRefreshCerts ¶
func (m *Manager) TriggerRefreshCerts()
TriggerRefreshCerts triggers a background job that re-checks all certificates and refreshes them
func (*Manager) TriggerRefreshHealth ¶
func (m *Manager) TriggerRefreshHealth()
TriggerRefreshHealth triggers a background job that re-checks the health of all websites
type NodeDHParams ¶
NodeDHParams represents the DH Parameters file (PEM-encoded) and their age
type NodeState ¶
type NodeState struct { Sites []SiteState `json:"sites"` Secrets map[string][]byte `json:"secrets,omitempty"` DHParams *NodeDHParams `json:"dhparams,omitempty"` }
NodeState represents the global state of the node
type SiteApp ¶
type SiteApp struct { // App details Name string `json:"name" binding:"required"` // App manifest (for internal use) Manifest *utils.AppManifest `json:"-"` }
SiteApp represents the state of an app deployed or being deployed
type SiteHealth ¶
SiteHealth represents the health of each site in the node
type SiteState ¶
type SiteState struct { // Domains: primary and aliases Domain string `json:"domain" binding:"ne=_default"` Aliases []string `json:"aliases" binding:"dive,ne=_default"` // Temporary site (e.g. for testing) Temporary bool `json:"temporary,omitempty"` // TLS configuration TLS *SiteTLS `json:"tls"` // App App *SiteApp `json:"app"` }
SiteState represents the state of a single site
type SiteTLS ¶
type SiteTLS struct { Type string `json:"type"` Certificate *string `json:"cert,omitempty"` Version *string `json:"ver,omitempty"` }
SiteTLS represents the TLS configuration for the site
type StateStore ¶
type StateStore interface { Init() error AcquireLock(name string, timeout bool) (interface{}, error) ReleaseLock(leaseID interface{}) error GetState() *NodeState SetState(*NodeState) error WriteState() error ReadState() error Healthy() (bool, error) OnStateUpdate(func()) ClusterHealth() (map[string]*utils.NodeStatus, error) StoreNodeHealth(health *utils.NodeStatus) error }
StateStore is the interface for the state stores
type StateStoreEtcd ¶
type StateStoreEtcd struct {
// contains filtered or unexported fields
}
func (*StateStoreEtcd) AcquireLock ¶
func (s *StateStoreEtcd) AcquireLock(name string, timeout bool) (interface{}, error)
AcquireLock acquires a lock, with an optional timeout
func (*StateStoreEtcd) ClusterHealth ¶
func (s *StateStoreEtcd) ClusterHealth() (map[string]*utils.NodeStatus, error)
ClusterHealth returns the health of all members in the cluster
func (*StateStoreEtcd) GetClient ¶
func (s *StateStoreEtcd) GetClient() *clientv3.Client
GetClient returns the etcd client with the active connection
func (*StateStoreEtcd) GetContext ¶
func (s *StateStoreEtcd) GetContext() (context.Context, context.CancelFunc)
GetContext returns a context that times out
func (*StateStoreEtcd) GetMemberId ¶
func (s *StateStoreEtcd) GetMemberId() string
GetMemberId returns the ID of this member in the cluster
func (*StateStoreEtcd) GetState ¶
func (s *StateStoreEtcd) GetState() *NodeState
GetState returns the full state
func (*StateStoreEtcd) Healthy ¶
func (s *StateStoreEtcd) Healthy() (healthy bool, err error)
Healthy returns true if the connection with etcd is active
func (*StateStoreEtcd) Init ¶
func (s *StateStoreEtcd) Init() (err error)
Init initializes the object
func (*StateStoreEtcd) OnStateUpdate ¶
func (s *StateStoreEtcd) OnStateUpdate(callback func())
OnStateUpdate stores the callback that is invoked when there's a new state from etcd
func (*StateStoreEtcd) ReadState ¶
func (s *StateStoreEtcd) ReadState() (err error)
ReadState reads the state from etcd
func (*StateStoreEtcd) ReleaseLock ¶
func (s *StateStoreEtcd) ReleaseLock(leaseID interface{}) error
ReleaseLock releases a lock
func (*StateStoreEtcd) SetState ¶
func (s *StateStoreEtcd) SetState(state *NodeState) (err error)
StoreState replaces the current state
func (*StateStoreEtcd) StoreNodeHealth ¶
func (s *StateStoreEtcd) StoreNodeHealth(health *utils.NodeStatus) error
StoreNodeHealth stores the health of this node in etcd
func (*StateStoreEtcd) WriteState ¶
func (s *StateStoreEtcd) WriteState() (err error)
WriteState stores the state in etcd
type StateStoreFile ¶
type StateStoreFile struct {
// contains filtered or unexported fields
}
func (*StateStoreFile) AcquireLock ¶
func (s *StateStoreFile) AcquireLock(name string, timeout bool) (interface{}, error)
AcquireLock acquires a lock, with an optional timeout
func (*StateStoreFile) ClusterHealth ¶
func (s *StateStoreFile) ClusterHealth() (map[string]*utils.NodeStatus, error)
ClusterHealth returns the health of all members in the cluster
func (*StateStoreFile) GetState ¶
func (s *StateStoreFile) GetState() *NodeState
GetState returns the full state
func (*StateStoreFile) Healthy ¶
func (s *StateStoreFile) Healthy() (bool, error)
Healthy returns always true
func (*StateStoreFile) Init ¶
func (s *StateStoreFile) Init() (err error)
Init initializes the object
func (*StateStoreFile) OnStateUpdate ¶
func (s *StateStoreFile) OnStateUpdate(callback func())
OnStateUpdate isn't used with this store
func (*StateStoreFile) ReadState ¶
func (s *StateStoreFile) ReadState() (err error)
ReadState reads the state from disk
func (*StateStoreFile) ReleaseLock ¶
func (s *StateStoreFile) ReleaseLock(leaseID interface{}) error
ReleaseLock releases a lock
func (*StateStoreFile) SetState ¶
func (s *StateStoreFile) SetState(state *NodeState) (err error)
StoreState replaces the current state
func (*StateStoreFile) StoreNodeHealth ¶
func (s *StateStoreFile) StoreNodeHealth(health *utils.NodeStatus) error
StoreNodeHealth isn't used with this store
func (*StateStoreFile) WriteState ¶
func (s *StateStoreFile) WriteState() (err error)
WriteState stores the state on disk
type WorkerController ¶
type WorkerController interface { Init(store StateStore) IsLeader() bool AddJob(job utils.JobData) (string, error) CompleteJob(jobID string) error WaitForJob(jobID string, ch chan error) }
WorkerController is the interface for the controller
var Worker WorkerController
Worker is a singleton for the WorkerController