-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.go
50 lines (42 loc) · 914 Bytes
/
builder.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
49
50
package putxt
import (
"time"
"git.tcp.direct/kayos/common/pool"
"github.com/yunginnanet/Rate5"
)
type TermDumpster struct {
gzip bool
maxSize int64
timeout time.Duration
handler Handler
log Logger
Pool pool.BufferFactory
*rate5.Limiter
}
func NewTermDumpster(handler Handler) *TermDumpster {
td := &TermDumpster{
maxSize: 3 << 20,
timeout: 5 * time.Second,
Limiter: rate5.NewStrictLimiter(60, 10),
handler: handler,
log: dummyLogger{},
Pool: pool.NewBufferFactory(),
}
return td
}
func (td *TermDumpster) WithGzip() *TermDumpster {
td.gzip = true
return td
}
func (td *TermDumpster) WithMaxSize(size int64) *TermDumpster {
td.maxSize = size
return td
}
func (td *TermDumpster) WithTimeout(timeout time.Duration) *TermDumpster {
td.timeout = timeout
return td
}
func (td *TermDumpster) WithLogger(logger Logger) *TermDumpster {
td.log = logger
return td
}