Skip to content

Commit

Permalink
chore: improve doc lint (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Oct 31, 2022
1 parent a5edfba commit dc0f10b
Show file tree
Hide file tree
Showing 60 changed files with 659 additions and 713 deletions.
51 changes: 2 additions & 49 deletions .github/markdown_lint_config.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,5 @@
{
"MD001": true,
"MD002": false,
"MD003": false,
"MD004": false,
"MD005": false,
"MD006": false,
"MD007": false,
"MD008": false,
"MD009": false,
"MD010": false,
"MD011": false,
"MD012": false,
"MD013": false,
"MD014": false,
"MD015": false,
"MD016": false,
"MD017": false,
"MD018": false,
"MD019": false,
"MD020": false,
"MD021": false,
"MD022": false,
"MD023": false,
"MD024": false,
"MD025": false,
"MD026": false,
"MD027": false,
"MD028": false,
"MD029": false,
"MD030": false,
"MD031": true,
"MD032": false,
"default": true,
"MD033": false,
"MD034": false,
"MD035": false,
"MD036": false,
"MD037": true,
"MD038": true,
"MD039": false,
"MD040": false,
"MD041": false,
"MD042": false,
"MD043": false,
"MD044": false,
"MD045": false,
"MD046": false,
"MD047": false,
"MD048": false,
"MD049": false,
"MD050": false
"MD013": false
}
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Run markdown linter
uses: nosborn/github-action-markdown-cli@v3.2.0
with:
files: .
files: website/docs,README.md,pkg
config_file: ".github/markdown_lint_config.json"

docs-build-and-deploy:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ lintd:
docker run --rm -v "$(shell pwd)/:/go/src/github.com/douyu/jupiter" --workdir /go/src/github.com/douyu/jupiter -it golangci/golangci-lint:v1.42.1 golangci-lint run -v
lintl:
golangci-lint run -v

lintmd:
markdownlint -c .github/markdown_lint_config.json website/docs README.md pkg
2 changes: 1 addition & 1 deletion pkg/core/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"github.com/douyu/jupiter/pkg/conf"
"github.com/douyu/jupiter/pkg/core/component"
"github.com/douyu/jupiter/pkg/core/ecode"
"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/hooks"
"github.com/douyu/jupiter/pkg/core/signals"
"github.com/douyu/jupiter/pkg/executor"
"github.com/douyu/jupiter/pkg/flag"
"github.com/douyu/jupiter/pkg/registry"
"github.com/douyu/jupiter/pkg/server"
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

"github.com/BurntSushi/toml"
"github.com/douyu/jupiter/pkg/conf"
"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/executor/xxl"
"github.com/douyu/jupiter/pkg/core/hooks"
"github.com/douyu/jupiter/pkg/executor"
"github.com/douyu/jupiter/pkg/executor/xxl"
"github.com/douyu/jupiter/pkg/server"
"github.com/douyu/jupiter/pkg/server/xgrpc"
. "github.com/smartystreets/goconvey/convey"
Expand Down
91 changes: 0 additions & 91 deletions pkg/core/executor/xxl/Readme.md

This file was deleted.

File renamed without changes.
91 changes: 91 additions & 0 deletions pkg/executor/xxl/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# jupiter接入xxl-job分布式调度中心模块

example: /example/xxl-job
用法如下:

1. 增加配置:
以下是配置说明

```toml
[xxl]
[xxl.job]
[xxl.job.admin]
address = "http://127.0.0.1:8080/xxl-job-admin" # 注意换成XXL调度中心对应环境的域名
access_token = "jupiter-token" # 注册xxl-job执行器需要的token信息
appname = "jupiter-xxl-job-demo" # 启动执行器的名称
port = "59000" # 启动执行器的服务端口
log_dir = "./" # 执行器产生的日志文件目录
# 以下的配置建议使用默认
#host = "" # 启动执行器的主机。默认通过ip.get注册。确保xxl-job能调度该地址
debug = true # 是否开启debug模式
switch = true # 执行器的总开关
registry_group = "EXECUTOR" # 执行器组
#timeout = 2000 # 接口超时时间
```

1. 示例用法:

```go
func main() {
eng := NewEngine()
eng.RegisterHooks(hooks.Stage_AfterStop, func() {
fmt.Println("exit jupiter app ...")
})
if err := eng.Run(); err != nil {
log.Fatal(err)
}
}

type Engine struct {
jupiter.Application
}

func NewEngine() *Engine {
eng := &Engine{}
if err := eng.Startup(
xgo.ParallelWithError(
eng.startXxlJob,
),
); err != nil {
xlog.Panic("startup engine", xlog.Any("err", err))
}
return eng
}

func (eng *Engine) startXxlJob() error {
executor := xxl.StdNewExecutor()
// 注册定时任务
executor.RegXJob(
NewTest(),
NewTest2(),
)
eng.Executor(executor)
return nil
}


// =======以下为示例任务test.go=========
type Test struct{}

func NewTest() *Test {
return &Test{}
}

// 任务名称
func (t *Test) GetJobName() string {
return "test"
}

// xxl-job 分布式调度任务执行函数
func (t *Test) Run(ctx context.Context, param *executor.RunReq) (msg string, err error) {
//使用xxl-logger日志即可在xxl-job平台上看到日志
logger.Info(param.LogID, "start run...")
logger.Info(param.LogID, fmt.Sprintf("job param is: %s", param.ExecutorParams))
fmt.Println("test job has been executed")
return "success", nil
}
```

```txt
注:调度器中的停止某项任务是停止调度接下来的任务。如果用中途中止某个正在进行中的定时任务,请使用ctx.Done()
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"strings"
"time"

"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/executor/xxl/logger"
"github.com/douyu/jupiter/pkg/executor"
"github.com/douyu/jupiter/pkg/executor/xxl/logger"
"github.com/douyu/jupiter/pkg/util/xdebug"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

"github.com/BurntSushi/toml"
"github.com/douyu/jupiter/pkg/conf"
"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/executor/xxl/constants"
"github.com/douyu/jupiter/pkg/executor"
"github.com/douyu/jupiter/pkg/executor/xxl/constants"
"github.com/go-basic/ipv4"
"github.com/stretchr/testify/assert"
)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"github.com/douyu/jupiter/pkg/core/executor/xxl/constants"
"github.com/douyu/jupiter/pkg/executor/xxl/constants"
)

type LogIDKey string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/douyu/jupiter/pkg/conf"
"github.com/douyu/jupiter/pkg/core/executor/xxl/constants"
"github.com/douyu/jupiter/pkg/executor/xxl/constants"
"github.com/douyu/jupiter/pkg/xlog"
"github.com/go-basic/ipv4"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/BurntSushi/toml"
"github.com/douyu/jupiter/pkg/conf"
"github.com/douyu/jupiter/pkg/core/executor/xxl/constants"
"github.com/douyu/jupiter/pkg/executor/xxl/constants"
"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/core/executor/xxl/task.go → pkg/executor/xxl/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"sync/atomic"
"time"

"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/executor/xxl/logger"
"github.com/douyu/jupiter/pkg/core/metric"
"github.com/douyu/jupiter/pkg/executor"
"github.com/douyu/jupiter/pkg/executor/xxl/logger"
)

// 任务执行函数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/executor"
)

// 测试XJob
Expand Down
4 changes: 2 additions & 2 deletions pkg/core/executor/xxl/util.go → pkg/executor/xxl/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"
"strconv"

"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/core/executor/xxl/logger"
"github.com/douyu/jupiter/pkg/executor"
"github.com/douyu/jupiter/pkg/executor/xxl/logger"
)

//int64 to str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

"github.com/douyu/jupiter/pkg/core/executor"
"github.com/douyu/jupiter/pkg/executor"
)

func Test_Int64ToStr(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/xlog/rotate/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## rotate
# rotate

rotate用于对日志文件进行切分。rotate fork自[lumberjack](https://github.com/sevenNt/lumberjack)。在lumberjack对文件夹权限、日志格式、对外API等做了稍许调整。
2 changes: 2 additions & 0 deletions website/docs/join/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# JOIN US

## 加入开发群

### 钉钉群
Expand Down
2 changes: 2 additions & 0 deletions website/docs/juno/1.2install_docker.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Docker

## 1.2 docker安装

### 1.2.1 安装
Expand Down
2 changes: 1 addition & 1 deletion website/docs/juno/1.3install_binary.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 1.3 二进制安装
# 1.3 二进制安装

```bash
git clone https://github.com/douyu/juno-install.git
Expand Down
Loading

0 comments on commit dc0f10b

Please sign in to comment.