Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into refactorDML
Browse files Browse the repository at this point in the history
  • Loading branch information
GMHDBJD authored Oct 25, 2021
2 parents 4fc1ee6 + 00ddc30 commit 2ebdb46
Show file tree
Hide file tree
Showing 6 changed files with 1,752 additions and 410 deletions.
96 changes: 92 additions & 4 deletions dm/master/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ func (s *Server) GetDocHTML(ctx echo.Context) error {
return ctx.HTML(http.StatusOK, html)
}

// DMAPIGetClusterMasterList get cluster master node list url is:(GET /api/v1/cluster/masters).
func (s *Server) DMAPIGetClusterMasterList(ctx echo.Context) error {
return nil
}

// DMAPIOfflineMasterNode offline master node url is: (DELETE /api/v1/cluster/masters/{master-name}).
func (s *Server) DMAPIOfflineMasterNode(ctx echo.Context, masterName string) error {
return nil
}

// DMAPIGetClusterWorkerList get cluster worker node list url is: (GET /api/v1/cluster/workers).
func (s *Server) DMAPIGetClusterWorkerList(ctx echo.Context) error {
return nil
}

// DMAPIOfflineWorkerNode offline worker node url is: (DELETE /api/v1/cluster/workers/{worker-name}).
func (s *Server) DMAPIOfflineWorkerNode(ctx echo.Context, workerName string) error {
return nil
}

