workflow

package
v0.0.0-...-4d48bd8 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const AlertDBMapping string = "Alert"

AlertDBMapping is the name of the Elasticsearch type to which Alerts are added

View Source
const CronDBMapping = "Cron"
View Source
const EventDBMapping string = "_default_"
View Source
const EventTypeDBMapping string = "EventType"

EventTypeDBMapping is the name of the Elasticsearch type to which Events are added

View Source
const TestElasticsearchMapping = "TestElasticsearch"
View Source
const TriggerDBMapping string = "Trigger"

TriggerDBMapping is the name of the Elasticsearch type to which Triggers are added

View Source
const Version = "1.0.0"

Variables

This section is empty.

Functions

func ConstructEventMappingSchema

func ConstructEventMappingSchema(name string, mapping map[string]interface{}) (piazza.JsonString, error)

func IsSystemEvent

func IsSystemEvent(name string) bool

IsSystemEvent returns true if the event was generated within Piazza.

TODO: Instead, check if createdBy=system

func LoggedError

func LoggedError(mssg string, args ...interface{}) error

LoggedError logs the error's message and creates an error

Types

type Alert

type Alert struct {
	AlertID   piazza.Ident     `json:"alertId"`
	TriggerID piazza.Ident     `json:"triggerId"`
	EventID   piazza.Ident     `json:"eventId"`
	JobID     piazza.Ident     `json:"jobId"`
	CreatedBy string           `json:"createdBy"`
	CreatedOn piazza.TimeStamp `json:"createdOn"`
}

Alert is a notification, automatically created when a Trigger happens

type AlertDB

type AlertDB struct {
	*ResourceDB
	// contains filtered or unexported fields
}

func NewAlertDB

func NewAlertDB(service *Service, esi elasticsearch.IIndex) (*AlertDB, error)

func (*AlertDB) DeleteByID

func (db *AlertDB) DeleteByID(id piazza.Ident, actor string) (bool, error)

func (*AlertDB) GetAlertsByDslQuery

func (db *AlertDB) GetAlertsByDslQuery(dslString string, actor string) ([]Alert, int64, error)

func (*AlertDB) GetAll

func (db *AlertDB) GetAll(format *piazza.JsonPagination, actor string) ([]Alert, int64, error)

func (*AlertDB) GetAllByTrigger

func (db *AlertDB) GetAllByTrigger(format *piazza.JsonPagination, triggerID piazza.Ident, actor string) ([]Alert, int64, error)

func (*AlertDB) GetOne

func (db *AlertDB) GetOne(id piazza.Ident, actor string) (*Alert, bool, error)

func (*AlertDB) PostData

func (db *AlertDB) PostData(alert *Alert) error

type AlertExt

type AlertExt struct {
	AlertID   piazza.Ident     `json:"alertId"`
	Trigger   Trigger          `json:"trigger" binding:"required"`
	Event     Event            `json:"event" binding:"required"`
	JobID     piazza.Ident     `json:"jobId"`
	CreatedBy string           `json:"createdBy"`
	CreatedOn piazza.TimeStamp `json:"createdOn"`
}

type Client

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

func NewClient

func NewClient(url string, apiKey string, logger *pzsyslog.Logger) (*Client, error)

func (*Client) DeleteAlert

func (c *Client) DeleteAlert(id piazza.Ident) error

func (*Client) DeleteEvent

func (c *Client) DeleteEvent(id piazza.Ident) error

func (*Client) DeleteEventType

func (c *Client) DeleteEventType(id piazza.Ident) error

func (*Client) DeleteTrigger

func (c *Client) DeleteTrigger(id piazza.Ident) error

func (*Client) GetAlert

func (c *Client) GetAlert(id piazza.Ident) (*Alert, error)

func (*Client) GetAlertByTrigger

func (c *Client) GetAlertByTrigger(id piazza.Ident) (*[]Alert, error)

func (*Client) GetAllAlerts

func (c *Client) GetAllAlerts(perPage int, page int) (*[]Alert, error)

func (*Client) GetAllEventTypes

func (c *Client) GetAllEventTypes(perPage, page int) (*[]EventType, error)

func (*Client) GetAllEvents

func (c *Client) GetAllEvents(perPage, page int) (*[]Event, error)

func (*Client) GetAllEventsByEventType

func (c *Client) GetAllEventsByEventType(eventTypeID piazza.Ident) (*[]Event, error)

