Use SetupAndServe instead of AddHealthCheck

This commit is contained in:
Till Faelligen 2020-10-05 18:35:03 +02:00
parent 3af5faa592
commit 47b7828a96
8 changed files with 11 additions and 9 deletions

View file

@ -29,11 +29,11 @@ func main() {
intAPI := appservice.NewInternalAPI(base, userAPI, rsAPI)
appservice.AddInternalRoutes(base.InternalAPIMux, intAPI)
setup.AddHealthCheck(base.InternalAPIMux, base.Cfg.AppServiceAPI.Database)
base.SetupAndServeHTTP(
base.Cfg.AppServiceAPI.InternalAPI.Listen,
setup.NoExternalListener,
nil, nil,
base.Cfg.AppServiceAPI.Database,
)
}

View file

@ -28,11 +28,11 @@ func main() {
intAPI.SetUserAPI(base.UserAPIClient())
keyserver.AddInternalRoutes(base.InternalAPIMux, intAPI)
setup.AddHealthCheck(base.InternalAPIMux, base.Cfg.KeyServer.Database)
base.SetupAndServeHTTP(
base.Cfg.KeyServer.InternalAPI.Listen,
setup.NoExternalListener,
nil, nil,
base.Cfg.KeyServer.Database,
)
}

View file

@ -28,11 +28,11 @@ func main() {
client := base.CreateClient()
mediaapi.AddPublicRoutes(base.PublicMediaAPIMux, &base.Cfg.MediaAPI, userAPI, client)
setup.AddHealthCheck(base.InternalAPIMux, base.Cfg.MediaAPI.Database)
base.SetupAndServeHTTP(
base.Cfg.MediaAPI.InternalAPI.Listen,
base.Cfg.MediaAPI.ExternalAPI.Listen,
nil, nil,
base.Cfg.MediaAPI.Database,
)
}

View file

@ -145,7 +145,7 @@ func main() {
base.PublicMediaAPIMux,
)
setup.AddHealthCheck(base.InternalAPIMux,
dbConfigs := []config.DatabaseOptions{
base.Cfg.AppServiceAPI.Database,
base.Cfg.FederationSender.Database,
base.Cfg.KeyServer.Database,
@ -154,7 +154,7 @@ func main() {
base.Cfg.SyncAPI.Database,
base.Cfg.UserAPI.AccountDatabase,
base.Cfg.UserAPI.DeviceDatabase,
)
}
// Expose the matrix APIs directly rather than putting them under a /api path.
go func() {
@ -162,6 +162,7 @@ func main() {
config.HTTPAddress(httpAddr), // internal API
config.HTTPAddress(httpAddr), // external API
nil, nil, // TLS settings
dbConfigs..., // used in health checks
)
}()
// Handle HTTPS if certificate and key are provided
@ -171,6 +172,7 @@ func main() {
config.HTTPAddress(httpsAddr), // internal API
config.HTTPAddress(httpsAddr), // external API
certFile, keyFile, // TLS settings
dbConfigs..., // used in health checks
)
}()
}

View file

@ -31,11 +31,11 @@ func main() {
rsAPI := roomserver.NewInternalAPI(base, keyRing)
rsAPI.SetFederationSenderAPI(fsAPI)
roomserver.AddInternalRoutes(base.InternalAPIMux, rsAPI)
setup.AddHealthCheck(base.InternalAPIMux, base.Cfg.RoomServer.Database)
base.SetupAndServeHTTP(
base.Cfg.RoomServer.InternalAPI.Listen,
setup.NoExternalListener,
nil, nil,
base.Cfg.RoomServer.Database,
)
}

View file

@ -28,11 +28,11 @@ func main() {
intAPI := serverkeyapi.NewInternalAPI(&base.Cfg.ServerKeyAPI, federation, base.Caches)
serverkeyapi.AddInternalRoutes(base.InternalAPIMux, intAPI, base.Caches)
setup.AddHealthCheck(base.InternalAPIMux, base.Cfg.ServerKeyAPI.Database)
base.SetupAndServeHTTP(
base.Cfg.ServerKeyAPI.InternalAPI.Listen,
setup.NoExternalListener,
nil, nil,
base.Cfg.ServerKeyAPI.Database,
)
}

View file

@ -34,11 +34,11 @@ func main() {
base.KeyServerHTTPClient(),
federation, &cfg.SyncAPI,
)
setup.AddHealthCheck(base.InternalAPIMux, base.Cfg.SyncAPI.Database)
base.SetupAndServeHTTP(
base.Cfg.SyncAPI.InternalAPI.Listen,
base.Cfg.SyncAPI.ExternalAPI.Listen,
nil, nil,
base.Cfg.SyncAPI.Database,
)
}

View file

@ -29,11 +29,11 @@ func main() {
userAPI := userapi.NewInternalAPI(accountDB, &cfg.UserAPI, cfg.Derived.ApplicationServices, base.KeyServerHTTPClient())
userapi.AddInternalRoutes(base.InternalAPIMux, userAPI)
setup.AddHealthCheck(base.InternalAPIMux, cfg.UserAPI.AccountDatabase, cfg.UserAPI.DeviceDatabase)
base.SetupAndServeHTTP(
base.Cfg.UserAPI.InternalAPI.Listen,
setup.NoExternalListener,
nil, nil,
cfg.UserAPI.AccountDatabase, cfg.UserAPI.DeviceDatabase,
)
}