Skip to content

Commit

Permalink
api/v1/routes: setup orchestrator API routes
Browse files Browse the repository at this point in the history
The Orchestrator service is to serve endpoints to enable Controllers
to interface with the work queue, status, liveness over HTTP(s)
  • Loading branch information
joelrebel committed Jul 3, 2024
1 parent 6e5a283 commit 8e6b2eb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/api/v1/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Routes struct {
fleetDBClient fleetdb.FleetDB
repository store.Repository
streamBroker events.Stream
facilityCode string
streamSubjectPrefix string
conditionDefinitions rctypes.Definitions
logger *logrus.Logger
}
Expand All @@ -55,9 +57,16 @@ func WithFleetDBClient(client fleetdb.FleetDB) Option {
}

// WithStreamBroker sets the event stream broker.
func WithStreamBroker(broker events.Stream) Option {
func WithStreamBroker(broker events.Stream, streamSubjectPrefix string) Option {
return func(r *Routes) {
r.streamBroker = broker
r.streamSubjectPrefix = streamSubjectPrefix
}
}

func WithFacilityCode(fc string) Option {
return func(r *Routes) {
r.facilityCode = fc
}
}

Expand Down Expand Up @@ -127,6 +136,7 @@ func (r *Routes) composeAuthHandler(scopes []string) gin.HandlerFunc {
return r.authMW.AuthRequired(scopes)
}

// Routes returns routes for the Conditions API service.
func (r *Routes) Routes(g *gin.RouterGroup) {
servers := g.Group("/servers/:uuid")

Expand Down Expand Up @@ -157,6 +167,16 @@ func (r *Routes) Routes(g *gin.RouterGroup) {
}
}

// RoutesOrchestrator returns routes for the Orchestrator API service.
func (r *Routes) RoutesOrchestrator(g *gin.RouterGroup) {
controller := g.Group("/servers/:uuid")
controller.GET(
"/condition-queue/:conditionKind",
r.composeAuthHandler(readScopes("conditionQueuePop")),
wrapAPICall(nil),
)
}

func createScopes(items ...string) []string {
s := []string{"write", "create"}
for _, i := range items {
Expand Down

0 comments on commit 8e6b2eb

Please sign in to comment.