Skip to content

Commit

Permalink
api: make DeadlineIO private
Browse files Browse the repository at this point in the history
Part of #158
  • Loading branch information
oleg-jukovec committed Apr 20, 2023
1 parent 45ad25d commit 4f6725c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- multi subpackage (#240)
- msgpack.v2 support (#236)
- pool/RoundRobinStrategy (#158)
- DeadlineIO (#158)

### Fixed

Expand Down
6 changes: 3 additions & 3 deletions deadline_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import (
"time"
)

type DeadlineIO struct {
type deadlineIO struct {
to time.Duration
c net.Conn
}

func (d *DeadlineIO) Write(b []byte) (n int, err error) {
func (d *deadlineIO) Write(b []byte) (n int, err error) {
if d.to > 0 {
d.c.SetWriteDeadline(time.Now().Add(d.to))
}
n, err = d.c.Write(b)
return
}

func (d *DeadlineIO) Read(b []byte) (n int, err error) {
func (d *deadlineIO) Read(b []byte) (n int, err error) {
if d.to > 0 {
d.c.SetReadDeadline(time.Now().Add(d.to))
}
Expand Down
2 changes: 1 addition & 1 deletion dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (t TtDialer) Dial(address string, opts DialOpts) (Conn, error) {
return nil, fmt.Errorf("failed to dial: %w", err)
}

dc := &DeadlineIO{to: opts.IoTimeout, c: conn.net}
dc := &deadlineIO{to: opts.IoTimeout, c: conn.net}
conn.reader = bufio.NewReaderSize(dc, 128*1024)
conn.writer = bufio.NewWriterSize(dc, 128*1024)

Expand Down

0 comments on commit 4f6725c

Please sign in to comment.