-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance.go
More file actions
37 lines (31 loc) · 779 Bytes
/
instance.go
File metadata and controls
37 lines (31 loc) · 779 Bytes
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
package application
import (
"context"
)
// Instance is a method wrapper to implement Application interface.
type Instance struct {
StartFunc func(ctx context.Context, cancel context.CancelFunc)
RunFunc func(ctx context.Context, cancel context.CancelFunc)
TerminateFunc func(ctx context.Context)
StopFunc func()
}
func (a *Instance) Start(ctx context.Context, cancel context.CancelFunc) {
if a.StartFunc != nil {
a.StartFunc(ctx, cancel)
}
}
func (a *Instance) Run(ctx context.Context, cancel context.CancelFunc) {
if a.RunFunc != nil {
a.RunFunc(ctx, cancel)
}
}
func (a *Instance) Terminate(ctx context.Context) {
if a.TerminateFunc != nil {
a.TerminateFunc(ctx)
}
}
func (a *Instance) Stop() {
if a.StopFunc != nil {
a.StopFunc()
}
}