aboutsummaryrefslogtreecommitdiff
path: root/federationsender
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-06-08 15:51:07 +0100
committerGitHub <noreply@github.com>2020-06-08 15:51:07 +0100
commit4f171c56a832c836b0eb21650ee84d56e451dd6a (patch)
treee92059f1dbb784c978b60897d6ac13983d51c1b4 /federationsender
parentcdb9a115715bd5a9e84df5bc95060e2dac1f6d89 (diff)
Split out SetupFooComponent (#1106)
* Split out adding HTTP routes from making internal APIs for clarity * Split out more components * Split out more things * Finish converting * internal mux for internal routes
Diffstat (limited to 'federationsender')
-rw-r--r--federationsender/federationsender.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/federationsender/federationsender.go b/federationsender/federationsender.go
index e25c2723..e3e0ef9d 100644
--- a/federationsender/federationsender.go
+++ b/federationsender/federationsender.go
@@ -15,6 +15,7 @@
package federationsender
import (
+ "github.com/gorilla/mux"
"github.com/matrix-org/dendrite/federationsender/api"
"github.com/matrix-org/dendrite/federationsender/consumers"
"github.com/matrix-org/dendrite/federationsender/internal"
@@ -29,9 +30,15 @@ import (
"github.com/sirupsen/logrus"
)
-// SetupFederationSenderComponent sets up and registers HTTP handlers for the
-// FederationSender component.
-func SetupFederationSenderComponent(
+// AddInternalRoutes registers HTTP handlers for the internal API. Invokes functions
+// on the given input API.
+func AddInternalRoutes(router *mux.Router, intAPI api.FederationSenderInternalAPI) {
+ inthttp.AddRoutes(intAPI, router)
+}
+
+// NewInternalAPI returns a concerete implementation of the internal API. Callers
+// can call functions directly on the returned API or via an HTTP interface using AddInternalRoutes.
+func NewInternalAPI(
base *basecomponent.BaseDendrite,
federation *gomatrixserverlib.FederationClient,
rsAPI roomserverAPI.RoomserverInternalAPI,
@@ -66,8 +73,5 @@ func SetupFederationSenderComponent(
logrus.WithError(err).Panic("failed to start typing server consumer")
}
- queryAPI := internal.NewFederationSenderInternalAPI(federationSenderDB, base.Cfg, roomserverProducer, federation, keyRing, statistics, queues)
- inthttp.AddRoutes(queryAPI, base.InternalAPIMux)
-
- return queryAPI
+ return internal.NewFederationSenderInternalAPI(federationSenderDB, base.Cfg, roomserverProducer, federation, keyRing, statistics, queues)
}