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

Cancel prev state health check on config update (merge from v3) #2

Merged
merged 1 commit into from
Oct 11, 2023
Merged
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
9 changes: 8 additions & 1 deletion pkg/server/routerfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type RouterFactory struct {

chainBuilder *middleware.ChainBuilder
tlsManager *tls.Manager

cancelPrevState func()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use type context.CancelFunc for self-documenting purposes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just copied this over from v3 branch, to simplify future merges if necessary.

}

// NewRouterFactory creates a new RouterFactory.
Expand Down Expand Up @@ -65,7 +67,12 @@ func NewRouterFactory(staticConfiguration static.Configuration, managerFactory *

// CreateRouters creates new TCPRouters and UDPRouters.
func (f *RouterFactory) CreateRouters(rtConf *runtime.Configuration) (map[string]*tcprouter.Router, map[string]udptypes.Handler) {
ctx := context.Background()
if f.cancelPrevState != nil {
f.cancelPrevState()
}

var ctx context.Context
ctx, f.cancelPrevState = context.WithCancel(context.Background())

// HTTP
serviceManager := f.managerFactory.Build(rtConf)
Expand Down
Loading