Skip to content

Commit

Permalink
Merge pull request #1 from jasonjoo2010/integrate-v1.0
Browse files Browse the repository at this point in the history
Integrate with v1.0.0
  • Loading branch information
jasonjoo2010 authored May 16, 2021
2 parents 3ea003b + 00c8b88 commit 4836368
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 124 deletions.
6 changes: 3 additions & 3 deletions controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/jasonjoo2010/goschedule-console/controller"
"github.com/jasonjoo2010/goschedule-console/types"
"github.com/jasonjoo2010/goschedule-console/utils"
"github.com/jasonjoo2010/goschedule/core/definition"
"github.com/jasonjoo2010/goschedule/definition"
)

const (
Expand Down Expand Up @@ -169,7 +169,7 @@ func importSaveHandler(c *gin.Context) {
tasksSuccess := 0
store := app.Instance().Store
for _, strategy := range strategies {
s, _ := store.GetStrategy(strategy.Id)
s, _ := store.GetStrategy(strategy.ID)
if s != nil {
continue
}
Expand All @@ -180,7 +180,7 @@ func importSaveHandler(c *gin.Context) {
strategiesSuccess++
}
for _, task := range tasks {
s, _ := store.GetTask(task.Id)
s, _ := store.GetTask(task.ID)
if s != nil {
continue
}
Expand Down
14 changes: 7 additions & 7 deletions controller/strategy/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/jasonjoo2010/goschedule-console/controller"
"github.com/jasonjoo2010/goschedule-console/types"
"github.com/jasonjoo2010/goschedule-console/utils"
"github.com/jasonjoo2010/goschedule/core/definition"
"github.com/jasonjoo2010/goschedule/definition"
storepkg "github.com/jasonjoo2010/goschedule/store"
"github.com/robfig/cron"
)
Expand Down Expand Up @@ -142,12 +142,12 @@ func checkStrategy(resp types.JsonResponse, c *gin.Context) (strategy *definitio
}
}
strategyKind := utils.ToStrategyKind(kind)
if strategyKind == definition.UnknowKind {
if strategyKind == definition.UnknownKind {
resp.Err(4, "Kind is illegal")
return
}
strategy = &definition.Strategy{
Id: id,
ID: id,
MaxOnSingleScheduler: limit,
Total: total,
Kind: strategyKind,
Expand All @@ -158,12 +158,12 @@ func checkStrategy(resp types.JsonResponse, c *gin.Context) (strategy *definitio
CronEnd: cronEnd,
}
targets := strings.Split(target, ",")
strategy.IpList = make([]string, 0, len(targets))
strategy.IPList = make([]string, 0, len(targets))
for _, t := range targets {
if len(t) < 1 {
continue
}
strategy.IpList = append(strategy.IpList, t)
strategy.IPList = append(strategy.IPList, t)
}
result = true
return
Expand All @@ -174,7 +174,7 @@ func createHandler(c *gin.Context) {
defer c.JSON(200, resp)
store := app.Instance().Store
if strategy, ok := checkStrategy(resp, c); ok {
s, err := store.GetStrategy(strategy.Id)
s, err := store.GetStrategy(strategy.ID)
if err != nil && err != storepkg.NotExist {
resp.Err(2, "Fail to retrieve data from store")
return
Expand All @@ -192,7 +192,7 @@ func saveHandler(c *gin.Context) {
defer c.JSON(200, resp)
store := app.Instance().Store
if strategy, ok := checkStrategy(resp, c); ok {
s, err := store.GetStrategy(strategy.Id)
s, err := store.GetStrategy(strategy.ID)
if err != nil && err != storepkg.NotExist {
resp.Err(2, "Fail to retrieve data from store")
return
Expand Down
22 changes: 11 additions & 11 deletions controller/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/jasonjoo2010/goschedule-console/controller"
"github.com/jasonjoo2010/goschedule-console/types"
"github.com/jasonjoo2010/goschedule-console/utils"
"github.com/jasonjoo2010/goschedule/core/definition"
"github.com/jasonjoo2010/goschedule/definition"
storepkg "github.com/jasonjoo2010/goschedule/store"
)

Expand All @@ -39,7 +39,7 @@ func Init(engine *gin.Engine) {
func indexHandler(c *gin.Context) {
list, _ := app.Instance().Store.GetTasks()
sort.Slice(list, func(i, j int) bool {
return list[i].Id < list[j].Id
return list[i].ID < list[j].ID
})
c.HTML(http.StatusOK, "task/index.html", controller.DataWithSession(gin.H{
"tasks": list,
Expand Down Expand Up @@ -81,14 +81,14 @@ func infoHandler(c *gin.Context) {
infoMap := make(map[string]info)
strategyMap := make(map[string]*definition.Strategy)
for _, strategy := range strategies {
if strategy.Kind != definition.TaskKind || strategy.Bind != task.Id {
if strategy.Kind != definition.TaskKind || strategy.Bind != task.ID {
continue
}
strategyMap[strategy.Id] = strategy
runtimes, _ := s.GetTaskRuntimes(strategy.Id, task.Id)
assignments, _ := s.GetTaskAssignments(strategy.Id, task.Id)
version, _ := s.GetTaskItemsConfigVersion(strategy.Id, task.Id)
infoMap[strategy.Id] = info{
strategyMap[strategy.ID] = strategy
runtimes, _ := s.GetTaskRuntimes(strategy.ID, task.ID)
assignments, _ := s.GetTaskAssignments(strategy.ID, task.ID)
version, _ := s.GetTaskItemsConfigVersion(strategy.ID, task.ID)
infoMap[strategy.ID] = info{
Runtimes: runtimes,
Assignments: assignments,
ConfigVersion: version,
Expand Down Expand Up @@ -185,7 +185,7 @@ func checkTask(resp types.JsonResponse, c *gin.Context) (task *definition.Task,
taskModel = definition.Stream
}
task = &definition.Task{
Id: id,
ID: id,
Model: taskModel,
Bind: bind,
Parameter: parameter,
Expand All @@ -208,7 +208,7 @@ func createHandler(c *gin.Context) {
defer c.JSON(200, resp)
store := app.Instance().Store
if task, ok := checkTask(resp, c); ok {
s, err := store.GetTask(task.Id)
s, err := store.GetTask(task.ID)
if err != nil && err != storepkg.NotExist {
resp.Err(2, "Fail to retrieve data from store: "+err.Error())
return
Expand All @@ -226,7 +226,7 @@ func saveHandler(c *gin.Context) {
defer c.JSON(200, resp)
store := app.Instance().Store
if task, ok := checkTask(resp, c); ok {
s, err := store.GetTask(task.Id)
s, err := store.GetTask(task.ID)
if err != nil && err != storepkg.NotExist {
resp.Err(2, "Fail to retrieve data from store: "+err.Error())
return
Expand Down
21 changes: 12 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ go 1.14

require (
github.com/gin-gonic/gin v1.6.3
github.com/jasonjoo2010/goschedule v0.1.2
github.com/jasonjoo2010/goschedule/store/redis v0.1.2
github.com/jasonjoo2010/goschedule/store/zookeeper v0.1.2
github.com/jasonjoo2010/goschedule/store/database v0.1.2
github.com/jasonjoo2010/goschedule/store/etcdv2 v0.1.2
github.com/jasonjoo2010/goschedule/store/etcdv3 v0.1.2
github.com/go-sql-driver/mysql v1.5.0
github.com/jasonjoo2010/goschedule v1.0.0
github.com/jasonjoo2010/goschedule/store/database v1.0.0
github.com/jasonjoo2010/goschedule/store/etcdv2 v1.0.0
github.com/jasonjoo2010/goschedule/store/etcdv3 v1.0.0
github.com/jasonjoo2010/goschedule/store/redis v1.0.0
github.com/jasonjoo2010/goschedule/store/zookeeper v1.0.0
github.com/robfig/cron v1.2.0
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.5.1 // test
github.com/stretchr/testify v1.7.0 // test
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
github.com/go-sql-driver/mysql v1.5.0
)

replace (
google.golang.org/grpc => google.golang.org/grpc v1.26.0
)
Loading

0 comments on commit 4836368

Please sign in to comment.