Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Created August 30, 2021 06:34
Show Gist options
  • Save percybolmer/4784bbfec17ca5749284368efda41ba7 to your computer and use it in GitHub Desktop.
Save percybolmer/4784bbfec17ca5749284368efda41ba7 to your computer and use it in GitHub Desktop.
// 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