Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
vm-001 committed Mar 7, 2025
1 parent a484681 commit b6579ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions db/query/querys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package query
type EndpointQuery struct {
Query

Enabled *bool
WorkspaceId *string
}

func (q *EndpointQuery) WhereMap() map[string]interface{} {
maps := make(map[string]interface{})
if q.Enabled != nil {
maps["enabled"] = *q.Enabled
}
if q.WorkspaceId != nil {
maps["ws_id"] = *q.WorkspaceId
}
Expand Down
5 changes: 4 additions & 1 deletion dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,15 @@ func listWorkspaceEndpoints(ctx context.Context, db *db.DB, wid string) ([]*enti
endpoints, err := mcache.Load(ctx, cacheKey, nil, func(ctx context.Context, id string) (*[]*entities.Endpoint, error) {
var q query.EndpointQuery
q.WorkspaceId = &wid
//q.Enabled = true
q.Enabled = utils.Pointer(true)
endpoints, err := db.Endpoints.List(ctx, &q)
if err != nil {
return nil, err
}

Check warning on line 194 in dispatcher/dispatcher.go

View check run for this annotation

Codecov / codecov/patch

dispatcher/dispatcher.go#L193-L194

Added lines #L193 - L194 were not covered by tests
return &endpoints, nil
}, wid)
if err != nil {
return nil, err
}

Check warning on line 199 in dispatcher/dispatcher.go

View check run for this annotation

Codecov / codecov/patch

dispatcher/dispatcher.go#L198-L199

Added lines #L198 - L199 were not covered by tests
return *endpoints, err
}
8 changes: 3 additions & 5 deletions proxy/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ type Gateway struct {
log *zap.SugaredLogger
s *http.Server

router *router.Router // TODO: happens-before
routerVersion string
routerLastBuild time.Time
router *router.Router // TODO: happens-before
routerVersion string

db *db.DB

Expand Down Expand Up @@ -109,7 +108,7 @@ func NewGateway(cfg *config.ProxyConfig,
}

func (gw *Gateway) buildRouter(version string) {
gw.log.Debugf("creating router")
gw.log.Debugf("[proxy] creating router")

sources, err := gw.db.Sources.List(context.TODO(), &query.SourceQuery{})
if err != nil {
Expand All @@ -128,7 +127,6 @@ func (gw *Gateway) buildRouter(version string) {
}
gw.router = router.NewRouter(routes)
gw.routerVersion = version
gw.routerLastBuild = time.Now()
}

func (gw *Gateway) Handle(w http.ResponseWriter, r *http.Request) {
Expand Down
3 changes: 3 additions & 0 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,5 +431,8 @@ func listEndpointPlugins(ctx context.Context, db *db.DB, endpointId string) ([]*
}
return &plugins, nil
}, endpointId)
if err != nil {
return nil, err
}

Check warning on line 436 in worker/worker.go

View check run for this annotation

Codecov / codecov/patch

worker/worker.go#L435-L436

Added lines #L435 - L436 were not covered by tests
return *plugins, err
}

0 comments on commit b6579ac

Please sign in to comment.