Documentation ¶
Overview ¶
Package repository provides real implementation of storing data. It doesn't necessarily a database. It can be a file or in-memory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GetURLCache ¶
type GetURLCache interface { // Get gets a URL from the cache. Get(ctx context.Context, code string) (*entity.URL, error) InsertURLCache }
GetURLCache defines the interface to get URL from the cache.
type GetURLDatabase ¶
type GetURLDatabase interface { // GetAll gets all URLs from the database. GetAll(ctx context.Context) ([]*entity.URL, error) // GetByCode gets a single URL from the database. // If the URL can't be found, it returns entity.ErrNotFound(). GetByCode(ctx context.Context, code string) (*entity.URL, error) }
GetURLDatabase defines the interface to get URL from the database.
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker is responsible to check all dependencies' condition.
func NewHealthChecker ¶
func NewHealthChecker(deps ...HealthCheckerRepository) *HealthChecker
NewHealthChecker creates an instance of HealthChecker.
type HealthCheckerRepository ¶
type HealthCheckerRepository interface { // IsAlive must returns true if the system can connect without any problem. IsAlive(ctx context.Context) bool }
HealthCheckerRepository is the interface that defines the repository health check.
type InsertURLCache ¶
type InsertURLCache interface { // Save saves a new URL into the cache. Save(ctx context.Context, url *entity.URL) error }
InsertURLCache defines the interface to insert a new URL to the cache.
type InsertURLDatabase ¶
type InsertURLDatabase interface { // Insert inserts a new URL into the database. // It must handle if the data already exists. Insert(ctx context.Context, url *entity.URL) error }
InsertURLDatabase defines the interface to insert a new URL to the database.
type URLGetter ¶
type URLGetter struct {
// contains filtered or unexported fields
}
URLGetter is responsible to get URL from storage. It uses database and cache.
func NewURLGetter ¶
func NewURLGetter(database GetURLDatabase, cache GetURLCache) *URLGetter
NewURLGetter creates an instance of URLGetter.
type URLInserter ¶
type URLInserter struct {
// contains filtered or unexported fields
}
URLInserter is responsible to insert a new URL into storage. It uses database and cache.
func NewURLInserter ¶
func NewURLInserter(database InsertURLDatabase, cache InsertURLCache) *URLInserter
NewURLInserter creates an instance of URLInserter.