aboutsummaryrefslogtreecommitdiff
path: root/events.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <alexander@kiryukhin.su>2019-04-04 22:56:53 +0300
committerAlexander Kiryukhin <alexander@kiryukhin.su>2019-04-04 22:56:53 +0300
commitc691d422395cb72283512d8956a255db10b70b44 (patch)
treec913d176c23495a8aa82ecc98089de10074c0929 /events.go
parent04db7b633980e7c39e582479ea41608907aa45b2 (diff)
v0.4.3v0.4.3
Added: - Hooks for lifecycle events Fixed: - Close errors channel - Small fixes
Diffstat (limited to 'events.go')
-rw-r--r--events.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/events.go b/events.go
new file mode 100644
index 0000000..d435e62
--- /dev/null
+++ b/events.go
@@ -0,0 +1,22 @@
+//go:generate stringer -type=Event
+package rutina
+
+// Event represents lifecycle events
+type Event int
+
+const (
+ EventRoutineStart Event = iota
+ EventRoutineStop
+ EventRoutineComplete
+ EventRoutineFail
+ EventAppStop
+ EventAppComplete
+ EventAppFail
+)
+
+// Hook is function that calls when event fired
+// Params:
+// ev Event - fired event
+// r *Rutina - pointer to rutina
+// rid int - ID of routine if present, 0 - otherwise
+type Hook func(ev Event, r *Rutina, rid int) error