Skip to content

Commit 63fe5b8

Browse files
author
Eolink
authored
Merge pull request #23 from Dot-Liu/master
完善注释
2 parents a8e546a + ab0b8b9 commit 63fe5b8

File tree

228 files changed

+2518
-2483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+2518
-2483
lines changed

app/console/config/cluster.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cluster:
2-
- name: "Default"
2+
-
3+
name: "Default"
34
title: "默认机房"
45
note: "默认机房"
56
db:

app/console/main.go

+3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import (
1212
)
1313

1414
var (
15+
// UserPassword 用户密码
1516
UserPassword string
17+
// UserName 用户名
1618
UserName string
19+
// ConfFilePath 配置文件地址
1720
ConfFilePath = "./config/goku.conf"
1821

1922
)

app/goku-node/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/eolinker/goku-api-gateway/common/database"
1515
"github.com/eolinker/goku-api-gateway/common/general"
16-
"github.com/eolinker/goku-api-gateway/common/redis-manager"
16+
redis_manager "github.com/eolinker/goku-api-gateway/common/redis-manager"
1717
goku_node "github.com/eolinker/goku-api-gateway/goku-node"
1818
"github.com/eolinker/goku-api-gateway/server/entity"
1919
)
@@ -69,11 +69,11 @@ func main() {
6969
return
7070
}
7171
goku_node.InitLog()
72-
log.Debug("goku_node.InitLog")
72+
log.Debug("gokNode.InitLog")
7373
r := redis_manager.Create(&config.Redis)
7474
redis_manager.SetDefault(r)
7575

76-
log.Debug("redis_manager.SetDefault")
76+
log.Debug("redis-manager.SetDefault")
7777
// 其他需要初始化的模块
7878
_ = general.General()
7979

build/console/resources/html/redisAlert.html

-44
This file was deleted.

build/console/resources/html/monitorAlert.html build/goku-node/resources/html/currentAlert.html

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,28 @@
1414
</tr>
1515
<tr>
1616
<td style="line-height: 1.75em;">
17-
<h2>GoKu告警:节点自动重启失败,请及时重启节点。</h2>
17+
<h2>GoKu告警:$requestURL接口在$alertPeriod分钟内转发失败$alertCount次</h2>
1818
</td>
1919
</tr>
2020
<tr>
2121
<td>
22-
<p style="color:#333;font-size:14px;margin:15px 0 40px 0;">GoKu接口网关于 <b>$alertTime</b>
23-
检测到以下节点重启失败,详细日志内容请于 <b>./log/nodeMonitorLog</b> 文件查看。
22+
<p style="color:#333;font-size:14px;margin:15px 0 40px 0;">GoKu接口网关于 <b>$alertTime</b> 监控到<b>
23+
$requestURL </b>接口在 <b>$alertPeriod</b> 分钟内转发失败达到 <b>$alertCount</b> 次,详细告警内容请于
24+
<b>$alertLogPath</b> 文件夹查看。</p>
2425
</td>
2526
</tr>
2627
<tr>
2728
<td style="padding:40px 0 5px 0;line-height: 1.75em;border-top:1px solid #e5e5e5;">
28-
<h3>自动重启失败的节点列表</h3>
29+
<h3>接口基本信息</h3>
2930
</td>
3031
</tr>
3132
<tr>
3233
<td style="line-height: 1.75em; padding-bottom: 40px;">
33-
$nodeList
34+
<p>接口名称:$apiName</p>
35+
<p>apiID:$apiID</p>
36+
<p>请求路径:$requestURL</p>
37+
<p>转发路径:$targetServer</p>
38+
<p>映射路径:$proxyURL</p>
3439
</td>
3540
</tr>
3641
</tbody>

common/auto-form/auto.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import (
1111
"unsafe"
1212
)
1313

14+
//Values values
1415
type Values interface {
1516
Get(key string) (string, bool)
1617
}
1718

19+
//ValuesForm valuesForm
1820
type ValuesForm map[string][]string
1921