// DMAPICreateSource url is:(POST /api/v1/sources).
func (s *Server) DMAPICreateSource(ctx echo.Context) error {
var createSourceReq openapi.Source
Expand All @@ -117,7 +137,8 @@ func (s *Server) DMAPICreateSource(ctx echo.Context) error {
}

// DMAPIGetSourceList url is:(GET /api/v1/sources).
func (s *Server) DMAPIGetSourceList(ctx echo.Context) error {
func (s *Server) DMAPIGetSourceList(ctx echo.Context, params openapi.DMAPIGetSourceListParams) error {
// todo: support params
sourceMap := s.scheduler.GetSourceCfgs()
sourceList := []openapi.Source{}
for key := range sourceMap {
Expand All @@ -128,7 +149,8 @@ func (s *Server) DMAPIGetSourceList(ctx echo.Context) error {
}

// DMAPIDeleteSource url is:(DELETE /api/v1/sources).
func (s *Server) DMAPIDeleteSource(ctx echo.Context, sourceName string) error {
func (s *Server) DMAPIDeleteSource(ctx echo.Context, sourceName string, params openapi.DMAPIDeleteSourceParams) error {
// todo: support params
if err := s.scheduler.RemoveSourceCfg(sourceName); err != nil {
return err
}
Expand Down Expand Up @@ -177,7 +199,27 @@ func (s *Server) DMAPIStopRelay(ctx echo.Context, sourceName string) error {
return s.scheduler.StopRelay(sourceName, req.WorkerNameList)
}

// DMAPIGetSourceStatus url is:(GET /api/v1/sources/{source-id}/status).
// DMAPIPauseRelay pause relay log function for the data source url is: (POST /api/v1/sources/{source-name}/pause-relay).
func (s *Server) DMAPIPauseRelay(ctx echo.Context, sourceName string) error {
return nil
}

// DMAPIResumeRelay resume relay log function for the data source url is: (POST /api/v1/sources/{source-name}/resume-relay).
func (s *Server) DMAPIResumeRelay(ctx echo.Context, sourceName string) error {
return nil
}

// DMAPIGetSourceSchemaList get source schema list url is: (GET /api/v1/sources/{source-name}/schemas).
func (s *Server) DMAPIGetSourceSchemaList(ctx echo.Context, sourceName string) error {
return nil
}

// DMAPIGetSourceTableList get source table list url is: (GET /api/v1/sources/{source-name}/schemas/{schema-name}).
func (s *Server) DMAPIGetSourceTableList(ctx echo.Context, sourceName string, schemaName string) error {
return nil
}

// DMAPIGetSourceStatus url is: (GET /api/v1/sources/{source-id}/status).
func (s *Server) DMAPIGetSourceStatus(ctx echo.Context, sourceName string) error {
sourceCfg := s.scheduler.GetSourceCfgByID(sourceName)
if sourceCfg == nil {
Expand Down Expand Up @@ -217,6 +259,11 @@ func (s *Server) DMAPIGetSourceStatus(ctx echo.Context, sourceName string) error
return ctx.JSON(http.StatusOK, resp)
}

// DMAPITransferSource transfer source another free worker url is: (POST /api/v1/sources/{source-name}/transfer).
func (s *Server) DMAPITransferSource(ctx echo.Context, sourceName string) error {
return nil
}

// DMAPIStartTask url is:(POST /api/v1/tasks).
func (s *Server) DMAPIStartTask(ctx echo.Context) error {
var req openapi.CreateTaskRequest
Expand Down Expand Up @@ -330,7 +377,8 @@ func (s *Server) DMAPIGetTaskList(ctx echo.Context) error {
}

// DMAPIGetTaskStatus url is:(GET /api/v1/tasks/{task-name}/status).
func (s *Server) DMAPIGetTaskStatus(ctx echo.Context, taskName string) error {
func (s *Server) DMAPIGetTaskStatus(ctx echo.Context, taskName string, params openapi.DMAPIGetTaskStatusParams) error {
// todo support params
// 1. get task source list from scheduler
sourceList := s.getTaskResources(taskName)
if len(sourceList) == 0 {
Expand Down Expand Up @@ -408,6 +456,46 @@ func (s *Server) DMAPIGetTaskStatus(ctx echo.Context, taskName string) error {
return ctx.JSON(http.StatusOK, resp)
}

// DMAPPauseTask pause task url is: (POST /api/v1/tasks/{task-name}/pause).
func (s *Server) DMAPPauseTask(ctx echo.Context, taskName string) error {
return nil
}

// DMAPIResumeTask resume task url is: (POST /api/v1/tasks/{task-name}/resume).
func (s *Server) DMAPIResumeTask(ctx echo.Context, taskName string) error {
return nil
}

// DMAPIGetTaskSourceSchemaList get task source schema list url is: (GET /api/v1/tasks/{task-name}/sources/{source-name}/schemas).
func (s *Server) DMAPIGetTaskSourceSchemaList(ctx echo.Context, taskName string, sourceName string) error {
return nil
}

// DMAPIGetTaskSchemaStructure get task source schema structure url is: (GET /api/v1/tasks/{task-name}/sources/{source-name}/schemas/{schema-name}).
func (s *Server) DMAPIGetTaskSchemaStructure(ctx echo.Context, taskName string, sourceName string, schemaName string) error {
return nil
}

// DMAPIGetTaskSourceTableList get task source table list url is: (GET /api/v1/tasks/{task-name}/sources/{source-name}/schemas/{schema-name}).
func (s *Server) DMAPIGetTaskSourceTableList(ctx echo.Context, taskName string, sourceName string, schemaName string) error {
return nil
}

// DMAPIDeleteTaskSourceTableStructure delete task source table structure url is: (DELETE /api/v1/tasks/{task-name}/sources/{source-name}/schemas/{schema-name}/{table-name}).
func (s *Server) DMAPIDeleteTaskSourceTableStructure(ctx echo.Context, taskName string, sourceName string, schemaName string, tableName string) error {
return nil
}

// DMAPIGetTaskSourceTableStructure get task source table structure url is: (GET /api/v1/tasks/{task-name}/sources/{source-name}/schemas/{schema-name}/{table-name}).
func (s *Server) DMAPIGetTaskSourceTableStructure(ctx echo.Context, taskName string, sourceName string, schemaName string, tableName string) error {
return nil
}

// DMAPIOperateTaskSourceTableStructure operate task source table structure url is: (PUT /api/v1/tasks/{task-name}/sources/{source-name}/schemas/{schema-name}/{table-name}).
func (s *Server) DMAPIOperateTaskSourceTableStructure(ctx echo.Context, taskName string, sourceName string, schemaName string, tableName string) error {
return nil
}

func terrorHTTPErrorHandler(err error, c echo.Context) {
var code int
var msg string
Expand Down
4 changes: 2 additions & 2 deletions dm/master/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (t *openAPISuite) TestRelayAPI(c *check.C) {
// start relay
startRelayURL := fmt.Sprintf("%s/%s/start-relay", baseURL, source1.SourceName)
openAPIStartRelayReq := openapi.StartRelayRequest{WorkerNameList: []string{workerName1}}
result4 := testutil.NewRequest().Patch(startRelayURL).WithJsonBody(openAPIStartRelayReq).Go(t.testT, s.echo)
result4 := testutil.NewRequest().Post(startRelayURL).WithJsonBody(openAPIStartRelayReq).Go(t.testT, s.echo)
// check http status code
c.Assert(result4.Code(), check.Equals, http.StatusOK)
relayWorkers, err := s.scheduler.GetRelayWorkers(source1Name)
Expand Down Expand Up @@ -312,7 +312,7 @@ func (t *openAPISuite) TestRelayAPI(c *check.C) {
// test stop relay
stopRelayURL := fmt.Sprintf("%s/%s/stop-relay", baseURL, source1.SourceName)
stopRelayReq := openapi.StopRelayRequest{WorkerNameList: []string{workerName1}}
result7 := testutil.NewRequest().Patch(stopRelayURL).WithJsonBody(stopRelayReq).Go(t.testT, s.echo)
result7 := testutil.NewRequest().Post(stopRelayURL).WithJsonBody(stopRelayReq).Go(t.testT, s.echo)
c.Assert(result7.Code(), check.Equals, http.StatusOK)
relayWorkers, err = s.scheduler.GetRelayWorkers(source1Name)
c.Assert(err, check.IsNil)
Expand Down
Loading

0 comments on commit 2ebdb46

Please sign in to comment.