gateway

package
v0.0.0-...-d4bbc0e Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 20 Imported by: 0

README

流程

  1. 监听端口
  2. 初始化协程池(ants)
  3. 初始化epoll池
    1. 打开进程打开文件限制(fd:1048576)
    2. 初始化epoll池(多个epoll)
    3. 启动(cpu核数)协程,负责accept事件,NewConnect插入eChan
    4. 启动eSize个epoll,每个分配一个协程处理eChan,以及一个协程处理msg:runProc
  4. 初始化rpc,tgrpc注册到etcd
  5. 启动rpc-client(这里启动state的client)
  6. 启动rpc-server:通过cmdChannel异步处理

协程用量

  1. 监听accept事件【cpu数量】
  2. eSize个epoll,对应一个处理eChan(accept),一个处理sendMsg【eSize*2】
  3. ants/pool【1024】
  4. tgrpc内部【TODO】

上报etcd

运行

  1. etcd
  2. go build && ./tiger gateway --config=./tiger.yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(conn *net.TCPConn) *connection

func RunMain

func RunMain(path string)

启动网关服务 [配置文件路径]

Types

type ConnIDGenerater

type ConnIDGenerater struct {
	LastStamp int64 // 记录上一次ID的时间戳
	Sequence  int64 // 当前毫秒已经生成的ID序列号(从0开始累加)1毫秒内最多生成2^16个ID
	// contains filtered or unexported fields
}

ConnId生成器

func (*ConnIDGenerater) NextID

func (w *ConnIDGenerater) NextID() (uint64, error)

这里的锁会自旋,不会多么影响性能,主要是临界区小

Directories

Path Synopsis
rpc

Jump to

Keyboard shortcuts

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