2022
// Get gets the first value associated with the given key.
@@ -41,6 +43,7 @@ type (
4143
ContextHandle interface {
4244
SetContext(ctx Values) error
4345
}
46+
//CheckOptHandler 判断是否有opt字段
4447
CheckOptHandler interface {
4548
IsOpt(key string) bool
4649
}
@@ -50,6 +53,7 @@ type (
5053
}
5154
)
5255

56+
//IsOpt 是否是opt字段
5357
func IsOpt(key string, c interface{}) bool {
5458
val := reflect.ValueOf(c).Elem()
5559
typ := val.Type()
@@ -67,8 +71,10 @@ func IsOpt(key string, c interface{}) bool {
6771
return false
6872
}
6973

74+
//ErrorNil error nil
7075
var ErrorNil = errors.New("target is nil")
71-
// SetContext 从url.Values中完成配置字段,context中不存在时,使用 default
76+
77+
// SetValues 从url.Values中完成配置字段,context中不存在时,使用 default
7278
// 字段格式 opt:"name,require" default:"default value" min:"min value" max:"max value"
7379
// require 为可选,表示该字段是否为必填
7480
func SetValues(values url.Values, c interface{}) error {

common/conf/conf.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// 读取配置信息
21
package conf
32

43
import (
@@ -13,27 +12,37 @@ var (
1312
lastFile = ""
1413
)
1514

15+
//Get get
1616
func Get(name string) (string, bool) {
1717
v, has := _Configure[name]
1818
return v, has
1919
}
20+
21+
//Set set
2022
func Set(name, value string) {
2123
_Configure[name] = value
2224
}
2325

26+
//Value value
2427
func Value(name string) string {
2528
return _Configure[name]
2629
}
30+
31+
//Reload reload
2732
func Reload() {
2833
ReadConfigure(lastFile)
2934
}
35+
36+
//MastValue mastValue
3037
func MastValue(name string, def string) string {
3138
v, h := _Configure[name]
3239
if h {
3340
return v
3441
}
3542
return def
3643
}
44+
45+
//ReadConfigure 读取配置
3746
func ReadConfigure(filepath string) error {
3847
file, err := os.Open(filepath)
3948
if err != nil {
@@ -53,14 +62,8 @@ func ReadConfigure(filepath string) error {
5362
return nil
5463
}
5564

56-
// 更新配置文件
65+
//Save 更新配置文件
5766
func Save() (bool, error) {
58-
//file, err := os.OpenFile(lastFile, os.O_CREATE|os.O_WRONLY, 0666)
59-
//if err != nil {
60-
// panic(err)
61-
//}
62-
//defer file.Close()
63-
6467
confStr, err := yaml.Marshal(_Configure)
6568
if err != nil {
6669
return false, err

common/database/conn.go

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package database
33
import (
44
"database/sql"
55
log "github.com/eolinker/goku-api-gateway/goku-log"
6+
// mysql包
67
_ "github.com/go-sql-driver/mysql"
78
)
89

@@ -14,6 +15,7 @@ var (
1415
defaultDB *sql.DB
1516
)
1617

18+
//InitConnection 初始化连接
1719
func InitConnection(config Config) error {
1820
db, e := getConnection(config)
1921
defaultDB = db
@@ -45,6 +47,7 @@ func getConnection(config Config) (*sql.DB, error) {
4547

4648
}
4749

50+
//GetConnection 获取连接
4851
func GetConnection() *sql.DB {
4952

5053
return defaultDB

common/endless/endless.go

+15-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ import (
2020
)
2121

2222
const (
23+
//PRE_SIGNAL pre signal
2324
PRE_SIGNAL = iota
25+
26+
//POST_SIGNAL post signal
2427
POST_SIGNAL
2528

29+
//STATE_INIT state init
2630
STATE_INIT
31+
//STATE_RUNNING state running
2732
STATE_RUNNING
33+
//STATE_SHUTTING_DOWN state shutting down
2834
STATE_SHUTTING_DOWN
35+
//STATE_TERMINATE state terminate
2936
STATE_TERMINATE
3037
)
3138

@@ -36,18 +43,22 @@ var (
3643
socketPtrOffsetMap map[string]uint
3744
runningServersForked bool
3845

39-
DefaultReadTimeOut time.Duration
40-
DefaultWriteTimeOut time.Duration
46+
//DefaultReadTimeOut 默认读超时时间
47+
DefaultReadTimeOut time.Duration
48+
//DefaultWriteTimeOut 默认写超时时间
49+
DefaultWriteTimeOut time.Duration
50+
//DefaultMaxHeaderBytes 默认请求头最大字节数
4151
DefaultMaxHeaderBytes int
42-
DefaultHammerTime time.Duration
52+
//DefaultHammerTime default hammer time
53+
DefaultHammerTime time.Duration
4354

4455
isChild bool
4556
socketOrder string
4657

4758
hookableSignals []os.Signal
4859
)
4960

50-
var isStop bool = true
61+
var isStop = true
5162

5263
func init() {
5364
runningServerReg = sync.RWMutex{}

common/general/general.go

+5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package general
22

3+
//InitFunc init func
34
type InitFunc func() error
45

56
var (
67
_initFunc []InitFunc
78
_laterFunc []InitFunc
89
)
910

11+
//RegeditInit 初始化注册
1012
func RegeditInit(fn InitFunc) {
1113

1214
_initFunc = append(_initFunc, fn)
1315
}
16+
17+
//General general
1418
func General() error {
1519
for _, fn := range _initFunc {
1620
if err := fn(); err != nil {
@@ -25,6 +29,7 @@ func General() error {
2529
return nil
2630
}
2731

32+
//RegeditLater regedit later
2833
func RegeditLater(fn InitFunc) {
2934
_laterFunc = append(_laterFunc, fn)
3035
}

common/redis-manager/factory.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package redis_manager
1+
package redismanager
22

33
import (
44
"fmt"
@@ -11,6 +11,7 @@ const (
1111
_PoolSize = 2000
1212
)
1313

14+
//Create 创建
1415
func Create(config RedisConfig) Redis {
1516

1617
switch config.GetMode() {

common/redis-manager/function.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package redis_manager
1+
package redismanager
22

33
//
44
//func GetKeys(r Redis, pattern string) ([]string, error) {

common/redis-manager/manager.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package redis_manager
1+
package redismanager
22

33
import (
44
"sync"
@@ -11,6 +11,7 @@ var (
1111
locker sync.RWMutex
1212
)
1313

14+
//InitRedisOfCluster 初始化集群redis
1415
func InitRedisOfCluster(rs map[string]RedisConfig) {
1516
locker.Lock()
1617
defer locker.Unlock()
@@ -27,6 +28,8 @@ func get(name string) (Redis, bool) {
2728

2829
return r, h
2930
}
31+
32+
//Get 获取redis
3033
func Get(name string) (Redis, bool) {
3134
r, has := get(name)
3235

common/redis-manager/proxy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package redis_manager
1+
package redismanager
22

33
import (
44
"github.com/go-redis/redis"

common/redis-manager/redis.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
package redis_manager
1+
package redismanager
22

33
import "github.com/go-redis/redis"
44

55
const (
6-
RedisModeCluster = "cluster"
7-
RedisModeStand = "stand"
6+
//RedisModeCluster cluster模式
7+
RedisModeCluster = "cluster"
8+
//RedisModeStand stand模式
9+
RedisModeStand = "stand"
810
)
911

12+
//Redis redis
1013
type Redis interface {
1114
redis.Cmdable
1215
GetConfig() RedisConfig
1316
//Foreach(fn func(client *localRedis.Client) error) error
1417
Nodes() []string
1518
}
1619

20+
//RedisConfig redis config
1721
type RedisConfig interface {
1822
GetMode() string
1923
GetAddrs() []string

0 commit comments

Comments
 (0)