-
Notifications
You must be signed in to change notification settings - Fork 45
/
config.go
48 lines (40 loc) · 1018 Bytes
/
config.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
41
42
43
44
45
46
47
48
package muxado
import (
"io"
"sync"
"github.com/inconshreveable/muxado/frame"
)
var zeroConfig Config
type Config struct {
// Maximum size of unread data to receive and buffer (per-stream). Default 256KB.
MaxWindowSize uint32
// Maximum number of inbound streams to queue for Accept(). Default 128.
AcceptBacklog uint32
// Function creating the Session's framer. Deafult frame.NewFramer()
NewFramer func(io.Reader, io.Writer) frame.Framer
// allow safe concurrent initialization
initOnce sync.Once
// Function to create new streams
newStream streamFactory
// Size of writeFrames channel
writeFrameQueueDepth int
}
func (c *Config) initDefaults() {
c.initOnce.Do(func() {
if c.MaxWindowSize == 0 {
c.MaxWindowSize = 0x40000 // 256KB
}
if c.AcceptBacklog == 0 {
c.AcceptBacklog = 128
}
if c.NewFramer == nil {
c.NewFramer = frame.NewFramer
}
if c.newStream == nil {
c.newStream = newStream
}
if c.writeFrameQueueDepth == 0 {
c.writeFrameQueueDepth = 64
}
})
}