# jupiter
## 脚手架介绍
### jupiter脚手架工具集
1. 快速生成模板项目
2. 基于proto文件生成pb.go
3. 基于proto文件生成服务端实现
# go version
GO >= 1.13
## 脚手架工具获取
windows :
```shell script
set GO111MODULE=on
set GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
```
linux :
```shell script
export GO111MODULE=on
export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
```
`go get -u -v github.com/douyu/jupiter/tools/jupiter`
* windows 用户:
会在${GOPATH}/src/bin 目录下生成jupiter.exe 文件,若想方便的在任何地方使用jupiter命令,请将该
命令配置在系统的环境变量中
* Linux 用户:
* Mac 用户 :
## 如何使用
* jupiter -h
```shell script
E:\go\goworkspace\src\jupiter-demo\cmd>jupiter -h
NAME:
jupiter - jupiter tools
USAGE:
jupiter [global options] command [command options] [arguments...]
VERSION:
0.1.0
COMMANDS:
new, n Create Jupiter template project
protoc, p jupiter protoc tools
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--help, -h show help
--version, -v print the version
```
* jupiter new -h
```shell script
E:\go\goworkspace\src\jupiter-demo\cmd>jupiter new -h
NAME:
jupiter new - Create Jupiter template project
USAGE:
jupiter [commands|flags]
The commands & flags are:
new Create Jupiter template project
-d Build the specified directory for the template project
Examples:
# Build the specified directory for the template project
jupiter new (your project name) -d (project dir)
```
* jupiter protoc -h
```shell script
E:\go\goworkspace\src\jupiter-demo\cmd>jupiter protoc -h
NAME:
jupiter protoc - jupiter protoc tools
USAGE:
jupiter [commands|flags]
The commands & flags are:
protoc jupiter protoc tools
-g,--grpc whether to generate GRPC code
-s,--server whether to generate grpc server code
-f,--file path of proto file
-o,--out path of code generation
-p,--prefix prefix(current project name)
Examples:
# Generate GRPC code from the Proto file
# -f: Proto file address -o: Code generation path -g: Whether to generate GRPC code
jupiter protoc -f ./pb/hello/hello.proto -o ./pb/hello -g
# According to the proto file, generate the server implementation
# -f: Proto file address -o: Code generation path -p:prefix(Current project name) -g: Whether to generate Server code
jupiter protoc -f ./pb/hello/hello.proto -o ./internal/app/grpc -p jupiter-demo -s
```
## 开始实战
接下来我们会一步一步的带着大家从无到有开发jupiter应用!(gopher Let's go)
### 快速创建jupiter模板项目
```shell script
cd ${GOPATH}/src
jupiter new jupiter-demo -d ./
```
命令解释:
* new :创建jupiter模板项目
* jupiter-demo: 项目名称
* -d: 生成项目所在路径
然后就会在${GOPATH}/src 下生成jupiter-demo 项目
项目目录结构:
```go
build 编译目录
cmd 应用启动目录
config 应用配置目录
internal
├─app 应用目录
│ ├─engine
│ │ ├─engine.go 核心编排引擎(启动HTTP,GRPC,JOB等服务)
│ ├─grpc grpc服务实现目录
│ ├─handler 控制器目录(接收用户请求)
│ │ ├─user.go 控制器文件
│ ├─model model目录(定义持久层结构体)
│ │ ├─db
│ │ │ ├─user.go
│ │ ├─init.go 初始化全局数据库句柄
│ ├─service service层
│ │ ├─user 模块
│ │ │ ├─impl
│ │ │ │ ├─mysqlImpl.go 实现
│ │ │ ├─repository.go service 接口
│ │ ├─init.go
pb proto文件
sql sql脚本
.gitignore
go.mod
Makefile
```
### 运行jupiter应用
* 数据库环境准备
1. 请先在mysql中创建test库,然后将sql中的user.sql在该库中执行
2. 修改mysql配置: 在config/config.toml中 找到 `[jupiter.mysql.test]`
将`dsn` 改成你所在的环境
* 下载go.mod依赖
* 编译运行
在项目跟目录下执行以下命令
```shell script
cd cmd
go run main.go --config=../config/config.toml
```
接下来你将会看到以下日志
```shell script
E:\go\goworkspace\src\jupiter-demo\cmd>go run main.go --config=../config/config.toml
(_)_ _ _ __ (_) |_ ___ _ __
| | | | | '_ \| | __/ _ \ '__|
| | |_| | |_) | | || __/ |
_/ |\__,_| .__/|_|\__\___|_|
|__/ |_|
Welcome to jupiter, starting application ...
1592274902 INFO load local file {"mod": "config", "addr": "../config/config.toml"}
1592274902 INFO auto max procs {"mod": "proc", "procs": 4}
1592274902 INFO set global tracer {"mod": "trace"}
1592274902 INFO add job {"mod": "worker.cron", "name": "jupiter-demo/internal/app/engine.(*Engine).execJob-fm"}
?[33m[2020-06-16 10:35:02]?[0m ?[35m[info] replacing callback `gorm:delete` from E:/go/goworkspace/src/jupiter-demo/vendor/github.com/douyu/jupiter/pkg/store/gorm/orm.go:118?[0m ?[31;1m
?[0m
?[33m[2020-06-16 10:35:02]?[0m ?[35m[info] replacing callback `gorm:update` from E:/go/goworkspace/src/jupiter-demo/vendor/github.com/douyu/jupiter/pkg/store/gorm/orm.go:118?[0m ?[31;1m
?[0m
?[33m[2020-06-16 10:35:02]?[0m ?[35m[info] replacing callback `gorm:create` from E:/go/goworkspace/src/jupiter-demo/vendor/github.com/douyu/jupiter/pkg/store/gorm/orm.go:118?[0m ?[31;1m
?[0m
?[33m[2020-06-16 10:35:02]?[0m ?[35m[info] replacing callback `gorm:query` from E:/go/goworkspace/src/jupiter-demo/vendor/github.com/douyu/jupiter/pkg/store/gorm/orm.go:118?[0m ?[31;1m ?
[0m
?[33m[2020-06-16 10:35:02]?[0m ?[35m[info] replacing callback `gorm:row_query` from E:/go/goworkspace/src/jupiter-demo/vendor/github.com/douyu/jupiter/pkg/store/gorm/orm.go:118?[0m ?[31;
1m ?[0m
1592274902 INFO client mysql start {"mod": "gorm", "addr": "127.0.0.1:3306", "name": "test"}
1592274902 INFO run worker {"mod": "worker.cron", "number of scheduled jobs": 1}
1592274902 INFO cron start {"mod": "worker.cron"}
1592274902 INFO cron schedule {"mod": "worker.cron", "now": 1592274902, "entry": 1, "next": 1592274902}
1592274902 INFO cron wake {"mod": "worker.cron", "now": 1592274902}
1592274902 INFO cron run {"mod": "worker.cron", "now": 1592274902, "entry": 1, "next": 1592274912}
1592274902 INFO start servers {"mod": "app", "addr": "http://127.0.0.1:20105"}
1592274902 INFO start servers {"mod": "app", "addr": "grpc://127.0.0.1:20102"}
1592274902 INFO start governor {"mod": "app", "addr": "http://127.0.0.1:9990"}
1592274902 INFO exec job {"info": "print info"}
1592274902 WARN exec job {"warn": "print warning"}
1592274902 INFO echo add route {"mod": "server.echo", "method": "GET", "path": "/jupiter"}
1592274902 INFO echo add route {"mod": "server.echo", "method": "GET", "path": "/api/user/:id"}
1592274902 INFO echo add route {"mod": "server.echo", "method": "GET", "path": "/grpc/get"}
1592274902 INFO echo add route {"mod": "server.echo", "method": "POST", "path": "/grpc/post"}
1592274902 INFO run job
没有合适的资源?快使用搜索试试~ 我知道了~
Jupiter-jb51源码.rar x
共789个文件
go:566个
toml:74个
md:46个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 96 浏览量
2022-11-06
21:54:48
上传
评论
收藏 1.25MB RAR 举报
温馨提示
Jupiter_jb51源码
资源推荐
资源详情
资源评论
收起资源包目录
Jupiter-jb51源码.rar x (789个子文件)
.gitignore 1KB
.gitignore 1KB
.gitignore 53B
.gitignore 53B
packed-packr.go 22KB
packed-packr.go 22KB
lumberjack_linux.go 17KB
lumberjack_linux.go 17KB
lumberjack_darwin.go 17KB
lumberjack_darwin.go 17KB
lumberjack_windows.go 16KB
lumberjack_windows.go 16KB
main.go 15KB
main.go 15KB
least_loaded_test.go 14KB
least_loaded_test.go 14KB
redis_cmds.go 14KB
redis_cmds.go 14KB
jupiter.go 14KB
jupiter.go 14KB
hello.pb.go 14KB
hello.pb.go 14KB
interface.go 13KB
interface.go 13KB
registry.go 13KB
registry.go 13KB
jupiter_test.go 12KB
jupiter_test.go 12KB
conf.go 11KB
conf.go 11KB
log.go 10KB
log.go 10KB
time_test.go 9KB
time_test.go 9KB
interceptor.go 9KB
interceptor.go 9KB
flag.go 8KB
flag.go 8KB
decode.go 8KB
decode.go 8KB
interceptor.go 8KB
interceptor.go 8KB
base.go 7KB
base.go 7KB
interceptor.go 7KB
interceptor.go 7KB
rash_timer.go 7KB
rash_timer.go 7KB
const.go 7KB
const.go 7KB
config.go 7KB
config.go 7KB
map.go 6KB
map.go 6KB
registry.go 6KB
registry.go 6KB
middleware.go 6KB
middleware.go 6KB
client.go 6KB
client.go 6KB
config.go 5KB
config.go 5KB
server_test.go 5KB
server_test.go 5KB
config.go 5KB
config.go 5KB
yasee.go 5KB
yasee.go 5KB
config.go 5KB
config.go 5KB
producer.go 5KB
producer.go 5KB
option.go 5KB
option.go 5KB
file.go 4KB
file.go 4KB
swr.go 4KB
swr.go 4KB
consumer.go 4KB
consumer.go 4KB
time.go 4KB
time.go 4KB
mockserver.go 4KB
mockserver.go 4KB
interceptor.go 4KB
interceptor.go 4KB
metric.go 4KB
metric.go 4KB
file_test.go 4KB
file_test.go 4KB
config.go 4KB
config.go 4KB
unified.go 4KB
unified.go 4KB
serial_test.go 4KB
serial_test.go 4KB
orm.go 4KB
orm.go 4KB
registry_test.go 4KB
registry_test.go 4KB
共 789 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
卷积神经网络
- 粉丝: 339
- 资源: 8460
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功