Skip to content

Commit

Permalink
feat: add WithAltTransporter option for parallel monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
welkeyever committed Dec 28, 2022
1 parent f34912c commit 5c93ee7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pkg/app/server/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ func WithTransport(transporter func(options *config.Options) network.Transporter
}}
}

// WithAltTransport sets which network library to use as an alternative transporter(need to be implemented by specific transporter).
func WithAltTransport(transporter func(options *config.Options) network.Transporter) config.Option {
return config.Option{F: func(o *config.Options) {
o.AltTransporterNewer = transporter
}}
}

// WithH2C sets whether enable H2C.
func WithH2C(enable bool) config.Option {
return config.Option{F: func(o *config.Options) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/common/config/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ type Options struct {
ListenConfig *net.ListenConfig

// TransporterNewer is the function to create a transporter.
TransporterNewer func(opt *Options) network.Transporter
TransporterNewer func(opt *Options) network.Transporter
AltTransporterNewer func(opt *Options) network.Transporter

// In netpoll library, OnAccept is called after connection accepted
// but before adding it to epoll. OnConnect is called after adding it to epoll.
Expand Down

0 comments on commit 5c93ee7

Please sign in to comment.