Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemoryRepository ¶
type InMemoryRepository struct {
// contains filtered or unexported fields
}
InMemoryRepository implements the coffee-service.data.Repository interface uisng go-membdb instead of postgres.
type MockRepository ¶
MockRepository is a mock connection object for unit tests.
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
PostgresRepository is a postgres implementation of the Repository interface.
type Repository ¶
Repository is the command/query interface this respository supports.
func NewFromConfig ¶
func NewFromConfig(cfg *config.Config) (Repository, error)
NewFromConfig is the CoffeeRepository factory method. It encapsulates the Postgres DB. It will attempt to create a connection, and keep retrying the database connection until successful or times out. When running the application on a scheduler it is possible (likely) that the app will come up before the database, this can cause the app to go into a CrashLoopBackoff cycle. By defining a retry loop, we are implementing circuit breaker, rather than just crashing on startup if the db is unavailable. TODO: this whole thing needs to be addressed. Probably we want to move the circuit breaking back to the lifecycle in main, and have this just test IsConnected() or just try to make the call.
func NewInMemoryDB ¶
func NewInMemoryDB(config *config.Config) (Repository, error)
NewInMemoryDB is the InMemoryRepository factory method. It fulfills the same interface as Repository, but uses go-membdb internally to provide data. NOTE, this interface requires build time tooling.
type TableNameKey ¶
type TableNameKey string
TableNameKey is a typesafe discriminator for table names
const ( // Ingredient is the ingredient table name Ingredient TableNameKey = "ingredient" // Coffee is the coffee table name Coffee TableNameKey = "coffee" // CoffeeIngredient is the coffee_ingredient table name CoffeeIngredient TableNameKey = "coffee_ingredient" )
func (TableNameKey) String ¶
func (t TableNameKey) String() string