common

package
v0.0.0-...-942df37 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LateEvent is the string returned for events that do not arrive on time
	LateEvent string = "event did not arrive by the expected time"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlueprintMaps

type BlueprintMaps struct {
	Events   map[string]EventBlueprint
	Handlers map[string]HandlerBlueprint
}

BlueprintMaps is a helper struct to keep event and handler blueprints in a single struct

func GetBlueprintMaps

func GetBlueprintMaps(blueprint *ScheduleBlueprint) (*BlueprintMaps, error)

GetBlueprintMaps returns BlueprintMaps for a given blueprint for a schedule

type EmailHandlerBlueprint

type EmailHandlerBlueprint struct {
	EmailTo string `xml:"to"`
}

EmailHandlerBlueprint is a blueprint for an email handler

type EndBlueprint

type EndBlueprint struct {
	Name string `xml:"name,attr"`
}

EndBlueprint is a blueprint for an end node.

type Event

type Event struct {
	Name       string            `json:"name" xml:"name,attr" db:"name"`
	Details    map[string]string `json:"details,omitempty" db:"details"`
	ReceivedAt int64             `json:"received-at" db:"receiveat"`
}

Event is the struct that represents something that has happened from some other system.

func (*Event) IsSuccessful

func (e *Event) IsSuccessful(c EventConstraints) (bool, string)

IsSuccessful returns true if the event has met it's set of contstraints. If false, it will also return a non-empty string as the reason for it's failure

func (*Event) ValidateEvent

func (e *Event) ValidateEvent() error

ValidateEvent is a helper function that validates that the event is correctly strutured. I.e., the Name field must not be empty. This returns an error if the event is not valid.

type EventBlueprint

type EventBlueprint struct {
	Name        string                    `xml:"name,attr"`
	Constraints EventConstraintsBlueprint `xml:"constraints"`
	OkTo        string                    `xml:"ok,attr"`
	ErrorTo     string                    `xml:"error,attr"`
}

EventBlueprint is a blueprint for an event node.

type EventConstraints

type EventConstraints struct {
	ReceiveBy int64
}

EventConstraints represent contstaints that are placed on an event. For example 'RecieveBy' is the constraint that says an event must be recieved by this time.

func FromBlueprint

func FromBlueprint(startAt time.Time, blueprint EventConstraintsBlueprint) (EventConstraints, error)

FromBlueprint returns constraints for an event based on the start time and blueprints

type EventConstraintsBlueprint

type EventConstraintsBlueprint struct {
	ReceiveBy string `xml:"receive-by,omitempty"`
}

EventConstraintsBlueprint is a blueprint for an EventConstraints struct.

type HandlerBlueprint

type HandlerBlueprint struct {
	Name  string                `xml:"name,attr"`
	Email EmailHandlerBlueprint `xml:"email,omitempty"`
	To    string                `xml:"to,attr"`
}

HandlerBlueprint is a blueprint for handler node

type ScheduleBlueprint

type ScheduleBlueprint struct {
	Timing   string             `xml:"timing,attr" db:"timing"`
	Name     string             `xml:"name,attr" db:"name"`
	StartsAt string             `xml:"starts-at,attr" db:"name"`
	Events   []EventBlueprint   `xml:"event"`
	Handlers []HandlerBlueprint `xml:"handler"`
	Start    StartBlueprint     `xml:"start"`
	End      EndBlueprint       `xml:"end"`
}

ScheduleBlueprint is the blueprint struct for a schedule. It is the serialable and static version of a schedule.

type StartBlueprint

type StartBlueprint struct {
	To string `xml:"to,attr"`
}

StartBlueprint is a blueprint for a start node.

Jump to

Keyboard shortcuts

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