@@ -32,34 +32,24 @@ type RequestServer struct {
32
32
handleCount int
33
33
}
34
34
35
- // NewRequestServer creates/allocates/returns new RequestServer.
36
- // Normally there will be one server per user-session.
37
- //
38
- // Deprecated: please use NewRequestServerWithOptions
39
- func NewRequestServer (rwc io.ReadWriteCloser , h Handlers ) * RequestServer {
40
- rs , _ := NewRequestServerWithOptions (rwc , h )
41
- return rs
42
- }
43
-
44
35
// A RequestServerOption is a function which applies configuration to a RequestServer.
45
- type RequestServerOption func (* RequestServer ) error
36
+ type RequestServerOption func (* RequestServer )
46
37
47
38
// WithRSAllocator enable the allocator.
48
39
// After processing a packet we keep in memory the allocated slices
49
40
// and we reuse them for new packets.
50
41
// The allocator is experimental
51
42
func WithRSAllocator () RequestServerOption {
52
- return func (rs * RequestServer ) error {
43
+ return func (rs * RequestServer ) {
53
44
alloc := newAllocator ()
54
45
rs .pktMgr .alloc = alloc
55
46
rs .conn .alloc = alloc
56
- return nil
57
47
}
58
48
}
59
49
60
- // NewRequestServerWithOptions creates/allocates/returns new RequestServer adding the specified options
61
- // If options is nil or empty this is equivalent to NewRequestServer
62
- func NewRequestServerWithOptions (rwc io.ReadWriteCloser , h Handlers , options ... RequestServerOption ) ( * RequestServer , error ) {
50
+ // NewRequestServer creates/allocates/returns new RequestServer.
51
+ // Normally there will be one server per user-session.
52
+ func NewRequestServer (rwc io.ReadWriteCloser , h Handlers , options ... RequestServerOption ) * RequestServer {
63
53
svrConn := & serverConn {
64
54
conn : conn {
65
55
Reader : rwc ,
@@ -74,11 +64,9 @@ func NewRequestServerWithOptions(rwc io.ReadWriteCloser, h Handlers, options ...
74
64
}
75
65
76
66
for _ , o := range options {
77
- if err := o (rs ); err != nil {
78
- return nil , err
79
- }
67
+ o (rs )
80
68
}
81
- return rs , nil
69
+ return rs
82
70
}
83
71
84
72
// New Open packet/Request
0 commit comments