handler

package
v0.0.0-...-bcbb5c0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Overview

Package hander handles reactions. A reaction is basically a series of actions trigerred by an event.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddReaction

func AddReaction(reaction Reaction)

AddReaction adds a reaction to the local map of reactions.

func HandleEvents

func HandleEvents(ch chan eventsources.EventData)

HandleEvents wait for events and calls handleEvent in a goroutine for each event.

func RemoveReaction

func RemoveReaction(event string, name string) error

RemoveReaction removes a reaction from the local map of reactions.

Types

type Action

type Action struct {
	Script string `json:"script"` // JS code
	Action string `json:"action"` // Name of the action
	Module string `json:"module"` // Name of the module containing the action
}

Action represents an action. It contains the JavaScript code to execute after the action, the name of the action and the name of the action module containing the action.

type Reaction

type Reaction struct {
	Actions map[string]Action `json:"actions"`
	Name    string            `json:"name"`
	Event   string            `json:"event"`
	Script  string            `json:"script"`
}

Reaction represents a reaction. It contains a list of actions to execute, the name of the reaction and the name of the event.

Jump to

Keyboard shortcuts

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