maglined

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LANE_READBUF_LEN  = 1024 * 100
	LANE_WRITEBUF_LEN = 1024 * 100
)
View Source
const (
	READ_BUF_SIZE = 10 * 1024
)

Variables

View Source
var (
	ENewAgent    = errors.New("New a Agent Error!")
	EREMOVE_TYPE = errors.New("Remove from List Error!")
	EINDEX       = errors.New("A Invalied Agent Index!")
	EIDLE_AGENT  = errors.New("It is a Idle Agent!")
	ENOAGENT     = errors.New("Don't Have Such a Agent")
)
View Source
var (
	EURL     = errors.New("Invaliad URL!")
	ENETWORK = errors.New("Unknown Network Type!")
)
View Source
var (
	ENewConn = errors.New("New Connection Error!")
)
View Source
var (
	ErrAddr = errors.New("Address may be invalied")
)
View Source
var (
	// ErrArg is argument's error such as nil
	ErrArg = errors.New("Argument's error")
)
View Source
var Logger *log.Logger

Functions

func DealNewAgent

func DealNewAgent(conn *Connection, req *Request) (err error)

func Exit

func Exit()

func Start

func Start()

func Version

func Version() string

Types

type Addr

type Addr struct {
	Network string
	IPPort  string
	Kpal    bool
}

func ParseAddr

func ParseAddr(url string) (addr Addr, err error)

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent is a client object

func (*Agent) DealConnReq

func (ag *Agent) DealConnReq(req *Request) (err error)

DealConnReq deal connnection reqeuest

func (*Agent) DealNewAgentRsp

func (ag *Agent) DealNewAgentRsp() (err error)

func (*Agent) DealNodeMsg

func (ag *Agent) DealNodeMsg(data []byte) (err error)

func (*Agent) DealRequest

func (ag *Agent) DealRequest(req *Request) (err error)

DealRequest deal a client's request

func (*Agent) ID

func (ag *Agent) ID() uint32

ID return's agent's id

func (*Agent) Send2Node

func (ag *Agent) Send2Node(data []byte) (err error)

type AgentMgr

type AgentMgr struct {
	// contains filtered or unexported fields
}

func NewAgentMgr

func NewAgentMgr(maxAgents int) (agentMgr *AgentMgr, err error)

func (*AgentMgr) Alloc

func (am *AgentMgr) Alloc() (agent *Agent, err error)

func (*AgentMgr) FindAgent

func (am *AgentMgr) FindAgent(id uint32) (agent *Agent, err error)

func (*AgentMgr) Init

func (am *AgentMgr) Init(maxAgents int) error

type BackendServer

type BackendServer struct {
	Addr   string
	Bridge *Bridge
}

func (*BackendServer) AcceptAndServe

func (bs *BackendServer) AcceptAndServe(ln *net.UnixListener)

func (*BackendServer) Dispatch

func (bs *BackendServer) Dispatch() (lane *Lane, err error)

func (*BackendServer) Init

func (bs *BackendServer) Init() (err error)

func (*BackendServer) Listen

func (bs *BackendServer) Listen() (err error)

type Bridge

type Bridge struct {
	// contains filtered or unexported fields
}

func (*Bridge) Alloc

func (b *Bridge) Alloc(rwc *net.UnixConn) (lane *Lane, err error)

func (*Bridge) Dispatch

func (b *Bridge) Dispatch() (lane *Lane, err error)

type ConfigInfo

type ConfigInfo struct {
	OuterAddr string
	InnerAddr string
	MaxConns  int
}
var Config ConfigInfo

type ConnPool

type ConnPool struct {
	// contains filtered or unexported fields
}

func NewMLConnPool

func NewMLConnPool(size int) (conn *ConnPool, err error)

func (*ConnPool) Alloc

func (cp *ConnPool) Alloc() (conn *Connection, err error)

func (*ConnPool) Init

func (cp *ConnPool) Init() error

func (*ConnPool) Release

func (cp *ConnPool) Release(conn *Connection) (err error)

type Connection

type Connection struct {
	RWC     *net.TCPConn
	ReadBuf []byte
	ID      int
	Elem    *list.Element
	AgentID uint32
	Server  *Server
}

func (*Connection) Close

func (conn *Connection) Close() error

func (*Connection) DealNewAgent

func (conn *Connection) DealNewAgent(req *Request)

func (*Connection) DealSendReq

func (conn *Connection) DealSendReq(req *Request)

func (*Connection) Init

func (conn *Connection) Init() error

func (*Connection) RecvRequest

func (conn *Connection) RecvRequest() (req *Request, err error)

func (*Connection) SendResponse

func (conn *Connection) SendResponse(rsp *Response) (err error)

func (*Connection) Serve

func (conn *Connection) Serve()

type Lane

type Lane struct {
	RWC *net.UnixConn

	ReadBuf []byte
	// contains filtered or unexported fields
}

func (*Lane) AddAgent

func (l *Lane) AddAgent(agent *Agent) (err error)

func (*Lane) DealConnReq

func (l *Lane) DealConnReq(msg *proto.KnotMessage) (err error)

func (*Lane) DealMsgK2N

func (l *Lane) DealMsgK2N(msg *proto.KnotMessage) (err error)

func (*Lane) DealNewAgentRsp

func (l *Lane) DealNewAgentRsp(msg *proto.KnotMessage) (err error)

func (*Lane) Init

func (l *Lane) Init() (err error)

func (*Lane) ReadMsg

func (l *Lane) ReadMsg() (msg *proto.KnotMessage, err error)

func (*Lane) SendNewAgent

func (l *Lane) SendNewAgent(id uint32) (err error)

func (*Lane) SendNodeMsg

func (l *Lane) SendNodeMsg(id uint32, data []byte) (err error)

func (*Lane) Serve

func (l *Lane) Serve()

func (*Lane) TickSeq

func (l *Lane) TickSeq() uint32

type Request

type Request struct {
	CMD     uint16
	AgentID uint32
	Body    []byte
}

type Response

type Response struct {
	CMD     uint16
	AgentID uint32
	Body    []byte
}

func (*Response) Init

func (rsp *Response) Init()

type Server

type Server struct {
	/**
	 * Address to listen such as
	 * "tcp://114.1.0.1?keep-alive=true"
	 * "tcp://114.1.0.1:80?keep-alive=false"
	 * "udp://114.1.0.1:8088"
	 */
	Addr string

	/**
	 * Coonection pool for client
	 */
	ConnPool *ConnPool

	/**
	* Agent Manger
	 */
	AgentMgr *AgentMgr

	Backend *BackendServer
}

func (*Server) Init

func (svr *Server) Init(maxConns int) (err error)

func (*Server) ListenAndServe

func (svr *Server) ListenAndServe() error

func (*Server) ListenAndServeTCP

func (svr *Server) ListenAndServeTCP(l *net.TCPListener, kpal bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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