event

package
v0.0.0-...-964918b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CreateServiceOps defines the operation to create a service, currently it
	// involves: clone repository (to check if repository exists).
	CreateServiceOps api.Operation = "create-service"

	// CreateVersionOps defines the operation to create a version, currently it
	// involves: clone repository, run CI if caicloud.yml exists and the operation
	// field in the version is not "Publish", thern tag it based on version name,
	// build docker image and push to caicloud registry, then run the postbuild
	// hook.
	CreateVersionOps api.Operation = "create-version"

	// CreateProjectVersionOps defines the operation to create a project version.
	CreateProjectVersionOps api.Operation = "create-projectversion"
)
View Source
const (
	CYCLONE_SERVER_HOST = "CYCLONE_SERVER_HOST"
	WORKER_IMAGE        = "WORKER_IMAGE"
	WORK_DOCKER_HOST    = "WORK_DOCKER_HOST"

	// worker env setting
	WORKER_EVENTID = "WORKER_EVENTID"
	SERVER_HOST    = "SERVER_HOST"

	// worker time out
	WORKER_TIMEOUT = 7200 * time.Second

	WORK_REGISTRY_LOCATION = "WORK_REGISTRY_LOCATION"
	REGISTRY_USERNAME      = "REGISTRY_USERNAME"
	REGISTRY_PASSWORD      = "REGISTRY_PASSWORD"
	CONSOLE_WEB_ENDPOINT   = "CONSOLE_WEB_ENDPOINT"
	LOG_SERVER             = "LOG_SERVER"
	CLAIR_SERVER_IP        = "CLAIR_SERVER_IP"
	SERVER_GITLAB          = "SERVER_GITLAB"
	MEMORY_FOR_CONTAINER   = "MEMORY_FOR_CONTAINER"
	CPU_FOR_CONTAINER      = "CPU_FOR_CONTAINER"
)
View Source
const (
	// unfinished event dir path in etcd
	Events_Unfinished = "/events/unfinished"
)

Variables

View Source
var (
	Err_Worker_Busy    = errors.New("Get worker docker host busy")
	Err_Unable_Support = errors.New("Unable to support the request resource")
)

Functions

func CheckWorkerTimeOut

func CheckWorkerTimeOut(e api.Event, w *Worker)

CheckWorkerTimeOut ensures that the events are not timed out.

func GetWorkerDockerHost

func GetWorkerDockerHost(event *api.Event) (string, error)

GetWorkerDockerHost get woker docker host LB according to node resource

func Init

func Init(certPath string, registry api.RegistryCompose)

Init init event manager Step1: init event operation map Step2: new a etcd client Step3: load unfinished events from etcd Step4: create a unfinished events watcher Step5: new a remote api manager

func IsEventFinished

func IsEventFinished(event *api.Event) bool

IsEventFinished return event is finished

func LoadEventFromEtcd

func LoadEventFromEtcd(eventID api.EventID) (*api.Event, error)

SaveEventToEtcd

func SaveEventToEtcd

func SaveEventToEtcd(event *api.Event) error

SaveEventToEtcd

Types

type Handler

type Handler func(*api.Event) error

Handler is the type for event handler.

type List

type List struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

List define event list

func GetList

func GetList() *List

GetList get event list

func (*List) GetEvent

func (el *List) GetEvent(eventID api.EventID) *api.Event

GetEvent gets a event from list.

type Operation

type Operation struct {
	// PostHook is called when event create.
	Handler Handler
	// PostHook is called when event has finished, and event status is set.
	PostHook PostHook
}

Operation define event operation.

type PostHook

type PostHook func(*api.Event)

PostHook is the type for post hook.

type Queue

type Queue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Queue) GetFront

func (eq *Queue) GetFront() *api.Event

func (*Queue) In

func (eq *Queue) In(event *api.Event)

func (*Queue) Init

func (eq *Queue) Init()

func (*Queue) IsEmpty

func (eq *Queue) IsEmpty() bool

func (*Queue) Out

func (eq *Queue) Out()

type RegistryCompose

type RegistryCompose struct {
	// Registry's address, ie. index.caicloud.io
	RegistryLocation string `json:"registrylocation,omitempty"`
	// RegistryUsername used for operating the images
	RegistryUsername string `json:"registryusername,omitempty"`
	// RegistryPassword used for operating the images
	RegistryPassword string `json:"registrypassword,omitempty"`
}

RegistryCompose that compose the info about the registry

type Worker

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

Worker is the type for Cyclone Worker.

func LoadWorker

func LoadWorker(event *api.Event) (*Worker, error)

LoadWorker load worker from event

func NewWorker

func NewWorker(event *api.Event) (*Worker, error)

NewWorker new a worker

func (*Worker) DoWork

func (w *Worker) DoWork(event *api.Event) (err error)

DoWork create a container start do work

func (*Worker) Fire

func (w *Worker) Fire() error

Fire fire a worker, stop and remove the worker container

Jump to

Keyboard shortcuts

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