-2

Usually, a proxy is used for internal services, but I'm interested in the opposite situation. I want to create a single point of access to external resources for my services. These external resources include Google APIs, Facebook APIs, and similar services. The functionality I want includes logging all requests to external APIs, restricting access, configuring timeouts, and implementing a circuit breaker feature.

My question is, how can I achieve this desired functionality? Which applications are suitable for this purpose?

4
  • So you are talking about gateway. What do you mean by "how can I achieve that"? Implement it? Or find a tool that already does that? Commented Oct 25, 2024 at 9:26
  • Using tools is prefferable way Commented Oct 25, 2024 at 10:37
  • Asking for tools is off-topic, because some tool that exists today might no longer exist tomorrow, so these kind of questions don’t have a long lasting value. Commented Oct 25, 2024 at 16:39
  • @RikD which Stack Exchange communities are suitable for this question? Commented Oct 29, 2024 at 9:34

2 Answers 2

3

That would be a proxy as well. And indeed, this technique is often used in high-security industries to monitor and restrict access to the resources outside the company—it could be as well a generic proxy that all employees should use to access websites, for example, or a specific proxy that APIs should use to call, say, Amazon AWS.

Regarding the features:

  • “logging all requests to external APIs” is done in the exact same way a reverse proxy would log all the requests that come from anywhere and reach your corporate website.

  • “restricting access”: same here. Nothing different from, say, restricting access, for a given internal API, to a single department in your company.

  • “configuring timeouts”: same here.

  • “implementing a circuit breaker feature”: in most reverse proxies, you can have a sort of a circuit breaker pattern. Usually, the logic is very basic for the reverse proxies (if server 1 is unreachable, reach server 2), but more complex scenarios are often supported as well (including being able to determine that the service is unreachable).

2

To augment Arseni's excellent points...

Another term you might hear is Wrapper: taking some technology specific / 3rd party code and wrapping it with a thin layer of your own code, which the rest of your code talks to, so when the underlying 3rd party tech changes, or you want to use something different, you only have to make changes in one place. You need to be careful how you define the API on your wrapper so that is doesn't contain terms and features that are too specific to the underlying 3rd party code.

You can further manage dependencies with other loose-coupling techniques like dependency injection.

Martin Fowler's Gateway pattern is the same thing: https://www.martinfowler.com/eaaCatalog/gateway.html

The Separated Interface pattern may also be helpful in terms of loose-coupling, if that is not a concept you are familiar with - i.e. you can make a wrapper, and either call it directly or use this pattern to further abstract it, which can be helpful if you need to swap different wrapper/gateway/proxy implementations in and out (e.g. for testing or multi-cloud situations): https://www.martinfowler.com/eaaCatalog/separatedInterface.html

1
  • The Gateway pattern was my first thought as well. I think Arsen's answer is very good in a general sense, but I think this one more directly suits the OP's situation. Commented Oct 28, 2024 at 15:15

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.