Skip to content

Commit

Permalink
Merge pull request #27 from askuy/feature/askuyoptimize
Browse files Browse the repository at this point in the history
governor
  • Loading branch information
askuy committed Dec 18, 2020
2 parents 64b6a8e + 005ce1c commit 241ce81
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion server/egovernor/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/gotomicro/ego/core/elog"
)

type Option func(c *Container)

type Container struct {
config *Config
name string
Expand Down Expand Up @@ -35,6 +37,21 @@ func Load(key string) *Container {
return c
}

func (c *Container) Build() *Component {
func WithHost(host string) Option {
return func(c *Container) {
c.config.Host = host
}
}

func WithPort(port int) Option {
return func(c *Container) {
c.config.Port = port
}
}

func (c *Container) Build(options ...Option) *Component {
for _, option := range options {
option(c)
}
return newComponent(c.name, c.config, c.logger)
}

0 comments on commit 241ce81

Please sign in to comment.