Skip to content

Commit

Permalink
[bugfix] Fix missing query routes and DB path parsing in goQuery API
Browse files Browse the repository at this point in the history
  • Loading branch information
fako1024 committed Aug 14, 2024
1 parent 552489b commit 3a5dff4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ go.work.sum
.db/
tmp/
bin/
goProbe
goQuery
gpctl
global-query
5 changes: 2 additions & 3 deletions cmd/goProbe/goProbe.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
openAPIfile := flags.CmdLine.OpenAPISpecOutfile
if openAPIfile != "" {
// skeleton server just for route registration
err := server.GenerateSpec(context.Background(), openAPIfile, gpserver.New("127.0.0.1:8145", nil, nil))
err := server.GenerateSpec(context.Background(), openAPIfile, gpserver.New("127.0.0.1:8145", config.DB.Path, nil, nil))
if err != nil {
logger.Fatal(err)
}
Expand Down Expand Up @@ -150,8 +150,7 @@ func main() {
// apiOptions = append(apiOptions, api.WithKeys(config.API.Keys))
// }

apiServer = gpserver.New(config.API.Addr, captureManager, configMonitor, apiOptions...)
apiServer.SetDBPath(config.DB.Path)
apiServer = gpserver.New(config.API.Addr, config.DB.Path, captureManager, configMonitor, apiOptions...)

// serve API
go func() {
Expand Down
11 changes: 2 additions & 9 deletions pkg/api/goprobe/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/els0r/goProbe/pkg/api"
"github.com/els0r/goProbe/pkg/api/server"
"github.com/els0r/goProbe/pkg/capture"
"github.com/els0r/goProbe/pkg/defaults"
"github.com/els0r/goProbe/pkg/goDB/engine"
"github.com/els0r/goProbe/pkg/version"
)
Expand All @@ -24,16 +23,10 @@ type Server struct {
*server.DefaultServer
}

// SetDBPath sets the path to the database directory
func (server *Server) SetDBPath(path string) *Server {
server.dbPath = path
return server
}

// New creates a new goprobe API server
func New(addr string, captureManager *capture.Manager, configMonitor *config.Monitor, opts ...server.Option) *Server {
func New(addr, dbPath string, captureManager *capture.Manager, configMonitor *config.Monitor, opts ...server.Option) *Server {
server := &Server{
dbPath: defaults.DBPath,
dbPath: dbPath,
captureManager: captureManager,
configMonitor: configMonitor,
DefaultServer: server.NewDefault(config.ServiceName, addr, opts...),
Expand Down
13 changes: 13 additions & 0 deletions pkg/api/query_api_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ var queryTags = []string{"Query"}

// RegisterQueryAPI registers all query related endpoints
func RegisterQueryAPI(a huma.API, caller string, querier query.Runner, middlewares huma.Middlewares) {
// query running
huma.Register(a,
huma.Operation{
OperationID: "query-post-run",
Method: http.MethodPost,
Path: QueryRoute,
Summary: "Run query",
Description: "Runs a query based on the parameters provided in the body",
Middlewares: middlewares,
Tags: queryTags,
},
getBodyQueryRunnerHandler(caller, querier),
)
// validation
huma.Register(a,
huma.Operation{
Expand Down

0 comments on commit 3a5dff4

Please sign in to comment.