Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta.Port implementation #183

Open
wants to merge 21 commits into
base: v310
Choose a base branch
from
9 changes: 4 additions & 5 deletions lib/flusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package lib
import (
"bufio"
"io"
"net"
"sync"
"time"
)
Expand All @@ -12,9 +11,9 @@ const (
latency time.Duration = 300 * time.Nanosecond
)

func NewFlusherWithKeepAlive(conn net.Conn, keepalive []byte, keepalivePeriod time.Duration) io.Writer {
func NewFlusherWithKeepAlive(w io.Writer, keepalive []byte, keepalivePeriod time.Duration) io.Writer {
f := &flusher{
writer: bufio.NewWriter(conn),
writer: bufio.NewWriter(w),
}
// first time it should be longer
f.timer = time.AfterFunc(latency*10, func() {
Expand All @@ -41,9 +40,9 @@ func NewFlusherWithKeepAlive(conn net.Conn, keepalive []byte, keepalivePeriod ti

}

func NewFlusher(conn net.Conn) io.Writer {
func NewFlusher(w io.Writer) io.Writer {
f := &flusher{
writer: bufio.NewWriter(conn),
writer: bufio.NewWriter(w),
}
f.timer = time.AfterFunc(latency, func() {
f.Lock()
Expand Down
Loading