Created
August 30, 2021 06:34
-
-
Save percybolmer/4784bbfec17ca5749284368efda41ba7 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
// WithMemoryProductRepository adds a in memory product repo and adds all input products | |
func WithMemoryProductRepository(products []aggregate.Product) OrderConfiguration { | |
return func(os *OrderService) error { | |
// Create the memory repo, if we needed parameters, such as connection strings they could be inputted here | |
pr := prodmemory.New() | |
// Add Items to repo | |
for _, p := range products { | |
err := pr.Add(p) | |
if err != nil { | |
return err | |
} | |
} | |
os.products = pr | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment