Revisiting the anti-corruption layer
We looked at the anti-corruption layer (also known as the adapter pattern) in Chapter 2. As a reminder, the adaptor pattern is useful for decoupling two different bounded contexts from each other, which helps separate concerns and ensure our systems can evolve independently and safely.
Let’s add an adaptor layer that satisfies the AvailabilityGetter
interface.
Firstly, let’s make a new file called adapter.go
:
Figure 6.4 – Creation of adapter.go
Firstly, let’s define a client struct and a New
function:
type PartnershipAdaptor struct { client *http.Client url string } func NewPartnerShipAdaptor(client *http.Client, url string) (*Client, error) { if client == nil { return nil, errors.New("client cannot be nil") } if url == "...