Skip to content

Commit

Permalink
feat: add Initialize to init pollers actively
Browse files Browse the repository at this point in the history
  • Loading branch information
joway committed Feb 20, 2024
1 parent 06e5be6 commit dba7064
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions netpoll_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ func SetLoadBalance(lb LoadBalance) error {
return setLoadBalance(lb)
}

// Initialize the pollers actively. By default, it's lazy initialized.
// It's safe to call it multi times.
func Initialize() {
initialize()
}

func SetLoggerOutput(w io.Writer) {
setLoggerOutput(w)
}
Expand Down
5 changes: 5 additions & 0 deletions poll_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func setLoadBalance(lb LoadBalance) error {
return pollmanager.SetLoadBalance(lb)
}

func initialize() {
// The first call of Pick() will init pollers
_ = pollmanager.Pick()
}

func setLoggerOutput(w io.Writer) {
logger = log.New(w, "", log.LstdFlags)
}
Expand Down

0 comments on commit dba7064

Please sign in to comment.