Skip to content

Commit

Permalink
feat: refactor fdl
Browse files Browse the repository at this point in the history
  • Loading branch information
mrh997 committed Dec 23, 2024
1 parent 97ad3cb commit 0037ccb
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 276 deletions.
3 changes: 2 additions & 1 deletion devops/internal/apihandler/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/cloudwego/eino-ext/devops/internal/service"
"github.com/cloudwego/eino-ext/devops/internal/utils/log"
"github.com/cloudwego/eino-ext/devops/internal/utils/safego"
devmodel "github.com/cloudwego/eino-ext/devops/model"
)

// GetCanvasInfo use graph name to get canvas info
Expand All @@ -35,7 +36,7 @@ func GetCanvasInfo(res http.ResponseWriter, req *http.Request) {
graphID string
ok bool
err error
canvasInfo model.CanvasInfo
canvasInfo devmodel.CanvasInfo
)

graphID = getPathParam(req, "graph_id")
Expand Down
12 changes: 9 additions & 3 deletions devops/internal/apihandler/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/cloudwego/eino-ext/devops/internal/mock"
"github.com/cloudwego/eino-ext/devops/internal/model"
"github.com/cloudwego/eino-ext/devops/internal/service"
devmodel "github.com/cloudwego/eino-ext/devops/model"
)

type debugTestSuite struct {
Expand Down Expand Up @@ -78,9 +79,14 @@ func (d *debugTestSuite) Test_GetCanvasInfo() {
mockey.PatchConvey("", d.t, func() {
mockGraphID := "mock_graph"
mockey.Mock(getPathParam).Return(mockGraphID).Build()
d.mockContainerSVC.EXPECT().GetCanvas(mockGraphID).Return(model.CanvasInfo{}, false).Times(1)
d.mockContainerSVC.EXPECT().CreateCanvas(mockGraphID).Return(model.CanvasInfo{
Name: "mock_canvas",

d.mockContainerSVC.EXPECT().GetCanvas(mockGraphID).Return(devmodel.CanvasInfo{
GraphSchema: &devmodel.GraphSchema{},
}, false).Times(1)
d.mockContainerSVC.EXPECT().CreateCanvas(mockGraphID).Return(devmodel.CanvasInfo{
GraphSchema: &devmodel.GraphSchema{
Name: "mock_canvas",
},
}, nil).Times(1)

req, err := http.NewRequest(http.MethodGet, "", nil)
Expand Down
1 change: 1 addition & 0 deletions devops/internal/apihandler/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func recoverMiddleware(next http.Handler) http.Handler {
next.ServeHTTP(w, r)
})
}

func corsMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
method := r.Method
Expand Down
6 changes: 4 additions & 2 deletions devops/internal/apihandler/types/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
package types

import (
"github.com/cloudwego/eino-ext/devops/internal/model"
"encoding/json"

"github.com/cloudwego/eino-ext/devops/internal/model"
devmodel "github.com/cloudwego/eino-ext/devops/model"
)

type GetCanvasInfoResponse struct {
CanvasInfo model.CanvasInfo `json:"canvas_info,omitempty"`
CanvasInfo devmodel.CanvasInfo `json:"canvas_info,omitempty"`
}

type CreateDebugThreadResponse struct {
Expand Down
11 changes: 6 additions & 5 deletions devops/internal/mock/container_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 0 additions & 88 deletions devops/internal/model/canvas.go

This file was deleted.

Loading

0 comments on commit 0037ccb

Please sign in to comment.