Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyashtrikul committed Oct 26, 2020
1 parent 87c76c0 commit bd31d36
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
9 changes: 9 additions & 0 deletions server/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package server

const (
rtNoWait = "nowait"
)

func NoWait(r *Runtime) {
r.options[rtNoWait] = true
}
38 changes: 34 additions & 4 deletions server/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,35 @@ const (
defaultConfigPath = "app"
)

func Run(app interface{}, cfg interface{}) {
func newRunTime(opts []Option) *Runtime {
runtime := &Runtime{options: map[string]bool{}}

for _, opt := range opts {
opt(runtime)
}

return runtime
}

type Runtime struct {
options map[string]bool
}

func (r *Runtime) Is(key string) bool {
v, ok := r.options[key]
return ok && v
}

func (r *Runtime) Not(key string) bool {
v, ok := r.options[key]
return !ok || !v
}

type Option func(r *Runtime)

func Run(app interface{}, cfg interface{}, opts ...Option) {
runtume := newRunTime(opts)

// core container instance
container := newContainer()

Expand Down Expand Up @@ -99,8 +127,10 @@ func Run(app interface{}, cfg interface{}) {
container.execute(exec)
}

// running application
if err := pipeline.Run(); err != nil {
logger.WithErrFilter(match.As(&run.SignalError{}).MatchError).Notify(err)
if runtume.Not(rtNoWait) {
// running application
if err := pipeline.Run(); err != nil {
logger.WithErrFilter(match.As(&run.SignalError{}).MatchError).Notify(err)
}
}
}
2 changes: 1 addition & 1 deletion server/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ type testConfig struct {
}

func Test_Start(t *testing.T) {
Run(testApp{}, &testConfig{})
Run(testApp{}, &testConfig{}, NoWait)
}

0 comments on commit bd31d36

Please sign in to comment.