-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.go
36 lines (30 loc) · 894 Bytes
/
util.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
package main
import (
"syscall"
"github.com/linkedin/goavro/v2"
)
func avroEncode(codec *goavro.Codec, blob []byte) ([]byte, error) {
native, _, err := codec.NativeFromTextual(blob)
if err != nil {
return nil, err
}
binary, err := codec.BinaryFromNative(nil, native)
return binary, err
}
// maxSoftFdLimit raises the file descriptor soft limit to the hard limit.
func maxSoftFdLimit() error {
var rLimit = new(syscall.Rlimit)
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, rLimit); err != nil {
return err
}
l.Printf("Original fd limit: cur=%d, max=%d", rLimit.Cur, rLimit.Max)
rLimit.Cur = rLimit.Max
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, rLimit); err != nil {
return err
}
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, rLimit); err != nil {
return err
}
l.Printf("Modified fd limit: cur=%d, max=%d.", rLimit.Cur, rLimit.Max)
return nil
}