event

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2018 License: Apache-2.0 Imports: 21 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"

	// PostStartPhase hooks phase
	PostStartPhase = "postStart"
	// PreStopPhase hooks phase
	PreStopPhase = "preStop"
)
View Source
const (
	// EventsUnfinished represents unfinished event dir path in etcd
	EventsUnfinished = "/events/unfinished/"
)

Variables

View Source
var (
	CloudController *cloud.Controller
)

Functions

func CheckWorkerTimeout

func CheckWorkerTimeout(event *api.Event)

CheckWorkerTimeout ...

func Init

func Init(wopts *cloud.WorkerOptions, cloudAutoDiscovery bool)

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)

LoadEventFromEtcd loads event from etcd.

func Resource2Quota

func Resource2Quota(resource api.BuildResource, def cloud.Quota) cloud.Quota

Resource2Quota TODO: FIXME

func SaveEventToEtcd

func SaveEventToEtcd(event *api.Event) error

SaveEventToEtcd saves event in etcd.

func SendCreateServiceEvent

func SendCreateServiceEvent(service *api.Service) error

SendCreateServiceEvent is a helper method which sends a create service event to etcd and wait for the event to be acked.

func SendCreateVersionEvent

func SendCreateVersionEvent(service *api.Service, version *api.Version) error

SendCreateVersionEvent is a helper method which sends a create version event to etcd and wait for the event to be acked.

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
}

Queue is the type for pending events.

func (*Queue) GetFront

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

GetFront get the first event in the queue.

func (*Queue) In

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

In enqueues a event.

func (*Queue) Init

func (eq *Queue) Init()

Init initializes a queue.

func (*Queue) IsEmpty

func (eq *Queue) IsEmpty() bool

IsEmpty checks if the queue is empty.

func (*Queue) Out

func (eq *Queue) Out()

Out dequeues a event.

Jump to

Keyboard shortcuts

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