grapes

module
v0.0.0-...-9eddc24 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: Apache-2.0

README

[TOC]

Grapes

设计想法

最简单的方法来创建一个节点,每个节点定义一个继承于CoreServer的结构即可。

package main

import (
	"flag"
	grapes "github.com/kermitbu/grapes/core"
)

type GrapesMQ struct {
	grapes.CoreServer
}

func main() {
	flag.Parse()
	svr := new(GrapesMQ)
	// 注册事件处理方法
	svr.Handle(1, func(req *grapes.GRequest, res *grapes.GResponse) {
		// 处理业务逻辑
	})

	// 服务器初始化完成,开始对外提供服务
	svr.InitComplete()
}

协议定义 采用消息头+PB序列化数据的方式

type MessageHead struct {
	Cmd     uint16
	Version byte
	HeadLen byte
	BodyLen uint16
}

Directories

Path Synopsis
* @Author: kermit.bu * @Date: 2017-04-24 15:40:36 * @Last Modified by: kermit.bu * @Last Modified time: 2017-04-24 16:15:47
* @Author: kermit.bu * @Date: 2017-04-24 15:40:36 * @Last Modified by: kermit.bu * @Last Modified time: 2017-04-24 16:15:47
Package core is a generated protocol buffer package.
Package core is a generated protocol buffer package.
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.

Jump to

Keyboard shortcuts

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