Skip to content

Commit

Permalink
Test Server.SetConnectTimeout
Browse files Browse the repository at this point in the history
the value is still not respected thought.
  • Loading branch information
gregoryv committed Aug 5, 2024
1 parent 26f728d commit 5a30766
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func newReceiver(h handlerFunc, r io.Reader) *receiver {
type receiver struct {
wire io.Reader
handle handlerFunc
deadline time.Duration
deadline time.Duration
}

// Run continuously handles next packet until context is cancelled
// Run handles packets until context is cancelled
func (r *receiver) Run(ctx context.Context) error {
for {
if err := ctx.Err(); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
"github.com/gregoryv/tt/ttx"
)

func TestServer_SetConnectTimeout(t *testing.T) {
srv := NewServer()
srv.SetConnectTimeout(0)
}


func TestServer_SetDebugIncreasesLogging(t *testing.T) {
srv := NewServer()
l := log.New(ioutil.Discard, "", 0)
Expand Down
1 change: 1 addition & 0 deletions srvcon.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (sc *sclient) receive(ctx context.Context, p mq.Packet) {
a.SetAssignedClientID(sc.clientID)
}
_ = sc.transmit(ctx, a)
// todo respect connectTimeout

case *mq.Subscribe:
a := mq.NewSubAck()
Expand Down

0 comments on commit 5a30766

Please sign in to comment.