exector

package
v5.2.0-release+incompa... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2020 License: LGPL-3.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OldMetadata identify older versions of metadata
	OldMetadata = "OldMetadata"
	// NewMetadata identify new version of metadata
	NewMetadata = "NewMetadata"
)

Variables

View Source
var ErrCallback = fmt.Errorf("callback task to mq")

ErrCallback do not handle this task

View Source
var MetricBackTaskNum float64

MetricBackTaskNum back task number

View Source
var MetricErrorTaskNum float64

MetricErrorTaskNum error run task number

View Source
var MetricTaskNum float64

MetricTaskNum task number

Functions

func GetVolumeDir

func GetVolumeDir() (string, string)

GetVolumeDir get volume path prifix

func RegisterWorker

func RegisterWorker(name string, fun func([]byte, *exectorManager) (TaskWorker, error))

RegisterWorker register worker creator

Types

type AppSnapshot

type AppSnapshot struct {
	Services            []*RegionServiceSnapshot
	Plugins             []*dbmodel.TenantPlugin
	PluginBuildVersions []*dbmodel.TenantPluginBuildVersion
}

AppSnapshot holds a snapshot of your app

type BackupAPPNew

type BackupAPPNew struct {
	GroupID      string   `json:"group_id" `
	ServiceIDs   []string `json:"service_ids" `
	Version      string   `json:"version"`
	EventID      string
	SourceDir    string `json:"source_dir"`
	SourceType   string `json:"source_type"`
	BackupID     string `json:"backup_id"`
	BackupSize   int64
	Logger       event.Logger
	DockerClient *client.Client

	//full-online,full-offline
	Mode     string `json:"mode"`
	S3Config struct {
		Provider   string `json:"provider"`
		Endpoint   string `json:"endpoint"`
		AccessKey  string `json:"access_key"`
		SecretKey  string `json:"secret_key"`
		BucketName string `json:"bucket_name"`
	} `json:"s3_config"`
}

BackupAPPNew backup group app new version

func (*BackupAPPNew) ErrorCallBack

func (b *BackupAPPNew) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*BackupAPPNew) GetLogger

func (b *BackupAPPNew) GetLogger() event.Logger

GetLogger GetLogger

func (*BackupAPPNew) Name

func (b *BackupAPPNew) Name() string

Name return worker name

func (*BackupAPPNew) Run

func (b *BackupAPPNew) Run(timeout time.Duration) error

Run Run

func (*BackupAPPNew) Stop

func (b *BackupAPPNew) Stop() error

Stop stop

type BackupAPPRestore

type BackupAPPRestore struct {
	//full-online,full-offline
	EventID  string
	BackupID string `json:"backup_id"`
	TenantID string `json:"tenant_id"`
	Logger   event.Logger
	//RestoreMode(cdct) current datacenter and current tenant
	//RestoreMode(cdot) current datacenter and other tenant
	//RestoreMode(od)     other datacenter
	RestoreMode  string `json:"restore_mode"`
	RestoreID    string `json:"restore_id"`
	DockerClient *client.Client

	S3Config struct {
		Provider   string `json:"provider"`
		Endpoint   string `json:"endpoint"`
		AccessKey  string `json:"access_key"`
		SecretKey  string `json:"secret_key"`
		BucketName string `json:"bucket_name"`
	} `json:"s3_config"`
	// contains filtered or unexported fields
}

BackupAPPRestore restrore the group app backup

func (*BackupAPPRestore) ErrorCallBack

func (b *BackupAPPRestore) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*BackupAPPRestore) GetLogger

func (b *BackupAPPRestore) GetLogger() event.Logger

GetLogger GetLogger

func (*BackupAPPRestore) Name

func (b *BackupAPPRestore) Name() string

Name return worker name

func (*BackupAPPRestore) Run

func (b *BackupAPPRestore) Run(timeout time.Duration) error

Run Run

func (*BackupAPPRestore) Stop

func (b *BackupAPPRestore) Stop() error

Stop stop

type Commit

type Commit struct {
	Hash    string
	Author  string
	Message string
}

Commit code Commit

type DockerComposeYaml

type DockerComposeYaml struct {
	Version  string              `yaml:"version"`
	Volumes  map[string]string   `yaml:"volumes,omitempty"`
	Services map[string]*Service `yaml:"services,omitempty"`
}

DockerComposeYaml docker compose struct

type Error

type Error struct {
	Code    uint   `json:"code"`
	Msg     string `json:"msg"`
	Details string `json:"details,omitempty"`
}

