Help us shape the future of Go! Take the 2026 Go Developer Survey

event

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 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"

	// PostStartPhase hooks phase
	PostStartPhase = "postStart"
	// PreStopPhase hooks phase
	PreStopPhase = "preStop"
)

Variables

View Source
var (
	CloudController *cloud.Controller
)

Functions

func CheckWorkerTimeout

func CheckWorkerTimeout(event *api.Event)

CheckWorkerTimeout ...

func DeleteEvent

func DeleteEvent(id string) error

DeleteEvent deletes the event. If it is running, delete its worker at the same time.

func GetEvent

func GetEvent(id string) (*api.Event, error)

GetEvent get the event by ID.

func Init

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

Init init event manager Step1: init cloud controller Step2: init event operation map Step3: new event manager Step4: create a goroutine to watch events Step5: new a remote api manager

func IsEventFinished

func IsEventFinished(event *api.Event) bool

IsEventFinished return true if event is finished.

func Resource2Quota

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

Resource2Quota TODO: FIXME

func SendCreateServiceEvent

func SendCreateServiceEvent(service *api.Service) error

SendCreateServiceEvent is a helper method which sends a create service event in MongoDB 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 in MongoDB and wait for the event to be acked.

func UpdateEvent

func UpdateEvent(event *api.Event) error

UpdateEvent updates the event. If it is finished, delete it and trigger the post hook.

Types

type EventManager

type EventManager interface {
	HandleEvent(event *api.Event) error
	WatchEvent()
}

EventManager represents the manager of events.

func NewEventManager

func NewEventManager(ds *store.DataStore) EventManager

NewEventManager creates the event manager.

type Handler

type Handler func(*api.Event) error

Handler is the type for event handler.

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.

Jump to

Keyboard shortcuts

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