-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangle.go
40 lines (33 loc) · 878 Bytes
/
angle.go
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
29
30
31
32
33
34
35
36
37
38
39
40
// Package angle is a Go framework with battery included.
package angle
import (
"context"
"os"
"time"
"github.com/go-angle/angle/bootstrap"
)
const (
// Version of current.
Version = "v0.1.0"
)
// Err returns error of angle.
func Err() error {
return bootstrap.Err()
}
// Start start app.
func Start(configPath string, invokes ...interface{}) (<-chan os.Signal, context.CancelFunc, error) {
bootstrap.SetConfigPath(configPath)
return bootstrap.Start(invokes...)
}
// Stop stop app.
func Stop(timeout ...time.Duration) (cancel context.CancelFunc, err error) {
return bootstrap.Stop(timeout...)
}
// RunOnce running functions during angle enviroment context.
func RunOnce(configPath string, invokes ...interface{}) (cancel context.CancelFunc, err error) {
_, cancel, err = Start(configPath, invokes...)
if err != nil {
return cancel, err
}
return Stop()
}