server

package
v0.0.0-...-1605a13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(c io.Closer, msg string)

Close safely closes an io.Closer resource (e.g., a connection or listener) and logs an optional message if closing fails.

Types

type Server

type Server struct {
	Add        string // Address and port the server binds to.
	MaxConn    int    // Maximum number of allowed active connections.
	ActiveConn int    // Current number of active connections.
	sync.RWMutex
	Manager *memory_allocator.SlabManager // Memory allocator for managing slab memory.
}

Server represents a server that handles TCP connections, manages active connections, and uses a memory allocator for efficient data handling.

func New

func New() *Server

New initializes a new Server instance by loading the configuration and setting up the slab memory allocator.

func (*Server) HandleConn

func (s *Server) HandleConn(conn net.Conn)

HandleConn processes an individual TCP connection, reading data, allocating slab memory, and delegating requests to a job channel.

func (*Server) Req

func (s *Server) Req(buf []byte, index int, conn net.Conn)

Req sends a processed request to the slab manager's job channel, including the payload, index, and connection.

func (*Server) Run

func (s *Server) Run() error

Run starts the server, listens for incoming TCP connections, and handles them concurrently. It also enforces a maximum connection limit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL