Last active
August 29, 2021 06:30
-
-
Save percybolmer/746c71e39778967050e6d9ee0c338732 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
// Package memory is a in-memory implementation of the customer repository | |
package memory | |
import ( | |
"sync" | |
"github.com/google/uuid" | |
"github.com/percybolmer/ddd-go/aggregate" | |
) | |
// MemoryRepository fulfills the CustomerRepository interface | |
type MemoryRepository struct { | |
customers map[uuid.UUID]aggregate.Customer | |
sync.Mutex | |
} | |
// New is a factory function to generate a new repository of customers | |
func New() *MemoryRepository { | |
return &MemoryRepository{ | |
customers: make(map[uuid.UUID]aggregate.Customer), | |
} | |
} | |
// Get finds a customer by ID | |
func (mr *MemoryRepository) Get(uuid.UUID) (aggregate.Customer, error) { | |
return aggregate.Customer{}, nil | |
} | |
// Add will add a new customer to the repository | |
func (mr *MemoryRepository) Add(aggregate.Customer) error { | |
return nil | |
} | |
// Update will replace an existing customer information with the new customer information | |
func (mr *MemoryRepository) Update(aggregate.Customer) error { | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment