Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertService ¶
type AlertService interface { Save(alert models.Alert, authorEmail string) (*models.Alert, error) List(service string) ([]*models.Alert, error) FindByID(id uint) (*models.Alert, error) Update(alert models.Alert, authorEmail string) error Delete(alert models.Alert, authorEmail string) error }
func NewGitlabOpsAlertService ¶
func NewGitlabOpsAlertService(db *gorm.DB, gitlab *gitlab.Client, gitlabProjectID string, gitlabBranch string, gitlabPathPrefix string) AlertService
Create a new AlertService that can be used with GitOps based on GitLab. It is assumed that the continuous integration (CI) jobs configured in GitLab can process the committed alert files to register the alerts to the corresponding external alert manager. This CI process is out of scope of Turing.
For every alert object created, a yaml file will be created at the following location: <gitlab_alert_repo_root>/<gitlabPathPrefix>/<environment>/<team>/<service>/<metric>.yaml
Every alert created will be persisted in the database and the configured alert repository in GitLab. In most cases, the alerts persisted in the database will be in sync with the alert files in GitLab (as long as the Git files are not manually modified i.e. the alert files are only updated by calling this service).
type CryptoService ¶
type CryptoService interface { // Encrypt takes an input plaintext string and returs the cipher text or an error Encrypt(plaintext string) (string, error) // Decrypt takes an input cipher string and returs the plaintext or an error Decrypt(ciphertext string) (string, error) }
CryptoService is used for encrypting / decrypting sensitive data
func NewCryptoService ¶
func NewCryptoService(encryptionKey string) CryptoService
NewCryptoService creates a new cryptoService using the given encryption key
type DeploymentService ¶
type DeploymentService interface { DeployRouterVersion( project *mlp.Project, environment *merlin.Environment, routerVersion *models.RouterVersion, routerServiceAccountKey string, enricherServiceAccountKey string, ensemblerServiceAccountKey string, experimentConfig json.RawMessage, experimentPasskey string, eventsCh *utils.EventChannel, ) (string, error) UndeployRouterVersion( project *mlp.Project, environment *merlin.Environment, routerVersion *models.RouterVersion, eventsCh *utils.EventChannel, ) error DeleteRouterEndpoint(project *mlp.Project, environment *merlin.Environment, routerVersion *models.RouterVersion, ) error }
DeploymentService handles the deployment of the Turing routers and the related components.
func NewDeploymentService ¶
func NewDeploymentService( deploymentConfig *config.DeploymentConfig, routerDefaults *config.RouterDefaults, sentryConfig sentry.Config, clusterControllers map[string]cluster.Controller, ) DeploymentService
NewDeploymentService initialises a new endpoints service
type EventService ¶
type EventService interface { ListEvents(routerID int) ([]*models.Event, error) ClearEvents(routerID int) error Save(event *models.Event) error }
func NewEventService ¶
func NewEventService(db *gorm.DB) EventService
NewEventService creates a new events service
type Experiment ¶
type Experiment struct { ID string `json:"id"` Name string `json:"name"` ClientName string `json:"client_name"` UnitType string `json:"unit_type"` Treatments []string `json:"treatments"` // List of treatment names (i.e variations) in the experiment. }
Experiment represents an experiment in Turing. The experiment info can come from different expriment engines such as Litmus or XP but they will be represented with the same schema in this experiment object. For instance in Litmus, the variation of the same experiment is called "variants" whereas in XP it is called "treament", but in Turing the term "treatment" in an experiment is consistently used.
type ExperimentsService ¶
type ExperimentsService interface { // ListEngines returns a list of the experiment engines available ListEngines() []manager.Engine // ListClients returns a list of the clients registered on the given experiment engine ListClients(engine string) ([]manager.Client, error) // ListExperiments returns a list of the experiments registered on the given experiment engine, // and for the given clientID if supplied ListExperiments(engine string, clientID string) ([]manager.Experiment, error) // ListVariables returns a list of the variables registered on the given experiment engine, // for the given clientID and/or experiments ListVariables(engine string, clientID string, experimentIDs []string) (manager.Variables, error) // ValidateExperimentConfig validates the given experiment config for completeness ValidateExperimentConfig(engine string, cfg manager.TuringExperimentConfig) error // GetExperimentRunnerConfig converts the given generic manager.TuringExperimentConfig into the // format compatible with the ExperimentRunner GetExperimentRunnerConfig(engine string, cfg *manager.TuringExperimentConfig) (json.RawMessage, error) }
ExperimentsService provides functionality to work with experiment engines supported by Turing
func NewExperimentsService ¶
func NewExperimentsService() (ExperimentsService, error)
NewExperimentsService creates a new experiment service from the given config
type MLPService ¶
type MLPService interface { // GetEnvironments gets all available environments from Merlin GetEnvironments() ([]merlin.Environment, error) // GetEnvironment gets the environment matching the provided name. GetEnvironment(name string) (*merlin.Environment, error) // GetProject gets the project matching the provided id. GetProject(id int) (*mlp.Project, error) // GetSecret gets a secret by project and name. GetSecret(projectID int, name string) (string, error) }
MLPService provides a set of methods to interact with the MLP / Merlin APIs
func NewMLPService ¶
func NewMLPService( mlpBasePath string, mlpEncryptionkey string, merlinBasePath string, ) (MLPService, error)
NewMLPService returns a service that retrieves information that is shared across MLP projects from (currently) the Merlin API.
type PodLog ¶
type PodLog struct { // Log timestamp in RFC3339 format Timestamp time.Time `json:"timestamp"` // Environment name of the router running the container that produces this log Environment string `json:"environment"` // Kubernetes namespace where the pod running the container is created Namespace string `json:"namespace"` // Pod name running the container that produces this log PodName string `json:"pod_name"` // Container name that produces this log ContainerName string `json:"container_name"` // Log in text format, either TextPayload or JSONPayload will be set but not both TextPayload string `json:"text_payload,omitempty"` // Log in JSON format, either TextPayload or JSONPayload will be set but not both JSONPayload map[string]interface{} `json:"json_payload,omitempty"` }
PodLog represents a single log line from a container running in Kubernetes. If the log message is in JSON format, JSONPayload must be populated with the structured JSON log message. Else, TextPayload must be populated with log text.
type PodLogOptions ¶
type PodLogOptions struct { // Container to get the logs from, default to 'user-container', the default container name in Knative Container string // If true, return the logs from previous terminated container in all pods Previous bool // (Optional) Timestamp from which to retrieve the logs from, useful for filtering recent logs. The logs retrieved // will have timestamp after (but not including) SinceTime. SinceTime *time.Time // (Optional) Number of lines from the end of the logs to retrieve. Should not be used together with HeadLines. // If both TailLines and Headlines are provided, TailLines will be ignored. TailLines *int64 // (Optional) Number of lines from the start of the logs to retrieve. Should not be used together with TailLines. // If both TailLines and Headlines are provided, TailLines will be ignored. HeadLines *int64 }
type PodLogService ¶
type PodLogService interface { // ListPodLogs retrieves logs from user-container (default) container from all pods running the router. ListPodLogs( project *mlp.Project, router *models.Router, routerVersion *models.RouterVersion, componentType string, opts *PodLogOptions, ) ([]*PodLog, error) }
func NewPodLogService ¶
func NewPodLogService(clusterControllers map[string]cluster.Controller) PodLogService
type RouterVersionsService ¶
type RouterVersionsService interface { // List all RouterVersions associated with the given routerID ListRouterVersions(routerID uint) ([]*models.RouterVersion, error) // Lists the RouterVersions for the given Router matching the given status. ListRouterVersionsWithStatus(routerID uint, status models.RouterVersionStatus) ([]*models.RouterVersion, error) // Save the given RouterVersion to the db. Updates the existing record if already exists. Save(routerVersion *models.RouterVersion) (*models.RouterVersion, error) // Finds the RouterVersion matching the given id. FindByID(routerVersionID uint) (*models.RouterVersion, error) // Finds the RouterVersion for the given Router matching the given version. FindByRouterIDAndVersion(routerID uint, version uint) (*models.RouterVersion, error) // Finds the latest RouterVersion for the given Router matching the given version. FindLatestVersionbyRouterID(routerID uint) (*models.RouterVersion, error) // Deletes the given RouterVersion from the db. This method deletes all child objects (enricher, ensembler). Delete(routerVersion *models.RouterVersion) error }
RouterVersionsService is the data access object for RouterVersions from the db.
func NewRouterVersionsService ¶
func NewRouterVersionsService(db *gorm.DB) RouterVersionsService
type RoutersService ¶
type RoutersService interface { // List routers within the given project and environment. ListRouters(projectID int, environmentName string) ([]*models.Router, error) // Save the given router to the db. Updates the existing record if already exists. Save(router *models.Router) (*models.Router, error) // Find a router matching the given router id. FindByID(routerID uint) (*models.Router, error) // Find a router within the given project that matches the given name. FindByProjectAndName(projectID int, routerName string) (*models.Router, error) // Find a router within the given project and environment that matches the given name. FindByProjectAndEnvironmentAndName(projectID int, environmentName string, routerName string) (*models.Router, error) // Delete a router. This deletes all child objects of the router (router versions, ensemblers and enrichers) // (Transactional). Delete(router *models.Router) error }
RoutersService is the data access object for the Routers from the db.
func NewRoutersService ¶
func NewRoutersService(db *gorm.DB) RoutersService
NewRoutersService creates a new router service