Documentation
¶
Index ¶
- Variables
- func NewRouter(app *App) http.Handler
- type App
- type ClientState
- type Config
- type Engine
- func (e *Engine) ForceTargetVersion(namespaceName, entityName string, targetVersion EntityTargetVersion) error
- func (e *Engine) GetClientGroupState(namespaceName, entityName, groupName string) ([]*ClientState, error)
- func (e *Engine) GetClientState(namespaceName, entityName string) ([]*ClientState, error)
- func (e *Engine) GetEntites(namespaceName string) ([]string, error)
- func (e *Engine) GetNamespaces() ([]string, error)
- func (e *Engine) GetRolloutInfo(namespaceName, entityName string) (*RolloutState, error)
- func (e *Engine) Load() error
- func (e *Engine) Orchestrate(namespaceName, entityName string, targets []*ClientState) ([]*ClientState, error)
- func (e *Engine) OrchestrateAsync(namespaceName, entityName string, targets []*ClientState) error
- func (e *Engine) Save() error
- func (e *Engine) SaveNamespaceEntity(namespaceName, entityName string) error
- func (e *Engine) SetEntityMonitoringController(namespaceName string, entityName string, controller EntityMonitoringController) error
- func (e *Engine) SetEntityTargetController(namespaceName string, entityName string, controller EntityTargetController) error
- func (e *Engine) SetRolloutOptions(namespaceName string, entityName string, options *RolloutOptions) error
- func (e *Engine) SetTargetVersion(namespaceName, entityName string, targetVersion EntityTargetVersion) error
- func (e *Engine) Shutdown() error
- func (e *Engine) ShutdownAndClose() error
- type Entity
- type EntityMonitoringController
- type EntityTarget
- type EntityTargetController
- type EntityTargetState
- type EntityTargetVersion
- type EntityTargets
- type EntityVersionInfo
- type EntityWebMonitoringController
- type EntityWebTargetController
- func (e *EntityWebTargetController) TargetApproval(clientTargets []*ClientState) ([]*ClientState, error)
- func (e *EntityWebTargetController) TargetMonitoring(clientTarget *ClientState) error
- func (e *EntityWebTargetController) TargetRemoval(clientTargets []*ClientState, numRemoval int) ([]*ClientState, error)
- func (e *EntityWebTargetController) TargetSelection(clientTargets []*ClientState, numSelection int) ([]*ClientState, error)
- type ExternalMonitoringRequest
- type ExternalMonitoringResponse
- type Message
- type Namespace
- type NoOpEntityMonitoringController
- type NoOpEntityTargetController
- func (e *NoOpEntityTargetController) TargetApproval(t []*ClientState) ([]*ClientState, error)
- func (e *NoOpEntityTargetController) TargetMonitoring(t *ClientState) error
- func (e *NoOpEntityTargetController) TargetRemoval(t []*ClientState, s int) ([]*ClientState, error)
- func (e *NoOpEntityTargetController) TargetSelection(t []*ClientState, s int) ([]*ClientState, error)
- type Rollout
- type RolloutOptions
- type RolloutState
- type RolloutVersionInfo
- type Route
- type SerializedEntityMonitoringController
- type SerializedEntityTargetController
- type TargetApprovalRequest
- type TargetApprovalResponse
- type TargetMonitoringRequest
- type TargetMonitoringResponse
- type TargetRemovalRequest
- type TargetRemovalResponse
- type TargetSelectionRequest
- type TargetSelectionResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNamespaceNotCreated returns an error if namespace is not created ErrNamespaceNotCreated = errors.New("namespace not created") // ErrEntityNotCreated returns an error if entity is not created ErrEntityNotCreated = errors.New("entity not created") // ErrInvalidTargetVersion returns an error if target version is invalid ErrInvalidTargetVersion = errors.New("invalid Target Version") // ErrExternalControllerFailure returns an error if call to external controller failed ErrExternalControllerFailure = errors.New("failure calling external controller") )
var RegisteredMonitoringControllers = []EntityMonitoringController{ &NoOpEntityMonitoringController{}, &EntityWebMonitoringController{}, }
var RegisteredTargetControllers = []EntityTargetController{ &NoOpEntityTargetController{}, &EntityWebTargetController{}, }
We need to register all known message types here to be able to unmarshal them to the correct interface type.
Functions ¶
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
Context stores local and aggregate stores
func (*App) Orchestrator ¶
Orchestrator Creates a new orchestrator router
type ClientState ¶
type ClientState struct {
Name string `json:"name,omitempty"`
Group string `json:"group,omitempty"`
Tags string `json:"tags,omitempty"`
Version string `json:"version,omitempty"`
Message string `json:"message,omitempty"`
IsError bool `json:"isError,omitempty"`
}
ClientState as reported by clients,
transformed to EntityTarget Orchestrator updates with target state Client could belong to a specific group making it easier to orchestrate
type Config ¶
type Config struct {
// Name for logs
ApplicationName string
// trace, debug, info, error, warn, fatal, panic
LogLevel string
// enable console logging
ConsoleLogging bool
// log dir to out json formatted logs
// these logs are auto rotated
LogDirectory string
// Use postgres db
StoreDatabaseURL string
// postgres db schema
StoreDatabaseSchema string
// postgres db table
StoreDatabaseTable string
// Location to store badger db
StoreDirectory string
// Masterkey for encrypting badger store
StoreMasterKey string
}
Provides an input config for new orchestrator engine
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine holds the namespaces serves
func NewOrchestratorEngine ¶
NewOrchestratorEngine creates a new Orchestration Context
func NewOrchestratorEngineWithApp ¶
NewOrchestratorEngineWithApp creates a new Orchestration Context
func (*Engine) ForceTargetVersion ¶
func (e *Engine) ForceTargetVersion(namespaceName, entityName string, targetVersion EntityTargetVersion) error
ForceTargetVersion sets the target version and marks current rolling version as bad this allows target version to be promoted to rolling version
func (*Engine) GetClientGroupState ¶
func (e *Engine) GetClientGroupState(namespaceName, entityName, groupName string) ([]*ClientState, error)
GetClientGroupState Gets Expected Client State for the client group state for the namespace, entity This is an optional API where controller service reports partial status thought 1 API, gets the current expected client group state with another API
func (*Engine) GetClientState ¶
func (e *Engine) GetClientState(namespaceName, entityName string) ([]*ClientState, error)
GetClientState Gets Expected Client State for all the client state for the namespace, entity This is an optional API where controller service reports partial status thought 1 API, gets the current expected client state with another API
func (*Engine) GetEntites ¶
GetEntites returns a list of entities owned by the namespace
func (*Engine) GetNamespaces ¶
GetNamespaces returns a list of namespaces owned by the engine
func (*Engine) GetRolloutInfo ¶
func (e *Engine) GetRolloutInfo(namespaceName, entityName string) (*RolloutState, error)
GetRolloutInfo returns current rollout information
func (*Engine) Orchestrate ¶
func (e *Engine) Orchestrate(namespaceName, entityName string, targets []*ClientState) ([]*ClientState, error)
Orchestrate list of input targets, modifies the state to record target state
func (*Engine) OrchestrateAsync ¶
func (e *Engine) OrchestrateAsync(namespaceName, entityName string, targets []*ClientState) error
OrchestrateAsync records the input state of targets, responds nothing Clients call GetClientState to know the declarative state of targets
func (*Engine) SaveNamespaceEntity ¶
SaveNamespaceEntity saves entityName with
func (*Engine) SetEntityMonitoringController ¶
func (e *Engine) SetEntityMonitoringController(namespaceName string, entityName string, controller EntityMonitoringController) error
SetEntityTargetController sets entity target controller for the entity
typically used for override
func (*Engine) SetEntityTargetController ¶
func (e *Engine) SetEntityTargetController(namespaceName string, entityName string, controller EntityTargetController) error
SetEntityTargetController sets entity target controller for the entity
typically used for override
func (*Engine) SetRolloutOptions ¶
func (e *Engine) SetRolloutOptions(namespaceName string, entityName string, options *RolloutOptions) error
SetRolloutOptions sets rollout options for the entity
caller should typically set this initially before calling orchestrate
func (*Engine) SetTargetVersion ¶
func (e *Engine) SetTargetVersion(namespaceName, entityName string, targetVersion EntityTargetVersion) error
SetTargetVersion sets the target version
func (*Engine) ShutdownAndClose ¶
Shutdown the engine when process is shutdown
type Entity ¶
type Entity struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
// contains filtered or unexported fields
}
Entity has a list of Targets We do need to serialize controller, which could be endpoints
type EntityMonitoringController ¶
type EntityMonitoringController interface {
// ExternalMonitoring communicates with external monitoring system,
// in case rollout has degraded the system as a whole
ExternalMonitoring([]*ClientState) error
}
type EntityTarget ¶
type EntityTarget struct {
Name string `json:"name,omitempty"`
Group string `json:"group,omitempty"`
Tags string `json:"tags,omitempty"`
State EntityTargetState `json:"state,omitempty"`
}
EntityTarget contains Entity name, and any properties, to uniquely identify a target
type EntityTargetController ¶
type EntityTargetController interface {
// TargetSelection notifies for selecting targets based on batchsize
// It could return new set of targets, typical pattern of blue-green deployments
TargetSelection([]*ClientState, int) ([]*ClientState, error)
// TargetApproval notifies external controller just before rolling out
// At this stage external controller could reject it
TargetApproval([]*ClientState) ([]*ClientState, error)
// TargetRemoval notifies external controller to remove set of old targets
// Sends old sets of target with size of new successful rolled out targets
// Sends new set of target with size of new successful rolled out targets
// All of the above is set to max batch size
TargetRemoval([]*ClientState, int) ([]*ClientState, error)
// TargetMonitoring checks for any additional monitoring for individual target
// typically health information is included in messages, but this provides another opportunity
TargetMonitoring(*ClientState) error
}
EntityController defines set of callback functions wrapper around RolloutController and could be more
type EntityTargetState ¶
type EntityTargetState struct {
CurrentVersion EntityVersionInfo `json:"currentversion,omitempty"`
TargetVersion EntityVersionInfo `json:"targetversion,omitempty"`
LastUpdatedTimestamp time.Time `json:"lastupdatedtimestamp,omitempty"`
}
EntityTargetState and list of properties stored internally
type EntityTargetVersion ¶
type EntityTargetVersion struct {
Version string `json:"version,omitempty"`
}
EntityTargetVersion used as an input, otherwise unused anywhere else
type EntityTargets ¶
type EntityTargets = []*EntityTarget
type EntityVersionInfo ¶
type EntityVersionInfo struct {
Version string `json:"version,omitempty"`
// changeTimestamp at which this version was created
// typically this is the time the version was switched
ChangeTimestamp time.Time `json:"changetimestamp,omitempty"`
// last message
LastMessage Message `json:"lastmessage,omitempty"`
}
EntityVersionInfo contains version information
type EntityWebMonitoringController ¶
type EntityWebMonitoringController struct {
// ExternalMonitoringEndpoint communicates with external monitoring system,
// in case rollout has degraded the system as a whole
ExternalMonitoringEndpoint string `json:"externalmonitoring,omitempty"`
}
func (*EntityWebMonitoringController) ExternalMonitoring ¶
func (e *EntityWebMonitoringController) ExternalMonitoring(clientTargets []*ClientState) error
ExternalMonitoring for list of client targets
type EntityWebTargetController ¶
type EntityWebTargetController struct {
// SelectionEndpoint notifies for selecting targets based on batchsize
// It could return new set of targets, typical pattern of blue-green deployments
SelectionEndpoint string `json:"selection,omitempty"`
// ApprovalEndpoint notifies external controller just before rolling out
// At this stage external controller could reject it
ApprovalEndpoint string `json:"approval,omitempty"`
// RemovalEndpoint notifies external controller to remove set of old targets
// Sends old sets of target with size of new successful rolled out targets
// Sends new set of target with size of new successful rolled out targets
// All of the above is set to max batch size
RemovalEndpoint string `json:"removal,omitempty"`
// MonitoringEndpoint checks for any additional monitoring for individual target
// typically health information is included in messages, but this provides another opportunity
MonitoringEndpoint string `json:"monitoring,omitempty"`
}
EntityWebController defines set of callback functions wrapper around RolloutController and could be more Right now its just a string to store the web endpoint, later could have auth and something else
func (*EntityWebTargetController) TargetApproval ¶
func (e *EntityWebTargetController) TargetApproval(clientTargets []*ClientState) ([]*ClientState, error)
TargetApproval gets approval for list of targets
func (*EntityWebTargetController) TargetMonitoring ¶
func (e *EntityWebTargetController) TargetMonitoring(clientTarget *ClientState) error
TargetMonitoring monitors the provided target
func (*EntityWebTargetController) TargetRemoval ¶
func (e *EntityWebTargetController) TargetRemoval(clientTargets []*ClientState, numRemoval int) ([]*ClientState, error)
TargetRemoval removes optional set of additional targets
func (*EntityWebTargetController) TargetSelection ¶
func (e *EntityWebTargetController) TargetSelection(clientTargets []*ClientState, numSelection int) ([]*ClientState, error)
TargetSelection selects list of targets
type ExternalMonitoringRequest ¶
type ExternalMonitoringRequest struct {
Targets []*ClientState `json:"targets,omitempty"`
}
ExternalMonitoringRequest request for external monitoring
type ExternalMonitoringResponse ¶
type ExternalMonitoringResponse struct {
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
ExternalMonitoringResponse Response for external monitoring
type Message ¶
type Message struct {
Message string `json:"message,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
IsError bool `json:"isError,omitempty"`
}
Message reported for each target
type Namespace ¶
type Namespace struct {
// list of entities
Name string `json:"name,omitempty"`
// contains filtered or unexported fields
}
Namespace holds the list of entities
func (*Namespace) SaveEntity ¶
SaveEntity saves entity to store
type NoOpEntityMonitoringController ¶
type NoOpEntityMonitoringController struct {
}
func (*NoOpEntityMonitoringController) ExternalMonitoring ¶
func (e *NoOpEntityMonitoringController) ExternalMonitoring([]*ClientState) error
ExternalMonitoring return success always
type NoOpEntityTargetController ¶
type NoOpEntityTargetController struct {
}
NoOpEntityController is a dummy default controller
func (*NoOpEntityTargetController) TargetApproval ¶
func (e *NoOpEntityTargetController) TargetApproval(t []*ClientState) ([]*ClientState, error)
TargetApproval approves everything
func (*NoOpEntityTargetController) TargetMonitoring ¶
func (e *NoOpEntityTargetController) TargetMonitoring(t *ClientState) error
TargetMonitoring returns success always
func (*NoOpEntityTargetController) TargetRemoval ¶
func (e *NoOpEntityTargetController) TargetRemoval(t []*ClientState, s int) ([]*ClientState, error)
TargetRemoval removes nothing
func (*NoOpEntityTargetController) TargetSelection ¶
func (e *NoOpEntityTargetController) TargetSelection(t []*ClientState, s int) ([]*ClientState, error)
TargetSelection selects everything
type Rollout ¶
type Rollout struct {
State RolloutState `json:"state,omitempty"`
TargetController SerializedEntityTargetController `json:"targetcontroller,omitempty"`
MonitoringController SerializedEntityMonitoringController `json:"monitoringcontroller,omitempty"`
// contains filtered or unexported fields
}
Rollout object stores current state
type RolloutOptions ¶
type RolloutOptions struct {
// Percentage of targets in rollout
BatchPercent int `json:"batchpercent,omitempty"`
// Percentage of targets successful to mark rollout as success
SuccessPercent int `json:"successpercent,omitempty"`
// Timeout in secs to have successful monitoring window
SuccessTimeoutSecs int `json:"successtimeoutsecs,omitempty"`
// Max Duration timeout in secs to wait to have a successful monitoring window
DurationTimeoutSecs int `json:"durationtimeoutsecs,omitempty"`
}
RolloutOptions rollout options
func DefaultRolloutOptions ¶
func DefaultRolloutOptions() *RolloutOptions
DefaultRolloutOptions conservative settings
func (RolloutOptions) MarshalZerologObject ¶
func (o RolloutOptions) MarshalZerologObject(e *zerolog.Event)
type RolloutState ¶
type RolloutState struct {
RolloutVersionInfo `json:",inline"`
Options *RolloutOptions `json:"options,omitempty"`
}
RolloutState is state that needs to be serialized to storage
type RolloutVersionInfo ¶
type SerializedEntityMonitoringController ¶
type SerializedEntityMonitoringController struct {
EntityMonitoringController `json:"value"`
}
func (SerializedEntityMonitoringController) MarshalJSON ¶
func (c SerializedEntityMonitoringController) MarshalJSON() ([]byte, error)
func (*SerializedEntityMonitoringController) UnmarshalJSON ¶
func (c *SerializedEntityMonitoringController) UnmarshalJSON(bytes []byte) error
type SerializedEntityTargetController ¶
type SerializedEntityTargetController struct {
EntityTargetController `json:"value"`
}
func (SerializedEntityTargetController) MarshalJSON ¶
func (c SerializedEntityTargetController) MarshalJSON() ([]byte, error)
func (*SerializedEntityTargetController) UnmarshalJSON ¶
func (c *SerializedEntityTargetController) UnmarshalJSON(bytes []byte) error
type TargetApprovalRequest ¶
type TargetApprovalRequest struct {
Targets []*ClientState `json:"targets,omitempty"`
}
TargetApprovalRequest request with target list
type TargetApprovalResponse ¶
type TargetApprovalResponse struct {
Targets []*ClientState `json:"targets,omitempty"`
}
TargetApprovalResponse response with list of targets
type TargetMonitoringRequest ¶
type TargetMonitoringRequest struct {
Target *ClientState `json:"target,omitempty"`
}
TargetMonitoringRequest request with target name
type TargetMonitoringResponse ¶
type TargetMonitoringResponse struct {
Status string `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
TargetMonitoringResponse response with target status
type TargetRemovalRequest ¶
type TargetRemovalRequest struct {
Targets []*ClientState `json:"targets,omitempty"`
Count int `json:"count,omitempty"`
}
TargetRemovalRequest request of target list with count
type TargetRemovalResponse ¶
type TargetRemovalResponse struct {
Targets []*ClientState `json:"targets,omitempty"`
}
TargetRemovalResponse response of target list
type TargetSelectionRequest ¶
type TargetSelectionRequest struct {
Targets []*ClientState `json:"targets,omitempty"`
Count int `json:"count,omitempty"`
}
TargetSelectionRequest request of target list with count
type TargetSelectionResponse ¶
type TargetSelectionResponse struct {
Targets []*ClientState `json:"targets,omitempty"`
}
TargetSelectionResponse response of target list