Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRequirements = errors.New("ring does not meet the requirements")
Functions ¶
This section is empty.
Types ¶
type NetOperation ¶
NetOperation must be implemented by NetworkReactor supported operations.
type NetworkReactor ¶
type NetworkReactor struct {
// contains filtered or unexported fields
}
NetworkReactor is event loop's manager with main responsibility - handling client requests and return responses asynchronously. NetworkReactor optimized for network operations like Accept, Recv, Send.
func NewNet ¶
func NewNet(rings []*uring.Ring, opts ...Option) (*NetworkReactor, error)
NewNet create NetworkReactor instance.
func (*NetworkReactor) Cancel ¶
func (r *NetworkReactor) Cancel(id RequestID)
Cancel queued operation. id - SQE id returned by Queue method.
func (*NetworkReactor) Queue ¶
func (r *NetworkReactor) Queue(op NetOperation, cb Callback) RequestID
Queue io_uring operation. Return RequestID which can be used as the SQE identifier.
func (*NetworkReactor) QueueWithDeadline ¶
func (r *NetworkReactor) QueueWithDeadline(op NetOperation, cb Callback, deadline time.Time) RequestID
QueueWithDeadline io_uring operation. After a deadline time, a CQE with the error ECANCELED will be placed in the callback function.
func (*NetworkReactor) Run ¶
func (r *NetworkReactor) Run(ctx context.Context)
Run start NetworkReactor.
type Option ¶
type Option func(cfg *configuration)
func WithTickTimeout ¶
WithTickTimeout set tick duration for event loop.
type Reactor ¶
type Reactor struct {
// contains filtered or unexported fields
}
Reactor is event loop's manager with main responsibility - handling client requests and return responses asynchronously.
func New ¶
New create new reactor instance. rings - io_uring instances. The reactor will create one event loop for each instance. opts - reactor options.
func (*Reactor) Queue ¶
Queue io_uring operation. Callback function `cb` calling when receive cqe. Return uint64 which can be used as the SQE identifier.
func (*Reactor) QueueWithDeadline ¶
func (r *Reactor) QueueWithDeadline(op uring.Operation, cb Callback, deadline time.Time) (uint64, error)
QueueWithDeadline io_uring operation. Callback function `cb` calling when receive cqe. After a deadline time, a CQE with the error ECANCELED will be placed in the channel retChan.