Skip to content

Commit

Permalink
Merge branch 'fx-init' into ancla
Browse files Browse the repository at this point in the history
  • Loading branch information
maurafortino committed Dec 13, 2023
2 parents 4fe9847 + ebe985e commit 28b0b22
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func caduceus(arguments []string, run bool) error {
arrangehttp.ProvideServer("servers.health"),
arrangehttp.ProvideServer("servers.metrics"),
arrangehttp.ProvideServer("servers.pprof"),
// arrangehttp.ProvideServer("servers.primary"),
// arrangehttp.ProvideServer("servers.alternate"),
arrangehttp.ProvideServer("servers.primary"),
arrangehttp.ProvideServer("servers.alternate"),

touchstone.Provide(),
touchhttp.Provide(),
Expand Down
2 changes: 1 addition & 1 deletion metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func NewMetricWrapperMeasures(m CaduceusMetricsRegistry) metrics.Histogram {

// TODO: do these need to be annonated/broken into groups based on where the metrics are being used/called
func ProvideMetrics() fx.Option {
return fx.Provide(
return fx.Options(
touchstone.Gauge(prometheus.GaugeOpts{
Name: IncomingQueueDepth,
Help: "The depth of the queue behind the incoming handlers.",
Expand Down
18 changes: 16 additions & 2 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,27 @@ func provideCoreEndpoints() fx.Option {
},
func(in RoutesIn) RoutesOut {
return RoutesOut{
// Primary: provideCoreOption("primary", in),
// Alternate: provideCoreOption("alternate", in),
Primary: provideCoreOption("primary", in),
Alternate: provideCoreOption("alternate", in),
}
},
)
}

func provideCoreOption(server string, in RoutesIn) arrangehttp.Option[http.Server] {
return arrangehttp.AsOption[http.Server](
func(s *http.Server) {
mux := chi.NewMux()
if server == "primary" {
s.Handler = in.PrimaryMetrics.Then(mux)
} else {
s.Handler = in.AlternateMetrics.Then(mux)
}
},
)

}

func provideHealthCheck() fx.Option {
return fx.Provide(
fx.Annotated{
Expand Down

0 comments on commit 28b0b22

Please sign in to comment.