Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for transmission of multiple #2952

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,29 @@ func StopTimeout(t time.Duration) Option {
// Before and Afters

// BeforeStart run funcs before app starts
func BeforeStart(fn func(context.Context) error) Option {
func BeforeStart(fn ...func(context.Context) error) Option {
return func(o *options) {
o.beforeStart = append(o.beforeStart, fn)
o.beforeStart = append(o.beforeStart, fn...)
}
}

// BeforeStop run funcs before app stops
func BeforeStop(fn func(context.Context) error) Option {
func BeforeStop(fn ...func(context.Context) error) Option {
return func(o *options) {
o.beforeStop = append(o.beforeStop, fn)
o.beforeStop = append(o.beforeStop, fn...)
}
}

// AfterStart run funcs after app starts
func AfterStart(fn func(context.Context) error) Option {
func AfterStart(fn ...func(context.Context) error) Option {
return func(o *options) {
o.afterStart = append(o.afterStart, fn)
o.afterStart = append(o.afterStart, fn...)
}
}

// AfterStop run funcs after app stops
func AfterStop(fn func(context.Context) error) Option {
func AfterStop(fn ...func(context.Context) error) Option {
return func(o *options) {
o.afterStop = append(o.afterStop, fn)
o.afterStop = append(o.afterStop, fn...)
}
}
8 changes: 4 additions & 4 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestBeforeStart(t *testing.T) {
t.Log("BeforeStart...")
return nil
}
BeforeStart(v)(o)
BeforeStart(v, v)(o)
}

func TestBeforeStop(t *testing.T) {
Expand All @@ -168,7 +168,7 @@ func TestBeforeStop(t *testing.T) {
t.Log("BeforeStop...")
return nil
}
BeforeStop(v)(o)
BeforeStop(v, v)(o)
}

func TestAfterStart(t *testing.T) {
Expand All @@ -177,7 +177,7 @@ func TestAfterStart(t *testing.T) {
t.Log("AfterStart...")
return nil
}
AfterStart(v)(o)
AfterStart(v, v)(o)
}

func TestAfterStop(t *testing.T) {
Expand All @@ -186,5 +186,5 @@ func TestAfterStop(t *testing.T) {
t.Log("AfterStop...")
return nil
}
AfterStop(v)(o)
AfterStop(v, v)(o)
}
Loading