this makes it easier to stub things out for tests.
Pull the magic that is currently in matrix_federation_endpoint and friends into an agent-like thing