Skip to content

Commit 77b9eda

Browse files
committed
Add feature flag for graph exploration.
1 parent 556c396 commit 77b9eda

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

api/routes.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ func addRoutes(r *gin.Engine, conf Configuration, uc usecases.Usecases, auth uti
118118
router.POST("/ingestion/:object_type/batch", timeoutMiddleware(conf.BatchTimeout), handlePostCsvIngestion(uc))
119119
router.GET("/ingestion/:object_type/upload-logs", tom, handleListUploadLogs(uc))
120120

121-
router.GET("/graph/relations", tom, handleListGraphRelations(uc))
122-
router.POST("/graph/relations", tom, handleCreateGraphRelation(uc))
123-
router.DELETE("/graph/relations/:relation_id", tom, handleDeleteGraphRelation(uc))
121+
infra.RouteWithFeatureFlag(router, infra.GRAPH_EXPLORATION_FEATURE_FLAG, func(sub gin.IRoutes) {
122+
sub.GET("/graph/relations", tom, handleListGraphRelations(uc))
123+
sub.POST("/graph/relations", tom, handleCreateGraphRelation(uc))
124+
sub.DELETE("/graph/relations/:relation_id", tom, handleDeleteGraphRelation(uc))
124125

125-
router.GET("/graph/:node_type/:node_id", tom, handleGraphWalk(uc))
126+
sub.GET("/graph/:node_type/:node_id", tom, handleGraphWalk(uc))
127+
})
126128

127129
router.GET("/client_data/:object_type/:object_id", tom, handleGetIngestedObject(uc))
128130
router.GET("/client_data/:object_type/:object_id/annotations", tom, handleListEntityAnnotations(uc))

infra/feature_flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type featureFlag string
1616
const (
1717
TEST_UNUSED_FEATURE_FLAG featureFlag = "TEST_UNUSED_FEATURE_FLAG"
1818
BATCH_EXECUTION_V2_FEATURE_FLAG featureFlag = "BATCH_EXECUTION_V2"
19+
GRAPH_EXPLORATION_FEATURE_FLAG featureFlag = "GRAPH_EXPLORATION"
1920
)
2021

2122
func HasGlobalFeatureFlag(flag featureFlag) bool {

usecases/worker_jobs/graph_build_job.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/google/uuid"
1212
"github.com/riverqueue/river"
1313

14+
"github.com/checkmarble/marble-backend/infra"
1415
"github.com/checkmarble/marble-backend/models"
1516
"github.com/checkmarble/marble-backend/repositories"
1617
"github.com/checkmarble/marble-backend/usecases/executor_factory"
@@ -180,6 +181,10 @@ func (w *GraphBuildWorker) Timeout(job *river.Job[models.GraphBuildArgs]) time.D
180181
func (w *GraphBuildWorker) Work(ctx context.Context, job *river.Job[models.GraphBuildArgs]) error {
181182
logger := utils.LoggerFromContext(ctx)
182183

184+
if !infra.HasFeatureFlag(infra.GRAPH_EXPLORATION_FEATURE_FLAG, job.Args.OrgId) {
185+
return nil
186+
}
187+
183188
// Prevent herd effect
184189
if err := AddStrideDelay(job, w.interval); err != nil {
185190
return err

0 commit comments

Comments
 (0)