event

package
v0.0.0-...-900fa13 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// resource type
	ResourceTypeDistro = "DISTRO"

	// event types
	EventDistroAdded    = "DISTRO_ADDED"
	EventDistroModified = "DISTRO_MODIFIED"
	EventDistroRemoved  = "DISTRO_REMOVED"
)
View Source
const (
	// resource type
	ResourceTypeHost = "HOST"

	// event types
	EventHostCreated            = "HOST_CREATED"
	EventHostStatusChanged      = "HOST_STATUS_CHANGED"
	EventHostDNSNameSet         = "HOST_DNS_NAME_SET"
	EventHostProvisionFailed    = "HOST_PROVISION_FAILED"
	EventHostProvisioned        = "HOST_PROVISIONED"
	EventHostRunningTaskSet     = "HOST_RUNNING_TASK_SET"
	EventHostRunningTaskCleared = "HOST_RUNNING_TASK_CLEARED"
	EventHostTaskPidSet         = "HOST_TASK_PID_SET"
)
View Source
const (
	// resource type
	ResourceTypeTask = "TASK"

	// event types
	TaskCreated      = "TASK_CREATED"
	TaskDispatched   = "TASK_DISPATCHED"
	TaskUndispatched = "TASK_UNDISPATCHED"
	TaskStarted      = "TASK_STARTED"
	TaskFinished     = "TASK_FINISHED"
	TaskRestarted    = "TASK_RESTARTED"
	TaskActivated    = "TASK_ACTIVATED"
	TaskDeactivated  = "TASK_DEACTIVATED"
	TaskAbortRequest = "TASK_ABORT_REQUEST"
	TaskScheduled    = "TASK_SCHEDULED"
)
View Source
const (
	// db constants
	Collection = "event_log"
)

Variables

View Source
var (
	// bson fields for the event struct
	TimestampKey  = bsonutil.MustHaveTag(Event{}, "Timestamp")
	ResourceIdKey = bsonutil.MustHaveTag(Event{}, "ResourceId")
	TypeKey       = bsonutil.MustHaveTag(Event{}, "EventType")
	DataKey       = bsonutil.MustHaveTag(Event{}, "Data")

	// resource type key.  this doesn't exist a part of the event struct,
	// but has to be the same for all of the event types
	ResourceTypeKey = bsonutil.MustHaveTag(HostEventData{}, "ResourceType")
)

Functions

func DistroEventsForId

func DistroEventsForId(id string) db.Q

Distro Events

func DistroEventsInOrder

func DistroEventsInOrder(id string) db.Q

func HostEventsForId

func HostEventsForId(id string) db.Q

Host Events

func HostEventsInOrder

func HostEventsInOrder(id string) db.Q

func LogDistroAdded

func LogDistroAdded(distroId, userId string, data interface{})

func LogDistroEvent

func LogDistroEvent(distroId string, eventType string, eventData DistroEventData)

func LogDistroModified

func LogDistroModified(distroId, userId string, data interface{})

func LogDistroRemoved

func LogDistroRemoved(distroId, userId string, data interface{})

func LogHostCreated

func LogHostCreated(hostId string)

func LogHostDNSNameSet

func LogHostDNSNameSet(hostId string, dnsName string)

func LogHostEvent

func LogHostEvent(hostId string, eventType string, eventData HostEventData)

func LogHostProvisioned

func LogHostProvisioned(hostId string)

func LogHostRunningTaskCleared

func LogHostRunningTaskCleared(hostId string, taskId string)

func LogHostRunningTaskSet

func LogHostRunningTaskSet(hostId string, taskId string)

func LogHostStatusChanged

func LogHostStatusChanged(hostId string, oldStatus string,
	newStatus string)

func LogHostTaskPidSet

func LogHostTaskPidSet(hostId string, taskPid string)

func LogProvisionFailed

func LogProvisionFailed(hostId string, setupLog string)

func LogTaskAbortRequest

func LogTaskAbortRequest(taskId string, userId string)

func LogTaskActivated

func LogTaskActivated(taskId string, userId string)

func LogTaskCreated

func LogTaskCreated(taskId string)

func LogTaskDeactivated

func LogTaskDeactivated(taskId string, userId string)

