ygo

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: Apache-2.0 Imports: 11 Imported by: 1

README

YGO

version 0.1.1

golang微服务框架

支持http 、 rpc 和 cli 模式

Installation

go get -u golang.org/x/net (https://github.com/golang/net)
go get -u golang.org/x/text (https://github.com/golang/text)
go get -u google.golang.org/grpc (https://github.com/grpc/grpc-go/)
go get -u google.golang.org/genproto/googleapis/rpc/status  (https://github.com/google/go-genproto/blob/master/googleapis/rpc/status)
go get -u github.com/go-sql-driver/mysql
go get -u github.com/golang/protobuf
go get -u github.com/mediocregopher/radix.v2
go get -u github.com/mlaoji/go-cache

go get -u github.com/mlaoji/ygo
go get -u github.com/mlaoji/yclient
go get -u github.com/mlaoji/yqueue

Quick Start

  1. 把github.com/mlaoji/ygo/demo目录拷贝到你的GOPATH/src路径下,作为一个演示项目
  2. 进入demo目录,执行 ./run, 启动一个http服务,浏览器访问:http://127.0.0.1:6002/testHttp/hello
  3. 再执行 ./run rpc, 启动一个RPC服务,可以到 tool目录下运行testRpc.go 测试一下rpc效果
  4. run 命令实际执行了 (go run main.go -f xxxx.conf -m rpc),-f 后面是配置文件 -m 后面是服务模式(http、rpc、 cli)
  5. 运行make脚本, 编译并输出执行文件到./bin 目录, 文件名称默认为:"app.bin", 也可指定名称, 如 make test, 则文件名为 test.app.bin
  6. 运行控制台脚本 ./serverctl 启动、停止、重启、热重启, ./serverctl start|stop|restart|reload

详细文档梳理中……

Documentation

Index

Constants

View Source
const (
	SYSTEM_VERSION = "v0.1.1"
	SERVER_HTTP    = "http"
	SERVER_RPC     = "rpc"
	SERVER_CLI     = "cli"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Ygo

type Ygo struct {
	Mode       string
	HttpServer *lib.HttpServer
	RpcServer  *lib.RpcServer
	CliServer  *lib.CliServer
}

func NewYgo

func NewYgo() *Ygo

func (*Ygo) AddApi

func (this *Ygo) AddApi(c interface{}, group ...string)

添加http 方法对应的controller, 支持分组; 默认url路径: controller/action, 分组时路径: group/controller/action

func (*Ygo) AddCli

func (this *Ygo) AddCli(c interface{})

添加cli 方法对应的controller

func (*Ygo) AddService

func (this *Ygo) AddService(c interface{})

添加rpc 方法对应的controller

func (*Ygo) Init

func (this *Ygo) Init()

func (*Ygo) Run

func (this *Ygo) Run()

支持命令行参数 -m 指定运行模式

func (*Ygo) RunCli

func (this *Ygo) RunCli()

func (*Ygo) RunHttp

func (this *Ygo) RunHttp()

func (*Ygo) RunRpc

func (this *Ygo) RunRpc()

Directories

Path Synopsis
lib
models
dao

Jump to

Keyboard shortcuts

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