func (*Client) GetAllTriggers

func (c *Client) GetAllTriggers(perPage int, page int) (*[]Trigger, error)

func (*Client) GetEvent

func (c *Client) GetEvent(id piazza.Ident) (*Event, error)

func (*Client) GetEventType

func (c *Client) GetEventType(id piazza.Ident) (*EventType, error)

func (*Client) GetEventTypeByName

func (c *Client) GetEventTypeByName(name string) (*EventType, error)

func (*Client) GetNumAlerts

func (c *Client) GetNumAlerts() (int, error)

func (*Client) GetNumEventTypes

func (c *Client) GetNumEventTypes() (int, error)

func (*Client) GetNumEvents

func (c *Client) GetNumEvents() (int, error)

func (*Client) GetNumTriggers

func (c *Client) GetNumTriggers() (int, error)

func (*Client) GetStats

func (c *Client) GetStats() (*Stats, error)

func (*Client) GetTrigger

func (c *Client) GetTrigger(id piazza.Ident) (*Trigger, error)

func (*Client) GetVersion

func (c *Client) GetVersion() (*piazza.Version, error)

func (*Client) PostAlert

func (c *Client) PostAlert(alert *Alert) (*Alert, error)

func (*Client) PostEvent

func (c *Client) PostEvent(event *Event) (*Event, error)

func (*Client) PostEventType

func (c *Client) PostEventType(eventType *EventType) (*EventType, error)

func (*Client) PostTrigger

func (c *Client) PostTrigger(trigger *Trigger) (*Trigger, error)

func (*Client) PutAlert

func (c *Client) PutAlert(alert *Alert) (*Alert, error)

func (*Client) PutEvent

func (c *Client) PutEvent(event *Event) (*Event, error)

func (*Client) PutEventType

func (c *Client) PutEventType(eventType *EventType) (*EventType, error)

func (*Client) PutTrigger

func (c *Client) PutTrigger(id piazza.Ident, triggerUpdate *TriggerUpdate) error

func (*Client) QueryAlerts

func (c *Client) QueryAlerts(query map[string]interface{}) (*[]Alert, error)

func (*Client) QueryEventTypes

func (c *Client) QueryEventTypes(query map[string]interface{}) (*[]EventType, error)

func (*Client) QueryEvents

func (c *Client) QueryEvents(query map[string]interface{}) (*[]Event, error)

func (*Client) QueryTriggers

func (c *Client) QueryTriggers(query map[string]interface{}) (*[]Trigger, error)

func (*Client) TestElasticsearchGetOne

func (c *Client) TestElasticsearchGetOne(id piazza.Ident) (*TestElasticsearchBody, error)

func (*Client) TestElasticsearchGetVersion

func (c *Client) TestElasticsearchGetVersion() (*string, error)

func (*Client) TestElasticsearchPost

func (c *Client) TestElasticsearchPost(body *TestElasticsearchBody) (*TestElasticsearchBody, error)

type CronDB

type CronDB struct {
	*ResourceDB
	// contains filtered or unexported fields
}

CronDB TODO

func NewCronDB

func NewCronDB(service *Service, esi elasticsearch.IIndex) (*CronDB, error)

NewCronDB TODO

func (*CronDB) DeleteByID

func (db *CronDB) DeleteByID(id piazza.Ident, actor string) (bool, error)

func (*CronDB) Exists

func (db *CronDB) Exists(actor string) (bool, error)

Exists checks to see if the database exists

func (*CronDB) GetAll

func (db *CronDB) GetAll(actor string) (*[]Event, error)

GetAll TODO

func (*CronDB) PostData

func (db *CronDB) PostData(event *Event) error

PostData TODO

type Event

type Event struct {
	EventID      piazza.Ident           `json:"eventId"`
	EventTypeID  piazza.Ident           `json:"eventTypeId" binding:"required"`
	Data         map[string]interface{} `json:"data"`
	CreatedBy    string                 `json:"createdBy"`
	CreatedOn    piazza.TimeStamp       `json:"createdOn"`
	CronSchedule string                 `json:"cronSchedule"`
}

An Event is posted by some source (service, user, etc) to indicate Something Happened Data is specific to the event type

type EventDB

type EventDB struct {
	*ResourceDB
}

func NewEventDB

func NewEventDB(service *Service, esi elasticsearch.IIndex) (*EventDB, error)

