Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
run: make build-all

- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.32
version: v1.45
skip-pkg-cache: true
skip-build-cache: true

Expand Down
8 changes: 8 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type Session interface {

// AllocateContext gets a Context ships with current session.
AllocateContext() Context

// Conn returns the underlined connection.
Conn() net.Conn
}

type session struct {
Expand Down Expand Up @@ -109,6 +112,11 @@ func (s *session) AllocateContext() Context {
return c
}

// Conn returns the underlined connection instance.
func (s *session) Conn() net.Conn {
return s.conn
}

// readInbound reads message packet from connection in a loop.
// And send unpacked message to reqQueue, which will be consumed in router.
// The loop breaks if errors occurred or the session is closed.
Expand Down
9 changes: 9 additions & 0 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,12 @@ func Test_session_SetID(t *testing.T) {
sess.SetID(123)
assert.Equal(t, sess.ID(), 123)
}

func Test_session_Conn(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

conn := mock.NewMockConn(ctrl)
s := newSession(conn, &sessionOption{})
assert.Equal(t, s.Conn(), conn)
}