2 // Copyright © 2017 Guy M. Allard
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed, an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
22 ExpiredNotification is a callback function, provided by the client
23 and called when a deadline expires. The err parameter will contain
24 the actual expired error. The rw parameter will be true if
25 the notification is for a write, and false otherwise.
27 type ExpiredNotification
func(err error
, rw
bool)
30 DeadlineData controls the use of deadlines in network I/O.
32 type deadlineData
struct {
33 wde
bool // Write deadline data enabled
34 wdld time
.Duration
// Write deadline duration
35 wds
bool // True if write duration has been set
37 dlnotify ExpiredNotification
38 dns
bool // True if dlnotify has been set
40 rde
bool // Read deadline data enabled
41 rdld time
.Duration
// Read deadline duration
42 rds
bool // True if read duration has been set
46 WriteDeadline sets the write deadline duration.
48 func (c
*Connection
) WriteDeadline(d time
.Duration
) {
49 c
.log("Write Deadline", d
)
55 EnableWriteDeadline enables/disables the use of write deadlines.
57 func (c
*Connection
) EnableWriteDeadline(e
bool) {
58 c
.log("Enable Write Deadline", e
)
63 ExpiredNotification sets the expired notification callback function.
65 func (c
*Connection
) ExpiredNotification(enf ExpiredNotification
) {
66 c
.log("Set ExpiredNotification")
72 IsWriteDeadlineEnabled returns the current value of write deadline
75 func (c
*Connection
) IsWriteDeadlineEnabled() bool {
80 ReadDeadline sets the write deadline duration.
82 func (c
*Connection
) ReadDeadline(d time
.Duration
) {
83 c
.log("Read Deadline", d
)
89 EnableReadDeadline enables/disables the use of read deadlines.
91 func (c
*Connection
) EnableReadDeadline(e
bool) {
92 c
.log("Enable Read Deadline", e
)
97 IsReadDeadlineEnabled returns the current value of write deadline
100 func (c
*Connection
) IsReadDeadlineEnabled() bool {