common

package
v0.0.0-...-519dc3d Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogCompleteFlag = "0F80573E-61DA-4C1B-9CDE-396F139D63DD"
	JobUnrecognized = "unrecognized"
)
View Source
const (
	DefaultJobTTL    = 60 * 60 * 24 * 7
	FlushChannelSize = 200
	EventMapSize     = 10000
)
View Source
const (
	DefaultJobLogTTL    = 60 * 60 * 24 * 7
	JobStepID           = "%s/%s"
	JobLogReadSize      = 8 * 1024
	JobChannelSize      = 100
	JobLogStoreInterval = 10
)

Variables

This section is empty.

Functions

func StringContain

func StringContain(s []string, e string) bool

Types

type Closeable

type Closeable interface {
	Close()
}

type EngineFactory

type EngineFactory interface {
	CreateJobEngine(config config.Engine, logger *zap.Logger) (JobEngine, error)
}

type Job

type Job struct {
	JobIdentity
	UserID    string                 `json:"userID"`
	Spec      map[string]interface{} `json:"spec"`
	Engine    string                 `json:"engine"`
	StartTime time.Time              `json:"startTime"`
	EndTime   time.Time              `json:"endTime"`
	State     JobState               `json:"state"`
	Steps     []Step                 `json:"steps"`
	Detail    string                 `json:"detail"`
	Version   int32                  `json:"version"`
}

type JobEngine

type JobEngine interface {
	Closeable
	Reloadable
	Initialize() error
	GetName() string
	GetSupportedJobs() []string
	CreateJob(ctx context.Context, job *Job) error
	GetJobStatus(ctx context.Context, job Job) (*Job, error)
	DeleteJob(ctx context.Context, jobID JobIdentity) error
	StartLoop() error
	GetJobEventChannel() <-chan JobIdentity
	FetchJobStepLog(ctx context.Context, jobID JobIdentity, stepName string) (io.ReadCloser, error)
}

type JobIdentity

type JobIdentity struct {
	Service         string            `json:"service"`
	Task            string            `json:"task"`
	Domain          string            `json:"domain"`
	ID              string            `json:"id"`
	ExtraIdentities map[string]string `json:"extraIdentities,omitempty"`
}

type JobImageBuildFromReleasePara

type JobImageBuildFromReleasePara struct {
	Version      string   `json:"version"`
	Packages     []string `json:"packages"`
	Format       string   `json:"format"`
	Architecture string   `json:"architecture"`
}

type JobKind

type JobKind string

type JobLogPart

type JobLogPart struct {
	Data           []byte
	MaxJobTimeUUID string
	Finished       bool
}

type JobManager

type JobManager interface {
	Closeable
	Reloadable
	GetName() string
	CreateJob(ctx context.Context, j *Job, kind string) error
	AcceptableJob(ctx context.Context, j Job) string
	DeleteJob(ctx context.Context, jobID JobIdentity) error
	GetJob(ctx context.Context, jobID JobIdentity) (Job, error)
	BatchGetJobs(ctx context.Context, jobID JobIdentity, IDs []string) ([]Job, error)
	StartLoop() error
	RegisterJobChangeNotifyChannel(ch chan<- Job)
}

func NewJobManagerImpl

func NewJobManagerImpl(engine JobEngine, store JobStore, config appconfig.JobManager, logger *zap.Logger) (JobManager, error)

type JobState

type JobState string
const (
	JobCreated JobState = "JobCreated"
	JobRunning JobState = "JobRunning"
	JobSucceed JobState = "JobSucceed"
	JobFailed  JobState = "JobFailed"
	JobStopped JobState = "JobStopped"
)

type JobStepContext

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

type JobStepInfo

type JobStepInfo struct {
	Service         string
	Task            string
	Domain          string
	JobID           string
	ExtraIdentities map[string]string
	StepID          string
	StepName        string
}

type JobStepLog

type JobStepLog struct {
	JobIdentity
	StepID  string
	LogTime time.Time
	Data    []byte
}

type JobStore

type JobStore interface {
	Closeable
	Reloadable
	Initialize() error
	GetName() string
	CreateJob(ctx context.Context, job *Job, ttl int64) error
	UpdateJobStatus(ctx context.Context, job *Job, version int32) error
	GetJob(ctx context.Context, jobID JobIdentity) (Job, error)
	BatchGetJobs(ctx context.Context, jobID JobIdentity, IDs []string) ([]Job, error)
	DeleteJob(ctx context.Context, jobID JobIdentity) error
	DeleteJobLog(ctx context.Context, jobID JobIdentity) error
	InsertJobStepLog(ctx context.Context, log *JobStepLog, ttl int64) error
	GetJobStepLogs(ctx context.Context, jobID JobIdentity, stepID, startTime string, maxRecord int) (*JobLogPart, error)
	DeleteJobStepLog(ctx context.Context, log *JobStepLog) error
	JobStepLogFinished(ctx context.Context, jobID JobIdentity, stepID string) bool
}

type LogManager

type LogManager interface {
	Closeable
	Reloadable
	GetName() string
	StartLoop() error
	DeleteJob(ctx context.Context, jobID JobIdentity) error
	GetJobChangeChannel() chan<- Job
	GetJobStepLogs(ctx context.Context, jobID JobIdentity, stepID string, startTime string, maxRecord int) (*JobLogPart, error)
}

func NewLogManagerImpl

func NewLogManagerImpl(engine JobEngine, store JobStore, config appconfig.LogManager, logger *zap.Logger) (LogManager, error)

type ManagerFactory

type ManagerFactory interface {
	NewJobManager(engine JobEngine, store JobStore, config config.JobManager, logger *zap.Logger) (JobManager, error)
	NewLogManager(engine JobEngine, store JobStore, config config.LogManager, logger *zap.Logger) (LogManager, error)
}

func NewFactory

func NewFactory() (ManagerFactory, error)

type Reloadable

type Reloadable interface {
	Reload()
	GetReloadDirs() []string
}

type Step

type Step struct {
	ID        int       `json:"id"`
	Name      string    `json:"name"`
	State     StepState `json:"state"`
	StartTime time.Time `json:"startTime"`
	EndTime   time.Time `json:"endTime"`
	Message   string    `json:"message"`
}

type StepState

type StepState string
const (
	StepCreated StepState = "StepCreated"
	StepRunning StepState = "StepRunning"
	StepSucceed StepState = "StepSucceed"
	StepFailed  StepState = "StepFailed"
	StepStopped StepState = "StepStopped"
)

type StoreFactory

type StoreFactory interface {
	CreateJobStore(config config.PersistentStore, logger *zap.Logger) (JobStore, error)
}

Jump to

Keyboard shortcuts

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