Documentation
¶
Index ¶
- func GenerateTokensAndSetCookies(c echo.Context, user *api.Principal, mode string, secret string) error
- func JWTMiddleware(l *zap.Logger, p api.PrincipalService, next echo.HandlerFunc, mode string, ...) echo.HandlerFunc
- type ActivityManager
- type ActivityMeta
- type AnomalyScanner
- type BackupRunner
- type CacheService
- type Claims
- type DataUpdateTaskExecutor
- type DatabaseBackupTaskExecutor
- type DatabaseCreateTaskExecutor
- type DatabaseRestoreTaskExecutor
- type DefaultTaskExecutor
- type SchemaSyncer
- type SchemaUpdateTaskExecutor
- type Server
- type TaskCheckDatabaseConnectExecutor
- type TaskCheckExecutor
- func NewTaskCheckDatabaseConnectExecutor(logger *zap.Logger) TaskCheckExecutor
- func NewTaskCheckMigrationSchemaExecutor(logger *zap.Logger) TaskCheckExecutor
- func NewTaskCheckStatementAdvisorExecutor(logger *zap.Logger) TaskCheckExecutor
- func NewTaskCheckTimingExecutor(logger *zap.Logger) TaskCheckExecutor
- type TaskCheckMigrationSchemaExecutor
- type TaskCheckScheduler
- type TaskCheckStatementAdvisorExecutor
- type TaskCheckTimingExecutor
- type TaskExecutor
- func NewDataUpdateTaskExecutor(logger *zap.Logger) TaskExecutor
- func NewDatabaseBackupTaskExecutor(logger *zap.Logger) TaskExecutor
- func NewDatabaseCreateTaskExecutor(logger *zap.Logger) TaskExecutor
- func NewDatabaseRestoreTaskExecutor(logger *zap.Logger) TaskExecutor
- func NewDefaultTaskExecutor(logger *zap.Logger) TaskExecutor
- func NewSchemaUpdateTaskExecutor(logger *zap.Logger) TaskExecutor
- type TaskScheduler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateTokensAndSetCookies ¶
func GenerateTokensAndSetCookies(c echo.Context, user *api.Principal, mode string, secret string) error
GenerateTokensAndSetCookies generates jwt token and saves it to the http-only cookie.
func JWTMiddleware ¶
func JWTMiddleware(l *zap.Logger, p api.PrincipalService, next echo.HandlerFunc, mode string, secret string) echo.HandlerFunc
JWTMiddleware validates the access token. If the access token is about to expire or has expired and the request has a valid refresh token, it will try to generate new access token and refresh token.
Types ¶
type ActivityManager ¶
type ActivityManager struct {
// contains filtered or unexported fields
}
ActivityManager is the activity manager.
func NewActivityManager ¶
func NewActivityManager(server *Server, activityService api.ActivityService) *ActivityManager
NewActivityManager creates an activity manager.
func (*ActivityManager) CreateActivity ¶
func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.ActivityCreate, meta *ActivityMeta) (*api.Activity, error)
CreateActivity creates an activity.
type ActivityMeta ¶
type ActivityMeta struct {
// contains filtered or unexported fields
}
ActivityMeta is the activity metadata.
type AnomalyScanner ¶
type AnomalyScanner struct {
// contains filtered or unexported fields
}
AnomalyScanner is the anomaly scanner.
func NewAnomalyScanner ¶
func NewAnomalyScanner(logger *zap.Logger, server *Server) *AnomalyScanner
NewAnomalyScanner creates a anomaly scanner
type BackupRunner ¶
type BackupRunner struct {
// contains filtered or unexported fields
}
BackupRunner is the backup runner scheduling automatic backups.
func NewBackupRunner ¶
func NewBackupRunner(logger *zap.Logger, server *Server, backupRunnerInterval time.Duration) *BackupRunner
NewBackupRunner creates a new backup runner.
type CacheService ¶
type CacheService struct {
// contains filtered or unexported fields
}
CacheService implements a cache.
func NewCacheService ¶
func NewCacheService(logger *zap.Logger) *CacheService
NewCacheService creates a cache service.
func (*CacheService) FindCache ¶
func (s *CacheService) FindCache(namespace api.CacheNamespace, id int, entry interface{}) (bool, error)
FindCache finds the value in cache.
func (*CacheService) UpsertCache ¶
func (s *CacheService) UpsertCache(namespace api.CacheNamespace, id int, entry interface{}) error
UpsertCache upserts the value to cache.
type Claims ¶
type Claims struct { Name string `json:"name"` jwt.StandardClaims }
Claims creates a struct that will be encoded to a JWT. We add jwt.StandardClaims as an embedded type, to provide fields like name.
type DataUpdateTaskExecutor ¶
type DataUpdateTaskExecutor struct {
// contains filtered or unexported fields
}
DataUpdateTaskExecutor is the data update (DML) task executor.
type DatabaseBackupTaskExecutor ¶
type DatabaseBackupTaskExecutor struct {
// contains filtered or unexported fields
}
DatabaseBackupTaskExecutor is the task executor for database backup.
type DatabaseCreateTaskExecutor ¶
type DatabaseCreateTaskExecutor struct {
// contains filtered or unexported fields
}
DatabaseCreateTaskExecutor is the database create task executor.
type DatabaseRestoreTaskExecutor ¶
type DatabaseRestoreTaskExecutor struct {
// contains filtered or unexported fields
}
DatabaseRestoreTaskExecutor is the task executor for database restore.
type DefaultTaskExecutor ¶
type DefaultTaskExecutor struct {
// contains filtered or unexported fields
}
DefaultTaskExecutor is the default task executor.
type SchemaSyncer ¶
type SchemaSyncer struct {
// contains filtered or unexported fields
}
SchemaSyncer is the schema syncer.
func NewSchemaSyncer ¶
func NewSchemaSyncer(logger *zap.Logger, server *Server) *SchemaSyncer
NewSchemaSyncer creates a schema syncer.
type SchemaUpdateTaskExecutor ¶
type SchemaUpdateTaskExecutor struct {
// contains filtered or unexported fields
}
SchemaUpdateTaskExecutor is the schema update (DDL) task executor.
type Server ¶
type Server struct { // Asynchronous runners. TaskScheduler *TaskScheduler TaskCheckScheduler *TaskCheckScheduler SchemaSyncer *SchemaSyncer BackupRunner *BackupRunner AnomalyScanner *AnomalyScanner ActivityManager *ActivityManager CacheService api.CacheService SettingService api.SettingService PrincipalService api.PrincipalService MemberService api.MemberService PolicyService api.PolicyService ProjectService api.ProjectService ProjectMemberService api.ProjectMemberService ProjectWebhookService api.ProjectWebhookService EnvironmentService api.EnvironmentService InstanceService api.InstanceService InstanceUserService api.InstanceUserService DatabaseService api.DatabaseService TableService api.TableService ColumnService api.ColumnService ViewService api.ViewService IndexService api.IndexService DataSourceService api.DataSourceService BackupService api.BackupService IssueService api.IssueService IssueSubscriberService api.IssueSubscriberService PipelineService api.PipelineService StageService api.StageService TaskService api.TaskService TaskCheckRunService api.TaskCheckRunService ActivityService api.ActivityService InboxService api.InboxService BookmarkService api.BookmarkService VCSService api.VCSService RepositoryService api.RepositoryService AnomalyService api.AnomalyService LabelService api.LabelService DeploymentConfigService api.DeploymentConfigService LicenseService enterprise.LicenseService SheetService api.SheetService // contains filtered or unexported fields }
Server is the Bytebase server.
func NewServer ¶
func NewServer(logger *zap.Logger, loggerLevel *zap.AtomicLevel, version string, host string, port int, frontendHost string, frontendPort, datastorePort int, mode string, dataDir string, backupRunnerInterval time.Duration, secret string, readonly bool, demo bool, debug bool) *Server
NewServer creates a server.
func (*Server) GetEcho ¶
func (server *Server) GetEcho() *echo.Echo
GetEcho returns the echo server.
func (*Server) InitSubscription ¶
func (server *Server) InitSubscription()
InitSubscription will initial the subscription cache in memory
type TaskCheckDatabaseConnectExecutor ¶
type TaskCheckDatabaseConnectExecutor struct {
// contains filtered or unexported fields
}
TaskCheckDatabaseConnectExecutor is the task check database connect executor.
func (*TaskCheckDatabaseConnectExecutor) Run ¶
func (exec *TaskCheckDatabaseConnectExecutor) Run(ctx context.Context, server *Server, taskCheckRun *api.TaskCheckRun) (result []api.TaskCheckResult, err error)
Run will run the task check database connector executor once.
type TaskCheckExecutor ¶
type TaskCheckExecutor interface { // Run will be called periodically by the task check scheduler Run(ctx context.Context, server *Server, taskCheckRun *api.TaskCheckRun) (result []api.TaskCheckResult, err error) }
TaskCheckExecutor is the task check executor.
func NewTaskCheckDatabaseConnectExecutor ¶
func NewTaskCheckDatabaseConnectExecutor(logger *zap.Logger) TaskCheckExecutor
NewTaskCheckDatabaseConnectExecutor creates a task check database connect executor.
func NewTaskCheckMigrationSchemaExecutor ¶
func NewTaskCheckMigrationSchemaExecutor(logger *zap.Logger) TaskCheckExecutor
NewTaskCheckMigrationSchemaExecutor creates a task check migration schema executor.
func NewTaskCheckStatementAdvisorExecutor ¶
func NewTaskCheckStatementAdvisorExecutor(logger *zap.Logger) TaskCheckExecutor
NewTaskCheckStatementAdvisorExecutor creates a task check statement advisor executor.
func NewTaskCheckTimingExecutor ¶
func NewTaskCheckTimingExecutor(logger *zap.Logger) TaskCheckExecutor
NewTaskCheckTimingExecutor creates a task check timing executor.
type TaskCheckMigrationSchemaExecutor ¶
type TaskCheckMigrationSchemaExecutor struct {
// contains filtered or unexported fields
}
TaskCheckMigrationSchemaExecutor is the task check migration schema executor.
func (*TaskCheckMigrationSchemaExecutor) Run ¶
func (exec *TaskCheckMigrationSchemaExecutor) Run(ctx context.Context, server *Server, taskCheckRun *api.TaskCheckRun) (result []api.TaskCheckResult, err error)
Run will run the task check migration schema executor once.
type TaskCheckScheduler ¶
type TaskCheckScheduler struct {
// contains filtered or unexported fields
}
TaskCheckScheduler is the task check scheduler.
func NewTaskCheckScheduler ¶
func NewTaskCheckScheduler(logger *zap.Logger, server *Server) *TaskCheckScheduler
NewTaskCheckScheduler creates a task check scheduler.
func (*TaskCheckScheduler) Register ¶
func (s *TaskCheckScheduler) Register(taskType string, executor TaskCheckExecutor)
Register will register the task check executor.
type TaskCheckStatementAdvisorExecutor ¶
type TaskCheckStatementAdvisorExecutor struct {
// contains filtered or unexported fields
}
TaskCheckStatementAdvisorExecutor is the task check statement advisor executor.
func (*TaskCheckStatementAdvisorExecutor) Run ¶
func (exec *TaskCheckStatementAdvisorExecutor) Run(ctx context.Context, server *Server, taskCheckRun *api.TaskCheckRun) (result []api.TaskCheckResult, err error)
Run will run the task check statement advisor executor once.
type TaskCheckTimingExecutor ¶
type TaskCheckTimingExecutor struct {
// contains filtered or unexported fields
}
TaskCheckTimingExecutor is the task check timing executor.
func (*TaskCheckTimingExecutor) Run ¶
func (exec *TaskCheckTimingExecutor) Run(ctx context.Context, server *Server, taskCheckRun *api.TaskCheckRun) (result []api.TaskCheckResult, err error)
Run will run the task check timing executor once.
type TaskExecutor ¶
type TaskExecutor interface { // RunOnce will be called periodically by the scheduler until terminated is true. // // NOTE // // 1. It's possible that err could be non-nil while terminated is false, which // usually indicates a transient error and will make scheduler retry later. // 2. If err is non-nil, then the detail field will be ignored since info is provided in the err. RunOnce(ctx context.Context, server *Server, task *api.Task) (terminated bool, result *api.TaskRunResultPayload, err error) }
TaskExecutor is the task executor.
func NewDataUpdateTaskExecutor ¶
func NewDataUpdateTaskExecutor(logger *zap.Logger) TaskExecutor
NewDataUpdateTaskExecutor creates a data update (DML) task executor.
func NewDatabaseBackupTaskExecutor ¶
func NewDatabaseBackupTaskExecutor(logger *zap.Logger) TaskExecutor
NewDatabaseBackupTaskExecutor creates a new database backup task executor.
func NewDatabaseCreateTaskExecutor ¶
func NewDatabaseCreateTaskExecutor(logger *zap.Logger) TaskExecutor
NewDatabaseCreateTaskExecutor creates a database create task executor.
func NewDatabaseRestoreTaskExecutor ¶
func NewDatabaseRestoreTaskExecutor(logger *zap.Logger) TaskExecutor
NewDatabaseRestoreTaskExecutor creates a new database restore task executor.
func NewDefaultTaskExecutor ¶
func NewDefaultTaskExecutor(logger *zap.Logger) TaskExecutor
NewDefaultTaskExecutor creates a default task executor.
func NewSchemaUpdateTaskExecutor ¶
func NewSchemaUpdateTaskExecutor(logger *zap.Logger) TaskExecutor
NewSchemaUpdateTaskExecutor creates a schema update (DDL) task executor.
type TaskScheduler ¶
type TaskScheduler struct {
// contains filtered or unexported fields
}
TaskScheduler is the task scheduler.
func NewTaskScheduler ¶
func NewTaskScheduler(logger *zap.Logger, server *Server) *TaskScheduler
NewTaskScheduler creates a new task scheduler.
func (*TaskScheduler) Register ¶
func (s *TaskScheduler) Register(taskType string, executor TaskExecutor)
Register will register a task executor.
func (*TaskScheduler) Run ¶
func (s *TaskScheduler) Run(ctx context.Context, wg *sync.WaitGroup)
Run will run the task scheduler.
func (*TaskScheduler) ScheduleIfNeeded ¶
ScheduleIfNeeded schedules the task if its required check does not contain error in the latest run
Source Files
¶
- acl.go
- activity.go
- activity_manager.go
- actuator.go
- anomaly_scanner.go
- auth.go
- backup_runner.go
- bookmark.go
- cache.go
- database.go
- debug.go
- deploy.go
- environment.go
- inbox.go
- instance.go
- issue.go
- issue_subscriber.go
- jwt.go
- label.go
- member.go
- pipeline.go
- policy.go
- principal.go
- project.go
- project_member.go
- project_webhook.go
- recover.go
- repository.go
- schema_syncer.go
- server.go
- server_embed_dev.go
- setting.go
- sheet.go
- sql.go
- stage.go
- subscription.go
- task.go
- task_check_executor.go
- task_check_executor_database_connect.go
- task_check_executor_migration_schema.go
- task_check_executor_statement_advisor.go
- task_check_executor_timing.go
- task_check_scheduler.go
- task_executor.go
- task_executor_data_update.go
- task_executor_database_backup.go
- task_executor_database_create.go
- task_executor_database_restore.go
- task_executor_default.go
- task_executor_schema_update.go
- task_scheduler.go
- vcs.go
- webhook.go