Created
August 29, 2021 06:18
-
-
Save percybolmer/da0a52d275e4b9121fb15caccef7af41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WithCustomerRepository applies a given customer repository to the OrderService | |
func WithCustomerRepository(cr customer.CustomerRepository) OrderConfiguration { | |
// return a function that matches the OrderConfiguration alias, | |
// You need to return this so that the parent function can take in all the needed parameters | |
return func(os *OrderService) error { | |
os.customers = cr | |
return nil | |
} | |
} | |
// WithMemoryCustomerRepository applies a memory customer repository to the OrderService | |
func WithMemoryCustomerRepository() OrderConfiguration { | |
// Create the memory repo, if we needed parameters, such as connection strings they could be inputted here | |
cr := memory.New() | |
return WithCustomerRepository(cr) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment