Documentation ¶
Overview ¶
Copyright (c) 2022 Bruce Zhang
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func AcceptSocket(fd int) (int, net.Addr, error)
- func Run(eventHandler EventHandler, protoAddr string, optList ...SetOption)
- type BuiltinEventHandler
- func (builtinEventHandler BuiltinEventHandler) OnBoot(mr *MainReactor) error
- func (builtinEventHandler BuiltinEventHandler) OnClose(c Conn) error
- func (builtinEventHandler BuiltinEventHandler) OnConn(c Conn) error
- func (builtinEventHandler BuiltinEventHandler) OnOpen(c Conn) error
- func (builtinEventHandler BuiltinEventHandler) OnShutdown(mr *MainReactor) error
- func (builtinEventHandler BuiltinEventHandler) OnTraffic(c Conn) error
- type Conn
- type EventHandler
- type Listener
- type MainReactor
- type OptionArg
- type PollAttachment
- type Poller
- type SetOption
- type SubReactor
- type Writer
Constants ¶
View Source
const ( ErrEvents = unix.EPOLLERR | unix.EPOLLHUP | unix.EPOLLRDHUP // OutEvents combines EPOLLOUT event and some exceptional events. OutEvents = ErrEvents | unix.EPOLLOUT // InEvents combines EPOLLIN/EPOLLPRI events and some exceptional events. InEvents = ErrEvents | unix.EPOLLIN | unix.EPOLLPRI )
View Source
const (
PollEventsCap = 128
)
Variables ¶
View Source
var ( //close the connection ErrClose = errors.New("Close") //shutdown the reactor ErrShutdown = errors.New("Shutdown") //peer close the connection before writting completely ErrClosedWhenWritting = errors.New("Closed when writting") )
View Source
var SubReactorsNum = 10
Functions ¶
func Run ¶
func Run(eventHandler EventHandler, protoAddr string, optList ...SetOption)
Types ¶
type BuiltinEventHandler ¶
type BuiltinEventHandler struct { }
func (BuiltinEventHandler) OnBoot ¶ added in v0.9.0
func (builtinEventHandler BuiltinEventHandler) OnBoot(mr *MainReactor) error
func (BuiltinEventHandler) OnClose ¶
func (builtinEventHandler BuiltinEventHandler) OnClose(c Conn) error
func (BuiltinEventHandler) OnConn ¶
func (builtinEventHandler BuiltinEventHandler) OnConn(c Conn) error
func (BuiltinEventHandler) OnOpen ¶ added in v0.9.0
func (builtinEventHandler BuiltinEventHandler) OnOpen(c Conn) error
func (BuiltinEventHandler) OnShutdown ¶ added in v0.9.0
func (builtinEventHandler BuiltinEventHandler) OnShutdown(mr *MainReactor) error
func (BuiltinEventHandler) OnTraffic ¶ added in v0.9.0
func (builtinEventHandler BuiltinEventHandler) OnTraffic(c Conn) error
type Conn ¶
type Conn interface { //working io.Reader Writer Socket Next(n int) ([]byte, error) // LocalAddr is the connection's local socket address. LocalAddr() (addr net.Addr) // RemoteAddr is the connection's remote peer address. RemoteAddr() (addr net.Addr) SetContext(ctx interface{}) Context() interface{} Close() error }
type EventHandler ¶
type MainReactor ¶
type MainReactor struct {
// contains filtered or unexported fields
}
func (*MainReactor) Init ¶
func (mr *MainReactor) Init(proto, addr string) error
Create poller and listener for mainReactor
func (*MainReactor) Loop ¶
func (mainReactor *MainReactor) Loop()
func (*MainReactor) SetEventHandler ¶
func (mr *MainReactor) SetEventHandler(eh EventHandler)
type PollAttachment ¶
type PollAttachment struct { Fd int Event unix.EpollEvent }
type Poller ¶
type Poller struct {
Fd int
}
func (*Poller) AddPollRead ¶
func (*Poller) ModRead ¶ added in v0.9.0
ModRead renews the given file-descriptor with readable event in the poller.
func (*Poller) ModReadWrite ¶ added in v0.9.0
type SetOption ¶ added in v0.9.0
type SetOption func(optArg *OptionArg)
func WithLogLevel ¶ added in v0.9.0
func WithLogPath ¶
type SubReactor ¶
type SubReactor struct {
// contains filtered or unexported fields
}
func (*SubReactor) Loop ¶
func (sr *SubReactor) Loop() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.