Remove polylith/API mode (#2967)

This removes most of the code used for polylith/API mode.

This removes the `/api` internal endpoints entirely. 

Binary size change roughly 5%: 
```
51437560 Feb 13 10:15 dendrite-monolith-server # old
48759008 Feb 13 10:15 dendrite-monolith-server # new
```
This commit is contained in:
Till 2023-02-14 12:47:47 +01:00 committed by GitHub
parent cc59879faa
commit 11d9b9db0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
106 changed files with 374 additions and 5850 deletions

View file

@ -38,7 +38,6 @@ type Global struct {
// component does not specify any database options of its own, then this pool of
// connections will be used instead. This way we don't have to manage connection
// counts on a per-component basis, but can instead do it for the entire monolith.
// In a polylith deployment, this will be ignored.
DatabaseOptions DatabaseOptions `yaml:"database,omitempty"`
// The server name to delegate server-server communications to, with optional port
@ -93,7 +92,7 @@ func (c *Global) Defaults(opts DefaultOpts) {
}
}
c.KeyValidityPeriod = time.Hour * 24 * 7
if opts.Monolithic {
if opts.SingleDatabase {
c.DatabaseOptions.Defaults(90)
}
c.JetStream.Defaults(opts)
@ -105,7 +104,7 @@ func (c *Global) Defaults(opts DefaultOpts) {
c.Cache.Defaults()
}
func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
func (c *Global) Verify(configErrs *ConfigErrors) {
checkNotEmpty(configErrs, "global.server_name", string(c.ServerName))
checkNotEmpty(configErrs, "global.private_key", string(c.PrivateKeyPath))
@ -113,13 +112,13 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
v.Verify(configErrs)
}
c.JetStream.Verify(configErrs, isMonolith)
c.Metrics.Verify(configErrs, isMonolith)
c.Sentry.Verify(configErrs, isMonolith)
c.DNSCache.Verify(configErrs, isMonolith)
c.ServerNotices.Verify(configErrs, isMonolith)
c.ReportStats.Verify(configErrs, isMonolith)
c.Cache.Verify(configErrs, isMonolith)
c.JetStream.Verify(configErrs)
c.Metrics.Verify(configErrs)
c.Sentry.Verify(configErrs)
c.DNSCache.Verify(configErrs)
c.ServerNotices.Verify(configErrs)
c.ReportStats.Verify(configErrs)
c.Cache.Verify(configErrs)
}
func (c *Global) IsLocalServerName(serverName gomatrixserverlib.ServerName) bool {
@ -267,7 +266,7 @@ func (c *Metrics) Defaults(opts DefaultOpts) {
}
}
func (c *Metrics) Verify(configErrs *ConfigErrors, isMonolith bool) {
func (c *Metrics) Verify(configErrs *ConfigErrors) {
}
// ServerNotices defines the configuration used for sending server notices
@ -293,7 +292,7 @@ func (c *ServerNotices) Defaults(opts DefaultOpts) {
}
}
func (c *ServerNotices) Verify(errors *ConfigErrors, isMonolith bool) {}
func (c *ServerNotices) Verify(errors *ConfigErrors) {}
type Cache struct {
EstimatedMaxSize DataUnit `yaml:"max_size_estimated"`
@ -305,7 +304,7 @@ func (c *Cache) Defaults() {
c.MaxAge = time.Hour
}
func (c *Cache) Verify(errors *ConfigErrors, isMonolith bool) {
func (c *Cache) Verify(errors *ConfigErrors) {
checkPositive(errors, "max_size_estimated", int64(c.EstimatedMaxSize))
}
@ -323,7 +322,7 @@ func (c *ReportStats) Defaults() {
c.Endpoint = "https://matrix.org/report-usage-stats/push"
}
func (c *ReportStats) Verify(configErrs *ConfigErrors, isMonolith bool) {
func (c *ReportStats) Verify(configErrs *ConfigErrors) {
if c.Enabled {
checkNotEmpty(configErrs, "global.report_stats.endpoint", c.Endpoint)
}
@ -344,7 +343,7 @@ func (c *Sentry) Defaults() {
c.Enabled = false
}
func (c *Sentry) Verify(configErrs *ConfigErrors, isMonolith bool) {
func (c *Sentry) Verify(configErrs *ConfigErrors) {
}
type DatabaseOptions struct {
@ -364,8 +363,7 @@ func (c *DatabaseOptions) Defaults(conns int) {
c.ConnMaxLifetimeSeconds = -1
}
func (c *DatabaseOptions) Verify(configErrs *ConfigErrors, isMonolith bool) {
}
func (c *DatabaseOptions) Verify(configErrs *ConfigErrors) {}
// MaxIdleConns returns maximum idle connections to the DB
func (c DatabaseOptions) MaxIdleConns() int {
@ -397,7 +395,7 @@ func (c *DNSCacheOptions) Defaults() {
c.CacheLifetime = time.Minute * 5
}
func (c *DNSCacheOptions) Verify(configErrs *ConfigErrors, isMonolith bool) {
func (c *DNSCacheOptions) Verify(configErrs *ConfigErrors) {
checkPositive(configErrs, "cache_size", int64(c.CacheSize))
checkPositive(configErrs, "cache_lifetime", int64(c.CacheLifetime))
}