-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
23 lines (18 loc) · 1 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package packaged
import "time"
type (
NewService func(g Group) Service
KitOptions func(*Kit)
UnitOptions func(*Unit)
)
// WithSetup
//
// Set the unit type to setup, OnInstall and OnStart will be executed immediately without delay
func WithSetup() UnitOptions { return func(u *Unit) { u.Setup = true } }
func WithIndex(idx int32) UnitOptions { return func(u *Unit) { u.Index = idx } }
func WithMaxRetry(retry int32) UnitOptions { return func(u *Unit) { u.MaxRetry = retry } }
func WithGroup(name string) UnitOptions { return func(u *Unit) { u.GroupName = name } }
func WithDescription(desc string) UnitOptions { return func(u *Unit) { u.Description = desc } }
func WithRestartPolicy(rp Restart) UnitOptions { return func(u *Unit) { u.RestartPolicy = rp } }
func WithRestartDelay(delay time.Duration) UnitOptions { return func(u *Unit) { u.RetryDelay = delay } }
func WithLogger(logger Logger) KitOptions { return func(kit *Kit) { kit.Logger = logger } }