Error Error

type ExportApp

type ExportApp struct {
	EventID      string `json:"event_id"`
	Format       string `json:"format"`
	SourceDir    string `json:"source_dir"`
	Logger       event.Logger
	DockerClient *client.Client
}

ExportApp Export app to specified format(rainbond-app or dockercompose)

func (*ExportApp) CleanSourceDir

func (i *ExportApp) CleanSourceDir() error

CleanSourceDir clean export dir

func (*ExportApp) ErrorCallBack

func (i *ExportApp) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*ExportApp) GetLogger

func (i *ExportApp) GetLogger() event.Logger

GetLogger GetLogger

func (*ExportApp) Name

func (i *ExportApp) Name() string

Name return worker name

func (*ExportApp) Run

func (i *ExportApp) Run(timeout time.Duration) error

Run Run

func (*ExportApp) Stop

func (i *ExportApp) Stop() error

Stop stop

type GarbageCollectionItem

type GarbageCollectionItem struct {
	TenantID  string        `json:"tenant_id"`
	ServiceID string        `json:"service_id"`
	EventIDs  []string      `json:"event_ids"`
	Cfg       option.Config `json:"-"`
}

GarbageCollectionItem -

func NewGarbageCollectionItem

func NewGarbageCollectionItem(cfg option.Config, in []byte) (*GarbageCollectionItem, error)

NewGarbageCollectionItem creates a new GarbageCollectionItem

type ImageBuildItem

type ImageBuildItem struct {
	Namespace     string       `json:"namespace"`
	TenantName    string       `json:"tenant_name"`
	ServiceAlias  string       `json:"service_alias"`
	Image         string       `json:"image"`
	DestImage     string       `json:"dest_image"`
	Logger        event.Logger `json:"logger"`
	EventID       string       `json:"event_id"`
	DockerClient  *client.Client
	TenantID      string
	ServiceID     string
	DeployVersion string
	HubUser       string
	HubPassword   string
	Action        string
	Configs       map[string]gjson.Result `json:"configs"`
}

ImageBuildItem ImageBuildItem

func NewImageBuildItem

func NewImageBuildItem(in []byte) *ImageBuildItem

NewImageBuildItem 创建实体

func (*ImageBuildItem) Run

func (i *ImageBuildItem) Run(timeout time.Duration) error

Run Run

func (*ImageBuildItem) StorageVersionInfo

func (i *ImageBuildItem) StorageVersionInfo(imageURL string) error

StorageVersionInfo 存储version信息

func (*ImageBuildItem) UpdateVersionInfo

func (i *ImageBuildItem) UpdateVersionInfo(status string) error

UpdateVersionInfo 更新任务执行结果

type ImageShareItem

type ImageShareItem struct {
	Namespace          string `json:"namespace"`
	TenantName         string `json:"tenant_name"`
	ServiceID          string `json:"service_id"`
	ServiceAlias       string `json:"service_alias"`
	ImageName          string `json:"image_name"`
	LocalImageName     string `json:"local_image_name"`
	LocalImageUsername string `json:"-"`
	LocalImagePassword string `json:"-"`
	ShareID            string `json:"share_id"`
	Logger             event.Logger
	ShareInfo          struct {
		ServiceKey string `json:"service_key" `
		AppVersion string `json:"app_version" `
		EventID    string `json:"event_id"`
		ShareUser  string `json:"share_user"`
		ShareScope string `json:"share_scope"`
		ImageInfo  struct {
			HubURL      string `json:"hub_url"`
			HubUser     string `json:"hub_user"`
			HubPassword string `json:"hub_password"`
			Namespace   string `json:"namespace"`
			IsTrust     bool   `json:"is_trust,omitempty"`
		} `json:"image_info,omitempty"`
	} `json:"share_info"`
	DockerClient *client.Client
	EtcdCli      *clientv3.Client
}

ImageShareItem ImageShareItem

func NewImageShareItem

func NewImageShareItem(in []byte, DockerClient *client.Client, EtcdCli *clientv3.Client) (*ImageShareItem, error)

NewImageShareItem 创建实体

func (*ImageShareItem) ShareService

func (i *ImageShareItem) ShareService() error

ShareService ShareService

func (*ImageShareItem) UpdateShareStatus

func (i *ImageShareItem) UpdateShareStatus(status string) error

UpdateShareStatus 更新任务执行结果

type ImportApp

