-
Notifications
You must be signed in to change notification settings - Fork 6
/
engine_option.go
40 lines (32 loc) · 884 Bytes
/
engine_option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2023 Remember
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package easyio
import "net"
type Option func(options *Options)
type Options struct {
numPoller int
listener func(network, addr string) (net.Listener, error) // Listener for accept conns
eventHandler EventHandler
byteBuffer ByteBuffer
}
func WithNumPoller(num int) Option {
return func(options *Options) {
options.numPoller = num
}
}
func WithListener(fn func(network, addr string) (net.Listener, error)) Option {
return func(options *Options) {
options.listener = fn
}
}
func WithEventHandler(handler EventHandler) Option {
return func(options *Options) {
options.eventHandler = handler
}
}
func WithByteBuffer(byteBuffer ByteBuffer) Option {
return func(options *Options) {
options.byteBuffer = byteBuffer
}
}