func (*EventDB) AddMapping

func (db *EventDB) AddMapping(name string, mapping map[string]interface{}, actor string) error

func (*EventDB) DeleteByID

func (db *EventDB) DeleteByID(mapping string, id piazza.Ident, actor string) (bool, error)

func (*EventDB) GetAll

func (db *EventDB) GetAll(mapping string, format *piazza.JsonPagination, actor string) ([]Event, int64, error)

func (*EventDB) GetEventsByDslQuery

func (db *EventDB) GetEventsByDslQuery(mapping string, jsnString string, actor string) ([]Event, int64, error)

func (*EventDB) GetEventsByEventTypeID

func (db *EventDB) GetEventsByEventTypeID(format *piazza.JsonPagination, mapping string, eventTypeID piazza.Ident, actor string) ([]Event, int64, error)

func (*EventDB) GetOne

func (db *EventDB) GetOne(mapping string, id piazza.Ident, actor string) (*Event, bool, error)

func (*EventDB) NameExists

func (db *EventDB) NameExists(name string, actor string) (bool, error)

NameExists checks if an EventType name exists. This is easier to check in EventDB, as the mappings use the EventType.Name.

func (*EventDB) PercolateEventData

func (db *EventDB) PercolateEventData(eventType string, data map[string]interface{}, id piazza.Ident, actor string) (*[]piazza.Ident, error)

func (*EventDB) PostData

func (db *EventDB) PostData(event *Event, typ string) error

type EventList

type EventList []Event

EventList is a list of events

type EventType

type EventType struct {
	EventTypeID piazza.Ident           `json:"eventTypeId"`
	Name        string                 `json:"name" binding:"required"`
	Mapping     map[string]interface{} `json:"mapping" binding:"required"`
	CreatedBy   string                 `json:"createdBy"`
	CreatedOn   piazza.TimeStamp       `json:"createdOn"`
}

EventType describes an Event that is to be sent to workflow by a client or service

type EventTypeDB

type EventTypeDB struct {
	*ResourceDB
	// contains filtered or unexported fields
}

func NewEventTypeDB

func NewEventTypeDB(service *Service, esi elasticsearch.IIndex) (*EventTypeDB, error)

func (*EventTypeDB) DeleteByID

func (db *EventTypeDB) DeleteByID(id piazza.Ident, actor string) (bool, error)

func (*EventTypeDB) GetAll

func (db *EventTypeDB) GetAll(format *piazza.JsonPagination, actor string) ([]EventType, int64, error)

func (*EventTypeDB) GetEventTypesByDslQuery

func (db *EventTypeDB) GetEventTypesByDslQuery(dslString string, actor string) ([]EventType, int64, error)

func (*EventTypeDB) GetIDByName

func (db *EventTypeDB) GetIDByName(format *piazza.JsonPagination, name string, actor string) (*piazza.Ident, bool, error)

func (*EventTypeDB) GetOne

func (db *EventTypeDB) GetOne(id piazza.Ident, actor string) (*EventType, bool, error)

func (*EventTypeDB) PostData

func (db *EventTypeDB) PostData(eventType *EventType) error

type EventTypeList

type EventTypeList []EventType

EventTypeList is a list of EventTypes

type JobRequest

type JobRequest struct {
	CreatedBy string  `json:"createdBy"`
	JobType   JobType `json:"jobType" binding:"required"`
}

type JobType

type JobType struct {
	Data map[string]interface{} `json:"data" binding:"required"`
	Type string                 `json:"type" binding:"required"`
}

type Kit

type Kit struct {
	Service       *Service
	Server        *Server
	LogWriter     pzsyslog.Writer
	AuditWriter   pzsyslog.Writer
	Sys           *piazza.SystemConfig
	GenericServer *piazza.GenericServer
	Url           string
	// contains filtered or unexported fields
}

func NewKit

func NewKit(
	sys *piazza.SystemConfig,
	logWriter pzsyslog.Writer,
	auditWriter pzsyslog.Writer,
	mocking bool,
	pen string,
) (*Kit, error)

func (*Kit) Start

func (kit *Kit) Start() error

func (*Kit) Stop

func (kit *Kit) Stop() error

func (*Kit) Wait

func (kit *Kit) Wait() error

type ResourceDB

type ResourceDB struct {
	Esi elasticsearch.IIndex
	// contains filtered or unexported fields
}