func LogTaskDispatched

func LogTaskDispatched(taskId, hostId string)

func LogTaskEvent

func LogTaskEvent(taskId string, eventType string, eventData TaskEventData)

func LogTaskFinished

func LogTaskFinished(taskId string, status string)

func LogTaskRestarted

func LogTaskRestarted(taskId string, userId string)

func LogTaskScheduled

func LogTaskScheduled(taskId string, scheduledTime time.Time)

func LogTaskStarted

func LogTaskStarted(taskId string)

func LogTaskUndispatched

func LogTaskUndispatched(taskId, hostId string)

func MostRecentDistroEvents

func MostRecentDistroEvents(id string, n int) db.Q

func MostRecentHostEvents

func MostRecentHostEvents(id string, n int) db.Q

func MostRecentTaskEvents

func MostRecentTaskEvents(id string, n int) db.Q

func TaskEventsForId

func TaskEventsForId(id string) db.Q

Task Events

func TaskEventsInOrder

func TaskEventsInOrder(id string) db.Q

Types

type DBEventLogger

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

func NewDBEventLogger

func NewDBEventLogger(collection string) *DBEventLogger

func (*DBEventLogger) LogEvent

func (self *DBEventLogger) LogEvent(event Event) error

type Data

type Data interface {
	IsValid() bool
}

type DataWrapper

type DataWrapper struct {
	Data
}

func (DataWrapper) GetBSON

func (dw DataWrapper) GetBSON() (interface{}, error)

func (DataWrapper) MarshalJSON

func (dw DataWrapper) MarshalJSON() ([]byte, error)

MarshalJSON returns proper JSON encoding by uncovering the Data interface.

func (*DataWrapper) SetBSON

func (dw *DataWrapper) SetBSON(raw bson.Raw) error

type DistroEventData

type DistroEventData struct {
	// necessary for IsValid
	ResourceType string      `bson:"r_type" json:"resource_type"`
	DistroId     string      `bson:"d_id,omitempty" json:"d_id,omitempty"`
	UserId       string      `bson:"u_id,omitempty" json:"u_id,omitempty"`
	Data         interface{} `bson:"dstr,omitempty" json:"dstr,omitempty"`
}

DistroEventData implements EventData.

func (DistroEventData) IsValid

func (d DistroEventData) IsValid() bool

type Event

type Event struct {
	Timestamp  time.Time   `bson:"ts" json:"timestamp"`
	ResourceId string      `bson:"r_id" json:"resource_id"`
	EventType  string      `bson:"e_type" json:"event_type"`
	Data       DataWrapper `bson:"data" json:"data"`
}

func Find

func Find(query db.Q) ([]Event, error)

type EventLogger

type EventLogger interface {
	LogEvent(event *Event) error
}

type HostEventData

type HostEventData struct {
	// necessary for IsValid
	ResourceType string `bson:"r_type" json:"resource_type"`

	OldStatus string `bson:"o_s,omitempty" json:"old_status,omitempty"`
	NewStatus string `bson:"n_s,omitempty" json:"new_status,omitempty"`
	SetupLog  string `bson:"log,omitempty" json:"setup_log,omitempty"`
	Hostname  string `bson:"hn,omitempty" json:"hostname,omitempty"`
	TaskId    string `bson:"t_id,omitempty" json:"task_id,omitempty"`
	TaskPid   string `bson:"t_pid,omitempty" json:"task_pid,omitempty"`
}

implements EventData

func (HostEventData) IsValid

func (self HostEventData) IsValid() bool

type TaskEventData

type TaskEventData struct {
	// necessary for IsValid
	ResourceType string    `bson:"r_type" json:"resource_type"`
	HostId       string    `bson:"h_id,omitempty" json:"host_id,omitempty"`
	UserId       string    `bson:"u_id,omitempty" json:"user_id,omitempty"`
	Status       string    `bson:"s,omitempty" json:"status,omitempty"`
	Timestamp    time.Time `bson:"ts,omitempty" json:"timestamp,omitempty"`
}

implements Data

func (TaskEventData) IsValid

func (self TaskEventData) IsValid() bool

Jump to

Keyboard shortcuts

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