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

chore: do some chores on tests and comments #499

Merged
merged 2 commits into from
Sep 10, 2023
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
6 changes: 6 additions & 0 deletions gnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ type Writer interface {
// AsyncWrite writes bytes to peer asynchronously, it's goroutine-safe,
// you don't have to invoke it within any method in EventHandler,
// usually you would call it in an individual goroutine.
//
// Note that it will go synchronously with UDP, so it is needless to call
// this asynchronous method, we may disable this method for UDP and just
// return ErrUnsupportedOp in the future, therefore, please don't rely on
// this method to do something important under UDP, if you're working with UDP,
// just call Conn.Write to send back your data.
AsyncWrite(buf []byte, callback AsyncCallback) (err error)

// AsyncWritev writes multiple byte slices to peer asynchronously,
Expand Down
10 changes: 10 additions & 0 deletions gnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ func (t *testWakeConnServer) OnTick() (delay time.Duration, action Action) {
}

func testWakeConn(t *testing.T, network, addr string) {
currentLogger, currentFlusher := logging.GetDefaultLogger(), logging.GetDefaultFlusher()
t.Cleanup(func() {
logging.SetDefaultLoggerAndFlusher(currentLogger, currentFlusher) // restore
})

svr := &testWakeConnServer{tester: t, network: network, addr: addr, conn: make(chan Conn, 1)}
logger := zap.NewExample()
err := Run(svr, network+"://"+addr,
Expand Down Expand Up @@ -1145,6 +1150,11 @@ func (t *testMultiInstLoggerRaceServer) OnBoot(_ Engine) (action Action) {
}

func TestMultiInstLoggerRace(t *testing.T) {
currentLogger, currentFlusher := logging.GetDefaultLogger(), logging.GetDefaultFlusher()
t.Cleanup(func() {
logging.SetDefaultLoggerAndFlusher(currentLogger, currentFlusher) // restore
})

logger1, _ := zap.NewDevelopment()
events1 := new(testMultiInstLoggerRaceServer)
g := errgroup.Group{}
Expand Down
Loading