func NewResourceDB

func NewResourceDB(service *Service, esi elasticsearch.IIndex) (*ResourceDB, error)

type Server

type Server struct {
	Routes []piazza.RouteData
	// contains filtered or unexported fields
}

func (*Server) Init

func (server *Server) Init(service *Service) error

type Service

type Service struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Service) DeleteAlert

func (service *Service) DeleteAlert(id piazza.Ident) *piazza.JsonResponse

DeleteAlert TODO

func (*Service) DeleteEvent

func (service *Service) DeleteEvent(id piazza.Ident) *piazza.JsonResponse

func (*Service) DeleteEventType

func (service *Service) DeleteEventType(id piazza.Ident) *piazza.JsonResponse

DeleteEventType TODO

func (*Service) DeleteTrigger

func (service *Service) DeleteTrigger(id piazza.Ident) *piazza.JsonResponse

func (*Service) GetAlert

func (service *Service) GetAlert(id piazza.Ident) *piazza.JsonResponse

func (*Service) GetAllAlerts

func (service *Service) GetAllAlerts(params *piazza.HttpQueryParams) *piazza.JsonResponse

func (*Service) GetAllEventTypes

func (service *Service) GetAllEventTypes(params *piazza.HttpQueryParams) *piazza.JsonResponse

GetAllEventTypes TODO

func (*Service) GetAllEvents

func (service *Service) GetAllEvents(params *piazza.HttpQueryParams) *piazza.JsonResponse

GetAllEvents TODO

func (*Service) GetAllTriggers

func (service *Service) GetAllTriggers(params *piazza.HttpQueryParams) *piazza.JsonResponse

func (*Service) GetEvent

func (service *Service) GetEvent(id piazza.Ident) *piazza.JsonResponse

GetEvent TODO

func (*Service) GetEventType

func (service *Service) GetEventType(id piazza.Ident, actor string) *piazza.JsonResponse

GetEventType TODO

func (*Service) GetStats

func (service *Service) GetStats() *piazza.JsonResponse

GetStats TODO

func (*Service) GetTrigger

func (service *Service) GetTrigger(id piazza.Ident) *piazza.JsonResponse

func (*Service) Init

func (service *Service) Init(
	sys *piazza.SystemConfig,
	logWriter pzsyslog.Writer,
	auditWriter pzsyslog.Writer,
	indices *map[string]elasticsearch.IIndex,
	pen string,
) error

Init TODO

func (*Service) InitCron

func (service *Service) InitCron() error

InitCron TODO

func (*Service) PostAlert

func (service *Service) PostAlert(alert *Alert) *piazza.JsonResponse

PostAlert TODO

func (*Service) PostEvent

func (service *Service) PostEvent(event *Event) *piazza.JsonResponse

PostEvent TODO

func (*Service) PostEventType

func (service *Service) PostEventType(eventType *EventType) *piazza.JsonResponse

PostEventType TODO

func (*Service) PostRepeatingEvent

func (service *Service) PostRepeatingEvent(event *Event) *piazza.JsonResponse

PostRepeatingEvent deals with events that have a "CronSchedule" field specified. This field is checked for validity, and then set up to repeat at the interval specified by the CronSchedule. The createdBy field of each subsequent event is filled with the eventId of this initial event, so that searching for events created by the initial event is easier.

func (*Service) PostTrigger

func (service *Service) PostTrigger(trigger *Trigger) *piazza.JsonResponse

func (*Service) PutTrigger

func (service *Service) PutTrigger(id piazza.Ident, update *TriggerUpdate) *piazza.JsonResponse

func (*Service) QueryAlerts

func (service *Service) QueryAlerts(dslString string, params *piazza.HttpQueryParams) *piazza.JsonResponse

func (*Service) QueryEventTypes

func (service *Service) QueryEventTypes(dslString string, params *piazza.HttpQueryParams) *piazza.JsonResponse

func (*Service) QueryEvents

func (service *Service) QueryEvents(jsonString string, params *piazza.HttpQueryParams) *piazza.JsonResponse

func (*Service) QueryTriggers

func (service *Service) QueryTriggers(dslString string, params *piazza.HttpQueryParams) *piazza.JsonResponse

func (*Service) TestElasticsearchGetOne

func (service *Service) TestElasticsearchGetOne(id piazza.Ident) *piazza.JsonResponse

