diff options
author | Kegsay <kegan@matrix.org> | 2020-06-30 10:37:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 10:37:21 +0100 |
commit | ca5bbffd8d987b220c8f8eb888a2fc9b9cef104c (patch) | |
tree | 421bdd5967ef492d71559d0cc819012a74bf5b80 /internal | |
parent | 3a18b7fc7814755868a9847eb99fb465c9317017 (diff) |
Add a new component: currentstateserver (#1171)
* Add a new component: currentstateserver
- Add a skeleton for it, with databases and a single query method.
- Add integration tests for it.
- Add listen/address fields in the config (breaking as this will force people to specify this to validate)
Not currently hooked up to anything yet.
* Unbreak config tests
* Add current_state to sample config
* comments
Diffstat (limited to 'internal')
-rw-r--r-- | internal/config/config.go | 22 | ||||
-rw-r--r-- | internal/config/config_test.go | 2 |
2 files changed, 21 insertions, 3 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index baa82be2..8275fc47 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -160,10 +160,13 @@ type Dendrite struct { // Postgres Config Database struct { // The Account database stores the login details and account information - // for local users. It is accessed by the ClientAPI. + // for local users. It is accessed by the UserAPI. Account DataSource `yaml:"account"` + // The CurrentState database stores the current state of all rooms. + // It is accessed by the CurrentStateServer. + CurrentState DataSource `yaml:"current_state"` // The Device database stores session information for the devices of logged - // in local users. It is accessed by the ClientAPI, the MediaAPI and the SyncAPI. + // in local users. It is accessed by the UserAPI. Device DataSource `yaml:"device"` // The MediaAPI database stores information about files uploaded and downloaded // by local users. It is only accessed by the MediaAPI. @@ -222,6 +225,7 @@ type Dendrite struct { Bind struct { MediaAPI Address `yaml:"media_api"` ClientAPI Address `yaml:"client_api"` + CurrentState Address `yaml:"current_state_server"` FederationAPI Address `yaml:"federation_api"` ServerKeyAPI Address `yaml:"server_key_api"` AppServiceAPI Address `yaml:"appservice_api"` @@ -238,6 +242,7 @@ type Dendrite struct { Listen struct { MediaAPI Address `yaml:"media_api"` ClientAPI Address `yaml:"client_api"` + CurrentState Address `yaml:"current_state_server"` FederationAPI Address `yaml:"federation_api"` ServerKeyAPI Address `yaml:"server_key_api"` AppServiceAPI Address `yaml:"appservice_api"` @@ -601,6 +606,7 @@ func (config *Dendrite) checkDatabase(configErrs *configErrors) { checkNotEmpty(configErrs, "database.media_api", string(config.Database.MediaAPI)) checkNotEmpty(configErrs, "database.sync_api", string(config.Database.SyncAPI)) checkNotEmpty(configErrs, "database.room_server", string(config.Database.RoomServer)) + checkNotEmpty(configErrs, "database.current_state", string(config.Database.CurrentState)) } // checkListen verifies the parameters listen.* are valid. @@ -613,6 +619,7 @@ func (config *Dendrite) checkListen(configErrs *configErrors) { checkNotEmpty(configErrs, "listen.edu_server", string(config.Listen.EDUServer)) checkNotEmpty(configErrs, "listen.server_key_api", string(config.Listen.EDUServer)) checkNotEmpty(configErrs, "listen.user_api", string(config.Listen.UserAPI)) + checkNotEmpty(configErrs, "listen.current_state_server", string(config.Listen.CurrentState)) } // checkLogging verifies the parameters logging.* are valid. @@ -735,6 +742,15 @@ func (config *Dendrite) UserAPIURL() string { return "http://" + string(config.Listen.UserAPI) } +// CurrentStateAPIURL returns an HTTP URL for where the currentstateserver is listening. +func (config *Dendrite) CurrentStateAPIURL() string { + // Hard code the currentstateserver to talk HTTP for now. + // If we support HTTPS we need to think of a practical way to do certificate validation. + // People setting up servers shouldn't need to get a certificate valid for the public + // internet for an internal API. + return "http://" + string(config.Listen.CurrentState) +} + // EDUServerURL returns an HTTP URL for where the EDU server is listening. func (config *Dendrite) EDUServerURL() string { // Hard code the EDU server to talk HTTP for now. @@ -753,7 +769,7 @@ func (config *Dendrite) FederationSenderURL() string { return "http://" + string(config.Listen.FederationSender) } -// FederationSenderURL returns an HTTP URL for where the federation sender is listening. +// ServerKeyAPIURL returns an HTTP URL for where the federation sender is listening. func (config *Dendrite) ServerKeyAPIURL() string { // Hard code the server key API server to talk HTTP for now. // If we support HTTPS we need to think of a practical way to do certificate validation. diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 9a543e76..9b776a50 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -55,6 +55,7 @@ database: sync_api: "postgresql:///syn_api" room_server: "postgresql:///room_server" appservice: "postgresql:///appservice" + current_state: "postgresql:///current_state" listen: room_server: "localhost:7770" client_api: "localhost:7771" @@ -64,6 +65,7 @@ listen: appservice_api: "localhost:7777" edu_server: "localhost:7778" user_api: "localhost:7779" + current_state_server: "localhost:7775" logging: - type: "file" level: "info" |