Philipp Mayer
05/21/2023, 4:36 PMShopApi
(Github) gets passed in one httpHandler
, which is being used (via outgoingHttp
) for two different targets: The Warehouse
and SESNotifications
.
In LocalShopApiTests
(Github), FakeWarehouse()
is being passed in, which then ends up also being used for SESNotifications
.
Shouldn’t there be two parameters, one that gets a FakeWarehouse
and one that gets a FakeSES
?
Why is that/what am I missing here? 🙂
Thanks in advance!s4nchez
05/21/2023, 5:32 PMdave
05/21/2023, 6:21 PMPhilipp Mayer
05/21/2023, 6:50 PMI actually support using a single HTTP handler to the ShopAPI (which takes the HTTP "adapter")... and then use the reverse proxy pattern to split the traffic. This means that you only need one HTTP client (or you can also use a reverserproxy when injecting them to direct the traffic to a different HTTP client based on the URL.)Interesting stuff! Is this a common pattern in your services? Passing in one http handler that's actually a reverse proxy which then translates two X services?
dave
05/21/2023, 7:11 PMval http = reverseProxy(
WAREHOUSE_URL(ENV).authority to JavaHttpClient(),
"ses" to JavaHttpClient()
)
You can really go to town on this stuff - and actually hide is all behind a ServiceDiscovery
interface - which is basically:
interface ServiceDiscovery = (AppName) -> HttpHandler
- we did have it in the example repo originally but it complicated the slides too much so we pared it back. But it does make the wiring stuff easier to manage TBH (what became the NetworkAccess in the repo)... especially for running different "universes" - such as an InMemoryUniverse and a StagingUniverse and a LocalServerUniverse....HttpWarehouse(env[WAREHOUSE_URL], outgoingHttp)
... would become something like:
HttpWarehouse(serviceDiscovery(AppName.Warehouse)
Philipp Mayer
05/21/2023, 7:40 PMHttpHandler
instead of MyHttpBankClientClass
) - how do you assure that other teams/devs use it as intended?
For example, you have AppIncomingHttp
and AppOutgoingHttp
which are both http handlers that could be mixed up.
More of a design debate now, but I’m curiousdave
05/21/2023, 7:46 PMHasOpenApi
, or EndpointsAreSecured
and they can all be mixed into the main test suite - all you need to do is to provide a base test class which supplies the HTTP handler application setup and implements all of the Test interfaces and you get them all for free 🙂Philipp Mayer
05/21/2023, 7:49 PM