File: hooks.go

package info (click to toggle)
restic 0.9.4%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,636 kB
  • sloc: sh: 1,460; makefile: 46; python: 35
file content (28 lines) | stat: -rw-r--r-- 367 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build debug

package debug

var (
	hooks map[string]func(interface{})
)

func init() {
	hooks = make(map[string]func(interface{}))
}

func Hook(name string, f func(interface{})) {
	hooks[name] = f
}

func RunHook(name string, context interface{}) {
	f, ok := hooks[name]
	if !ok {
		return
	}

	f(context)
}

func RemoveHook(name string) {
	delete(hooks, name)
}