type ImportApp struct {
	EventID      string   `json:"event_id"`
	Format       string   `json:"format"`
	SourceDir    string   `json:"source_dir"`
	Apps         []string `json:"apps"`
	ServiceImage model.ServiceImage
	ServiceSlug  model.ServiceSlug
	Logger       event.Logger
	DockerClient *client.Client
	// contains filtered or unexported fields
}

ImportApp Export app to specified format(rainbond-app or dockercompose)

func (*ImportApp) ErrorCallBack

func (i *ImportApp) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*ImportApp) GetLogger

func (i *ImportApp) GetLogger() event.Logger

GetLogger GetLogger

func (*ImportApp) Name

func (i *ImportApp) Name() string

Name return worker name

func (*ImportApp) Run

func (i *ImportApp) Run(timeout time.Duration) error

Run Run

func (*ImportApp) Stop

func (i *ImportApp) Stop() error

Stop stop

type Info

type Info struct {
	ServiceID    string
	ServiceAlias string
	Status       string
	LBPorts      map[int]int
}

Info service cache info

type Manager

type Manager interface {
	GetMaxConcurrentTask() float64
	GetCurrentConcurrentTask() float64
	AddTask(*pb.TaskMessage) error
	SetReturnTaskChan(func(*pb.TaskMessage))
	Start() error
	Stop() error
}

Manager 任务执行管理器

func NewManager

func NewManager(conf option.Config, mqc mqclient.MQClient) (Manager, error)

NewManager new manager

type MarketSlugItem

type MarketSlugItem struct {
	TenantName    string       `json:"tenant_name"`
	ServiceAlias  string       `json:"service_alias"`
	Logger        event.Logger `json:"logger"`
	EventID       string       `json:"event_id"`
	Operator      string       `json:"operator"`
	DeployVersion string       `json:"deploy_version"`
	TenantID      string       `json:"tenant_id"`
	ServiceID     string       `json:"service_id"`
	Action        string       `json:"action"`
	TGZPath       string
	Configs       map[string]string `json:"configs"`
	SlugInfo      struct {
		SlugPath    string `json:"slug_path"`
		FTPHost     string `json:"ftp_host"`
		FTPPort     string `json:"ftp_port"`
		FTPUser     string `json:"ftp_username"`
		FTPPassword string `json:"ftp_password"`
	} `json:"slug_info"`
}

MarketSlugItem MarketSlugItem

func NewMarketSlugItem

func NewMarketSlugItem(in []byte) (*MarketSlugItem, error)

NewMarketSlugItem 创建实体

func (*MarketSlugItem) Run

func (i *MarketSlugItem) Run() error

Run Run

func (*MarketSlugItem) UpdateVersionInfo