func (*Service) TestElasticsearchPost

func (service *Service) TestElasticsearchPost(body *TestElasticsearchBody) *piazza.JsonResponse

func (*Service) TestElasticsearchVersion

func (service *Service) TestElasticsearchVersion() *piazza.JsonResponse

type Stats

type Stats struct {
	CreatedOn        piazza.TimeStamp `json:"createdOn"`
	NumEventTypes    int              `json:"numEventTypes"`
	NumEvents        int              `json:"numEvents"`
	NumTriggers      int              `json:"numTriggers"`
	NumAlerts        int              `json:"numAlerts"`
	NumTriggeredJobs int              `json:"numTriggeredJobs"`
}

func (*Stats) IncrAlerts

func (stats *Stats) IncrAlerts()

func (*Stats) IncrEventTypes

func (stats *Stats) IncrEventTypes()

func (*Stats) IncrEvents

func (stats *Stats) IncrEvents()

func (*Stats) IncrTriggerJobs

func (stats *Stats) IncrTriggerJobs()

func (*Stats) IncrTriggers

func (stats *Stats) IncrTriggers()

type TestElasticsearchBody

type TestElasticsearchBody struct {
	ID    piazza.Ident `json:"id"`
	Value int          `json:"value"`
}

type TestElasticsearchDB

type TestElasticsearchDB struct {
	*ResourceDB
	// contains filtered or unexported fields
}

func NewTestElasticsearchDB

func NewTestElasticsearchDB(service *Service, esi elasticsearch.IIndex) (*TestElasticsearchDB, error)

func (*TestElasticsearchDB) GetOne

func (db *TestElasticsearchDB) GetOne(id piazza.Ident) (*TestElasticsearchBody, bool, error)

func (*TestElasticsearchDB) GetVersion

func (db *TestElasticsearchDB) GetVersion() (string, error)

func (*TestElasticsearchDB) PostData

func (db *TestElasticsearchDB) PostData(obj interface{}, id piazza.Ident) (piazza.Ident, error)

type Trigger

type Trigger struct {
	TriggerID     piazza.Ident           `json:"triggerId"`
	Name          string                 `json:"name" binding:"required"`
	EventTypeID   piazza.Ident           `json:"eventTypeId" binding:"required"`
	Condition     map[string]interface{} `json:"condition" binding:"required"`
	Job           JobRequest             `json:"job" binding:"required"`
	PercolationID piazza.Ident           `json:"percolationId"`
	CreatedBy     string                 `json:"createdBy"`
	CreatedOn     piazza.TimeStamp       `json:"createdOn"`
	Enabled       bool                   `json:"enabled"`
}

Trigger does something when the and'ed set of Conditions all are true Events are the results of the Conditions queries Job is the JobMessage to submit back to Pz

type TriggerDB

type TriggerDB struct {
	*ResourceDB
	// contains filtered or unexported fields
}

func NewTriggerDB

func NewTriggerDB(service *Service, esi elasticsearch.IIndex) (*TriggerDB, error)

func (*TriggerDB) DeleteTrigger

func (db *TriggerDB) DeleteTrigger(id piazza.Ident, actor string) (bool, error)

func (*TriggerDB) GetAll

func (db *TriggerDB) GetAll(format *piazza.JsonPagination, actor string) ([]Trigger, int64, error)

func (*TriggerDB) GetOne

func (db *TriggerDB) GetOne(id piazza.Ident, actor string) (*Trigger, bool, error)

func (*TriggerDB) GetTriggersByDslQuery

func (db *TriggerDB) GetTriggersByDslQuery(dslString string, actor string) ([]Trigger, int64, error)

func (*TriggerDB) GetTriggersByEventTypeID

func (db *TriggerDB) GetTriggersByEventTypeID(format *piazza.JsonPagination, id piazza.Ident, actor string) ([]Trigger, int64, error)

func (*TriggerDB) PostData

func (db *TriggerDB) PostData(trigger *Trigger) error

func (*TriggerDB) PutTrigger

func (db *TriggerDB) PutTrigger(trigger *Trigger, update *TriggerUpdate, actor string) (*Trigger, error)

type TriggerList

type TriggerList []Trigger

TriggerList is a list of triggers

type TriggerUpdate

type TriggerUpdate struct {
	Enabled bool `json:"enabled"`
}

Jump to

Keyboard shortcuts

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