Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/panjf2000/gnet
/ functions
Functions
759 in github.com/panjf2000/gnet
⨍
Functions
759
◇
Types & classes
122
↓ 347 callers
Method
Run
Run is about to be executed by the event-loop.
gnet.go:383
↓ 114 callers
Function
testUnixAddr
testUnixAddr uses os.MkdirTemp to get a name that is unique. See https://github.com/golang/go/issues/62614.
gnet_test.go:52
↓ 112 callers
Function
runServer
(t *testing.T, addrs []string, conf *testConf)
gnet_test.go:785
↓ 74 callers
Method
Close
Close closes the current connection, implements net.Conn, it's concurrency-safe.
gnet.go:470
↓ 64 callers
Method
Buffered
Buffered returns the length of available bytes to read.
pkg/buffer/ring/ring_buffer.go:270
↓ 60 callers
Method
IsEmpty
()
pkg/queue/queue.go:46
↓ 60 callers
Function
runClient
(t *testing.T, network, addr string, conf *testConf)
client_test.go:494
↓ 47 callers
Method
Available
Available returns the length of available bytes to write.
pkg/buffer/ring/ring_buffer.go:296
↓ 46 callers
Method
Write
(p []byte)
connection_unix.go:408
↓ 43 callers
Function
Run
Run starts handling events on the specified address. Address should use a scheme prefix and be formatted like `tcp://192.168.0.10:9851` or `unix://so
gnet.go:690
↓ 43 callers
Method
Write
Write writes len(p) bytes from p to the underlying buf. It returns the number of bytes written from p (n == len(p) > 0) and any error encountered that
pkg/buffer/ring/ring_buffer.go:217
↓ 42 callers
Method
Bytes
Bytes returns all available read bytes. It does not move the read pointer and only copy the available data.
pkg/buffer/ring/ring_buffer.go:317
↓ 41 callers
Method
RemoteAddr
RemoteAddr is the connection's remote address, it's not concurrency-safe, you must invoke it and use the returned value within any method in EventHand
gnet.go:459
↓ 34 callers
Method
LocalAddr
LocalAddr is the connection's local socket address, it's not concurrency-safe, you must invoke it and use the returned value within any method in Even
gnet.go:453
↓ 33 callers
Method
Peek
Peek returns the next n bytes without advancing the inbound buffer, the returned bytes remain valid until a Discard is called. buf must neither be use
gnet.go:250
↓ 32 callers
Method
Errorf
Errorf logs messages at ERROR level.
pkg/logging/logger.go:290
↓ 31 callers
Method
Discard
Discard advances the inbound buffer with next n bytes, returning the number of bytes discarded.
gnet.go:253
↓ 30 callers
Method
Read
(p []byte)
connection_unix.go:314
↓ 30 callers
Method
Read
Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p
pkg/buffer/ring/ring_buffer.go:151
↓ 29 callers
Function
WithTicker
WithTicker indicates whether a ticker is currently set.
options.go:269
↓ 27 callers
Method
Reset
Reset the read pointer and write pointer to zero.
pkg/buffer/ring/ring_buffer.go:482
↓ 25 callers
Method
Put
Put returns the byte slice to the pool.
pkg/pool/byteslice/byteslice.go:60
↓ 24 callers
Method
Dial
Dial is like net.Dial().
client_unix.go:180
↓ 21 callers
Function
Debugf
Debugf logs messages at DEBUG level.
pkg/logging/logger.go:247
↓ 21 callers
Method
Get
Get retrieves a byte slice of the length requested by the caller from pool or allocates a new one.
pkg/pool/byteslice/byteslice.go:44
↓ 21 callers
Method
getLogger
()
eventloop_unix.go:92
↓ 18 callers
Method
ConnMatrixRow
ConnMatrixRow returns the connMatrix row index.
internal/gfd/gfd.go:63
↓ 17 callers
Method
Done
Done checks and returns the internal ring-buffer to pool.
pkg/buffer/elastic/elastic_ring_buffer.go:39
↓ 17 callers
Method
Next
Next returns the next n bytes and advances the inbound buffer. buf must not be used in a new goroutine. Otherwise, use Read instead. If the number of
gnet.go:241
↓ 16 callers
Method
IsFull
IsFull tells if this ring-buffer is full.
pkg/buffer/ring/ring_buffer.go:472
↓ 15 callers
Method
Trigger
Trigger enqueues task and wakes up the poller to process pending tasks. By default, any incoming task will enqueued into urgentAsyncTaskQueue before t
pkg/netpoll/poller_epoll_default.go:90
↓ 14 callers
Method
Dequeue
()
pkg/queue/queue.go:45
↓ 14 callers
Method
Len
Len returns the length of the underlying buffer.
pkg/buffer/ring/ring_buffer.go:286
↓ 14 callers
Method
close
()
listener_unix.go:72
↓ 13 callers
Method
Debugf
Debugf logs messages at DEBUG level.
pkg/logging/logger.go:284
↓ 13 callers
Method
len
()
load_balancer.go:46
↓ 13 callers
Method
shutdown
shutdown signals the engine to shut down.
engine_unix.go:55
↓ 12 callers
Function
New
New returns a new Buffer whose buffer has the given size.
pkg/buffer/ring/ring_buffer.go:57
↓ 12 callers
Method
SafeContext
SafeContext is the concurrency-safe version of Context that can be invoked on any goroutine.
gnet.go:435
↓ 12 callers
Method
SetSafeContext
SetSafeContext is the concurrency-safe version of SetContext that can be invoked on any goroutine.
gnet.go:447
↓ 12 callers
Method
Stop
Stop gracefully shuts down this Engine without interrupting any active event-loops, it waits indefinitely for connections and event-loops to be closed
gnet.go:153
↓ 12 callers
Method
Writev
Writev writes multiple byte slices to remote synchronously, it's not concurrency-safe, you must invoke it within any method in EventHandler.
gnet.go:273
↓ 12 callers
Function
newStreamConn
(proto string, fd int, el *eventloop, sa unix.Sockaddr, localAddr, remoteAddr net.Addr)
connection_unix.go:59
↓ 12 callers
Function
testServeGC
(t *testing.T, network, addr string, multicore, async bool, elNum int, initConnCount int32)
eventloop_unix_test.go:218
↓ 12 callers
Function
testStreamProxyServer
(t *testing.T, addr string, backendServers []string, multicore, et bool)
gnet_test.go:2410
↓ 11 callers
Method
ConnMatrixColumn
ConnMatrixColumn returns the connMatrix column index.
internal/gfd/gfd.go:68
↓ 11 callers
Method
Read
Read reads data from the Buffer.
pkg/buffer/linkedlist/linked_list_buffer.go:43
↓ 11 callers
Function
parseProtoAddr
(protoAddr string)
gnet.go:762
↓ 10 callers
Function
CeilToPowerOfTwo
CeilToPowerOfTwo returns n if it is a power-of-two, otherwise the next-highest power-of-two.
pkg/math/math.go:31
↓ 10 callers
Method
Context
all methods in Socket are concurrency-safe. Context returns a user-defined context, it's not concurrency-safe, you must invoke it within any method in
gnet.go:431
↓ 10 callers
Method
Dup
Dup returns a copy of the underlying file descriptor. It is the caller's responsibility to close fd when finished. Closing c does not affect fd, and c
gnet.go:326
↓ 10 callers
Method
Enqueue
(*Task)
pkg/queue/queue.go:44
↓ 10 callers
Method
isShutdown
()
engine_unix.go:50
↓ 9 callers
Method
Cap
Cap returns the size of the underlying buffer.
pkg/buffer/ring/ring_buffer.go:291
↓ 9 callers
Function
Errorf
Errorf logs messages at ERROR level.
pkg/logging/logger.go:268
↓ 9 callers
Function
GetDefaultLogger
GetDefaultLogger returns the default logger.
pkg/logging/logger.go:175
↓ 9 callers
Function
NewLockFreeQueue
NewLockFreeQueue instantiates and returns a lockFreeQueue.
pkg/queue/lock_free_queue.go:98
↓ 9 callers
Method
PushBack
PushBack is a wrapper of pushBack, which accepts []byte as its argument.
pkg/buffer/linkedlist/linked_list_buffer.go:108
↓ 9 callers
Method
Register
Register connects to the given address and registers the connection to the current event-loop, it's concurrency-safe.
gnet.go:404
↓ 9 callers
Function
convertPollAttachment
(ptr unsafe.Pointer, attachment *PollAttachment)
pkg/netpoll/poller_unix_ultimate.go:21
↓ 9 callers
Method
iterate
(func(int, *eventloop) bool)
load_balancer.go:45
↓ 9 callers
Function
runSimServer
(t *testing.T, addr string, et bool, nclients, packetSize, batchWrite, batchRead int)
gnet_test.go:1943
↓ 8 callers
Method
Buffered
Buffered returns the length of available bytes to read.
pkg/buffer/elastic/elastic_ring_buffer.go:121
↓ 8 callers
Method
EventLoop
EventLoop returns the event-loop that the connection belongs to. The returned EventLoop is concurrency-safe.
gnet.go:439
↓ 8 callers
Function
GetDefaultFlusher
GetDefaultFlusher returns the default flusher.
pkg/logging/logger.go:182
↓ 8 callers
Function
PutTask
PutTask puts the trashy Task back in pool.
pkg/queue/queue.go:37
↓ 8 callers
Method
Read
Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p
pkg/buffer/elastic/elastic_ring_buffer.go:83
↓ 8 callers
Method
Reset
Reset removes all elements from this list.
pkg/buffer/linkedlist/linked_list_buffer.go:261
↓ 8 callers
Function
SetDefaultLoggerAndFlusher
SetDefaultLoggerAndFlusher sets the default logger and its flusher.
pkg/logging/logger.go:189
↓ 8 callers
Function
WithMulticore
WithMulticore enables multi-cores mode for gnet engine.
options.go:170
↓ 8 callers
Function
newUDPConn
(fd int, el *eventloop, localAddr net.Addr, sa unix.Sockaddr, connected bool)
connection_unix.go:74
↓ 8 callers
Method
pop
pop returns and removes the head of l. If l is empty, it returns nil.
pkg/buffer/linkedlist/linked_list_buffer.go:272
↓ 8 callers
Method
register
(*eventloop)
load_balancer.go:42
↓ 8 callers
Function
testUDPProxyServer
(t *testing.T, addr string, backendServers []string, multicore, et bool)
gnet_test.go:2677
↓ 7 callers
Method
Buffered
Buffered returns the number of bytes that can be read from the current buffer.
pkg/buffer/linkedlist/linked_list_buffer.go:251
↓ 7 callers
Method
Fatalf
Fatalf logs messages at FATAL level.
pkg/logging/logger.go:292
↓ 7 callers
Method
Polling
Polling blocks the current goroutine, monitoring the registered file descriptors and waiting for network I/O. When I/O occurs on any of the file descr
pkg/netpoll/poller_epoll_default.go:115
↓ 7 callers
Method
SetContext
SetContext sets a user-defined context, it's not concurrency-safe, you must invoke it within any method in EventHandler.
gnet.go:443
↓ 7 callers
Function
WithEdgeTriggeredIO
WithEdgeTriggeredIO enables the edge-triggered I/O for the underlying epoll/kqueue event-loop.
options.go:314
↓ 7 callers
Function
WithLockOSThread
WithLockOSThread enables LockOSThread mode for I/O event-loops.
options.go:177
↓ 7 callers
Function
WithTCPKeepAlive
WithTCPKeepAlive enables the TCP keep-alive mechanism and sets its values.
options.go:226
↓ 7 callers
Method
Write
(p []byte)
connection_windows.go:225
↓ 7 callers
Function
load
(p *unsafe.Pointer)
pkg/queue/lock_free_queue.go:165
↓ 7 callers
Method
next
(net.Addr)
load_balancer.go:43
↓ 6 callers
Method
AsyncWrite
AsyncWrite writes bytes to remote asynchronously, it's concurrency-safe, you don't have to invoke it within any method in EventHandler, usually you wo
gnet.go:292
↓ 6 callers
Method
Buffered
Buffered returns the number of bytes that can be read from the current buffer.
pkg/buffer/elastic/elastic_ring_list_buffer.go:154
↓ 6 callers
Method
DupListener
DupListener is like Dup, but it duplicates the listener with the given network and address. This is useful when there are multiple listeners.
gnet.go:137
↓ 6 callers
Method
OnTraffic
OnTraffic fires when a socket receives data from the remote. Also check out the comments on Reader and Writer interfaces.
gnet.go:509
↓ 6 callers
Method
SetKeepAlive
SetKeepAlive enables/disables the TCP keepalive with all socket options: TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT. idle is the value for TCP_KEEPID
gnet.go:367
↓ 6 callers
Function
StringToBytes
StringToBytes converts string to a byte slice without any memory allocation.
pkg/bs/bs.go:28
↓ 6 callers
Function
SysClose
(fd int)
os_windows_test.go:9
↓ 6 callers
Method
Wake
Wake triggers an OnTraffic event for the current connection, it's concurrency-safe.
gnet.go:462
↓ 6 callers
Function
WithReusePort
WithReusePort sets SO_REUSEPORT socket option.
options.go:212
↓ 6 callers
Method
Write
Write writes len(p) bytes from p to the underlying buf. It returns the number of bytes written from p (n == len(p) > 0) and any error encountered that
pkg/buffer/elastic/elastic_ring_buffer.go:108
↓ 6 callers
Method
close
(c *conn, err error)
eventloop_unix.go:363
↓ 6 callers
Function
epollCtl
(epfd int, op int, fd int, event *epollevent)
pkg/netpoll/syscall_epoll_linux.go:25
↓ 6 callers
Function
execSockOpts
(fd int, opts []Option[T])
pkg/socket/socket.go:33
↓ 6 callers
Method
release
()
connection_unix.go:92
↓ 6 callers
Function
testMulticast
(t *testing.T, addr string, reuseport, reuseaddr bool, index, nclients int)
os_unix_test.go:78
↓ 6 callers
Method
write
(data []byte)
connection_unix.go:142
next →
1–100 of 759, ranked by callers