func (i *MarketSlugItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error

UpdateVersionInfo 更新任务执行结果

type PluginShareItem

type PluginShareItem struct {
	EventID        string `json:"event_id"`
	ImageName      string `json:"image_name"`
	LocalImageName string `json:"local_image_name"`
	ShareID        string `json:"share_id"`
	Logger         event.Logger
	ImageInfo      struct {
		HubURL      string `json:"hub_url"`
		HubUser     string `json:"hub_user"`
		HubPassword string `json:"hub_password"`
		Namespace   string `json:"namespace"`
		IsTrust     bool   `json:"is_trust,omitempty"`
	} `json:"image_info,omitempty"`
	DockerClient *client.Client
	EtcdCli      *clientv3.Client
}

PluginShareItem PluginShareItem

func (*PluginShareItem) ErrorCallBack

func (i *PluginShareItem) ErrorCallBack(err error)

ErrorCallBack if run error will callback

func (*PluginShareItem) GetLogger

func (i *PluginShareItem) GetLogger() event.Logger

GetLogger GetLogger

func (*PluginShareItem) Name

func (i *PluginShareItem) Name() string

Name return worker name

func (*PluginShareItem) Run

func (i *PluginShareItem) Run(timeout time.Duration) error

Run Run

func (*PluginShareItem) Stop

func (i *PluginShareItem) Stop() error

Stop

type RegionServiceSnapshot

type RegionServiceSnapshot struct {
	ServiceID          string
	Service            *dbmodel.TenantServices
	ServiceProbe       []*dbmodel.TenantServiceProbe
	LBMappingPort      []*dbmodel.TenantServiceLBMappingPort
	ServiceEnv         []*dbmodel.TenantServiceEnvVar
	ServiceLabel       []*dbmodel.TenantServiceLable
	ServiceMntRelation []*dbmodel.TenantServiceMountRelation
	ServiceRelation    []*dbmodel.TenantServiceRelation
	ServiceStatus      string
	ServiceVolume      []*dbmodel.TenantServiceVolume
	ServiceConfigFile  []*dbmodel.TenantServiceConfigFile
	ServicePort        []*dbmodel.TenantServicesPort
	Versions           []*dbmodel.VersionInfo

	PluginRelation    []*dbmodel.TenantServicePluginRelation
	PluginConfigs     []*dbmodel.TenantPluginVersionDiscoverConfig
	PluginEnvs        []*dbmodel.TenantPluginVersionEnv
	PluginStreamPorts []*dbmodel.TenantServicesStreamPluginPort
}

RegionServiceSnapshot RegionServiceSnapshot

type RestoreResult

type RestoreResult struct {
	Status        string           `json:"status"`
	Message       string           `json:"message"`
	CreateTime    time.Time        `json:"create_time"`
	ServiceChange map[string]*Info `json:"service_change"`
	BackupID      string           `json:"backup_id"`
	RestoreMode   string           `json:"restore_mode"`
	EventID       string           `json:"event_id"`
	RestoreID     string           `json:"restore_id"`
	CacheDir      string           `json:"cache_dir"`
}

RestoreResult RestoreResult

type Service

type Service struct {
	Image         string            `yaml:"image"`
	ContainerName string            `yaml:"container_name,omitempty"`
	Restart       string            `yaml:"restart,omitempty"`
	NetworkMode   string            `yaml:"network_mode,omitempty"`
	Volumes       []string          `yaml:"volumes,omitempty"`
	Command       string            `yaml:"command,omitempty"`
	Environment   map[string]string `yaml:"environment,omitempty"`
	DependsOn     []string          `yaml:"depends_on,omitempty"`
	Loggin        struct {
		Driver  string `yaml:"driver,omitempty"`
		Options struct {
			MaxSize string `yaml:"max-size,omitempty"`
			MaxFile string `yaml:"max-file,omitempty"`
		}
	} `yaml:"logging,omitempty"`
}

Service service

type ServiceCheckInput

type ServiceCheckInput struct {
	CheckUUID string `json:"uuid"`
	//检测来源类型
	SourceType string `json:"source_type"`

	// 检测来源定义,
	// 代码: https://github.com/shurcooL/githubql.git master
	// docker-run: docker run --name xxx nginx:latest nginx
	// docker-compose: compose全文
	SourceBody string `json:"source_body"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	TenantID   string
	EventID    string `json:"event_id"`
}

ServiceCheckInput 任务输入数据

type ServiceCheckResult

type ServiceCheckResult struct {
	//检测状态 Success Failure
	CheckStatus string                `json:"check_status"`
	ErrorInfos  parser.ParseErrorList `json:"error_infos"`
	ServiceInfo []parser.ServiceInfo  `json:"service_info"`
}

ServiceCheckResult 应用检测结果

func CreateResult

func CreateResult(ErrorInfos parser.ParseErrorList, ServiceInfo []parser.ServiceInfo) (ServiceCheckResult, error)

CreateResult 创建检测结果

type ShareStatus

type ShareStatus struct {
	ShareID string `json:"share_id,omitempty"`
	Status  string `json:"status,omitempty"`
}

ShareStatus share status result ShareStatus share status result

func (ShareStatus) String

func (s ShareStatus) String() string

type SlugShareItem

type SlugShareItem struct {
	Namespace     string `json:"namespace"`
	TenantName    string `json:"tenant_name"`
	ServiceID     string `json:"service_id"`
	ServiceAlias  string `json:"service_alias"`
	SlugPath      string `json:"slug_path"`
	LocalSlugPath string `json:"local_slug_path"`
	ShareID       string `json:"share_id"`
	Logger        event.Logger
	ShareInfo     struct {
		ServiceKey string `json:"service_key" `
		AppVersion string `json:"app_version" `
		EventID    string `json:"event_id"`
		ShareUser  string `json:"share_user"`
		ShareScope string `json:"share_scope"`
		SlugInfo   struct {
			Namespace   string `json:"namespace"`
			FTPHost     string `json:"ftp_host"`
			FTPPort     string `json:"ftp_port"`
			FTPUser     string `json:"ftp_username"`
			FTPPassword string `json:"ftp_password"`
		} `json:"slug_info,omitempty"`
	} `json:"share_info"`
	EtcdCli     *clientv3.Client
	PackageName string
}

SlugShareItem SlugShareItem

func NewSlugShareItem

func NewSlugShareItem(in []byte, etcdCli *clientv3.Client) (*SlugShareItem, error)

NewSlugShareItem 创建实体

func (*SlugShareItem) CheckMD5FileExist

func (i *SlugShareItem) CheckMD5FileExist(md5path, packageName string) bool

CheckMD5FileExist CheckMD5FileExist

func (*SlugShareItem) ShareService

func (i *SlugShareItem) ShareService() error

ShareService Run

func (*SlugShareItem) ShareToFTP

func (i *SlugShareItem) ShareToFTP() error

ShareToFTP ShareToFTP

func (*SlugShareItem) ShareToLocal

func (i *SlugShareItem) ShareToLocal() error

ShareToLocal ShareToLocal

func (*SlugShareItem) UpdateShareStatus

func (i *SlugShareItem) UpdateShareStatus(status string) error

UpdateShareStatus 更新任务执行结果

type SourceCodeBuildItem

type SourceCodeBuildItem struct {
	Namespace     string       `json:"namespace"`
	TenantName    string       `json:"tenant_name"`
	GRDataPVCName string       `json:"gr_data_pvc_name"`
	CachePVCName  string       `json:"cache_pvc_name"`
	ServiceAlias  string       `json:"service_alias"`
	Action        string       `json:"action"`
	DestImage     string       `json:"dest_image"`
	Logger        event.Logger `json:"logger"`
	EventID       string       `json:"event_id"`
	CacheDir      string       `json:"cache_dir"`
	//SourceDir     string       `json:"source_dir"`
	TGZDir        string `json:"tgz_dir"`
	DockerClient  *client.Client
	KubeClient    kubernetes.Interface
	RbdNamespace  string
	RbdRepoName   string
	TenantID      string
	ServiceID     string
	DeployVersion string
	Lang          string
	Runtime       string
	BuildEnvs     map[string]string
	CodeSouceInfo sources.CodeSourceInfo
	RepoInfo      *sources.RepostoryBuildInfo

	Configs map[string]gjson.Result `json:"configs"`
	Ctx     context.Context
	// contains filtered or unexported fields
}

SourceCodeBuildItem SouceCodeBuildItem

func NewSouceCodeBuildItem

func NewSouceCodeBuildItem(in []byte) *SourceCodeBuildItem

NewSouceCodeBuildItem create

func (*SourceCodeBuildItem) IsDockerfile

func (i *SourceCodeBuildItem) IsDockerfile() bool

IsDockerfile CheckDockerfile

func (*SourceCodeBuildItem) Run

func (i *SourceCodeBuildItem) Run(timeout time.Duration) error

Run Run

func (*SourceCodeBuildItem) UpdateBuildVersionInfo

func (i *SourceCodeBuildItem) UpdateBuildVersionInfo(res *build.Response) error

UpdateBuildVersionInfo update service build version info to db

func (*SourceCodeBuildItem) UpdateCheckResult

func (i *SourceCodeBuildItem) UpdateCheckResult(result *dbmodel.CodeCheckResult) error

UpdateCheckResult UpdateCheckResult

func (*SourceCodeBuildItem) UpdateVersionInfo

func (i *SourceCodeBuildItem) UpdateVersionInfo(vi *dbmodel.VersionInfo) error

UpdateVersionInfo Update build application service version info

type TaskWorker

type TaskWorker interface {
	Run(timeout time.Duration) error
	GetLogger() event.Logger
	Name() string
	Stop() error
	//ErrorCallBack if run error will callback
	ErrorCallBack(err error)
}

TaskWorker worker interface

func BackupAPPNewCreater

func BackupAPPNewCreater(in []byte, m *exectorManager) (TaskWorker, error)

BackupAPPNewCreater create

func BackupAPPRestoreCreater

func BackupAPPRestoreCreater(in []byte, m *exectorManager) (TaskWorker, error)

BackupAPPRestoreCreater create

func NewExportApp

func NewExportApp(in []byte, m *exectorManager) (TaskWorker, error)

NewExportApp create

func NewImportApp

func NewImportApp(in []byte, m *exectorManager) (TaskWorker, error)

NewImportApp create

func SharePluginItemCreater

func SharePluginItemCreater(in []byte, m *exectorManager) (TaskWorker, error)

SharePluginItemCreater create

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker 工作器

func NewWorker

func NewWorker(cmdpath, user string, envs []string, in []byte) *Worker

NewWorker 创建一个worker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL