Documentation ¶
Index ¶
- func HitCounter() echo.MiddlewareFunc
- type App
- type AppOption
- type Health
- type HealthCheckFn
- type HealthOption
- type MockNoteRepository
- func (_m *MockNoteRepository) Create(content string) (*Note, error)
- func (_m *MockNoteRepository) Delete(id string) error
- func (_m *MockNoteRepository) List() ([]Note, error)
- func (_m *MockNoteRepository) Retrieve(id string) (*Note, error)
- func (_m *MockNoteRepository) Update(id string, content string) (*Note, error)
- type MockRedisClient
- func (_m *MockRedisClient) Delete(keys ...string) (int64, error)
- func (_m *MockRedisClient) HGetAllMap(key string) (map[string]string, error)
- func (_m *MockRedisClient) HMSet(key string, field string, value string, pairs ...string) (string, error)
- func (_m *MockRedisClient) LPush(key string, values ...string) (int64, error)
- func (_m *MockRedisClient) LRange(key string, start int64, stop int64) ([]string, error)
- func (_m *MockRedisClient) LRem(key string, count int64, value interface{}) (int64, error)
- func (_m *MockRedisClient) Ping() (string, error)
- func (_m *MockRedisClient) Set(key string, value interface{}, expiration time.Duration) (string, error)
- type Note
- type NoteRepository
- type RedisClient
- type RedisNoteRepository
- func (nr *RedisNoteRepository) Create(content string) (*Note, error)
- func (nr *RedisNoteRepository) Delete(id string) error
- func (nr *RedisNoteRepository) List() ([]Note, error)
- func (nr *RedisNoteRepository) Retrieve(id string) (*Note, error)
- func (nr *RedisNoteRepository) Update(id, content string) (*Note, error)
- type RedisNoteRepositoryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppOption ¶
AppOption is an option for configuring App.
func AppNoteRepository ¶
func AppNoteRepository(nr NoteRepository) AppOption
AppNoteRepository sets the note repository for App.
type Health ¶
type Health struct {
// contains filtered or unexported fields
}
Health is a health checker.
func NewHealth ¶
func NewHealth(opts ...HealthOption) (*Health, error)
NewHealth builds an instance of Health.
type HealthCheckFn ¶
type HealthCheckFn func() bool
HealthCheckFn is a health check function that returns true for success.
type HealthOption ¶
HealthOption is a Healh configuration option.
func HealthCheckOption ¶
func HealthCheckOption(hc HealthCheckFn) HealthOption
HealthCheckOption adds a health check.
type MockNoteRepository ¶
func (*MockNoteRepository) Create ¶
func (_m *MockNoteRepository) Create(content string) (*Note, error)
func (*MockNoteRepository) Delete ¶
func (_m *MockNoteRepository) Delete(id string) error
func (*MockNoteRepository) List ¶
func (_m *MockNoteRepository) List() ([]Note, error)
type MockRedisClient ¶
func (*MockRedisClient) HGetAllMap ¶
func (_m *MockRedisClient) HGetAllMap(key string) (map[string]string, error)
func (*MockRedisClient) LPush ¶
func (_m *MockRedisClient) LPush(key string, values ...string) (int64, error)
func (*MockRedisClient) LRem ¶
func (_m *MockRedisClient) LRem(key string, count int64, value interface{}) (int64, error)
func (*MockRedisClient) Ping ¶
func (_m *MockRedisClient) Ping() (string, error)
type Note ¶
type Note struct { ID string `json:"id"` Content string `json:"content"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Note is note.
type NoteRepository ¶
type NoteRepository interface { Create(content string) (*Note, error) Retrieve(id string) (*Note, error) Update(id, content string) (*Note, error) Delete(id string) error List() ([]Note, error) }
NoteRepository is a repository for managing notes.
func NewRedisNoteRepository ¶
func NewRedisNoteRepository(opts ...RedisNoteRepositoryOption) (NoteRepository, error)
NewRedisNoteRepository creates an instance of NoteRepository.
type RedisClient ¶
type RedisClient interface { Delete(keys ...string) (int64, error) HGetAllMap(key string) (map[string]string, error) HMSet(key, field, value string, pairs ...string) (string, error) LPush(key string, values ...string) (int64, error) LRange(key string, start, stop int64) ([]string, error) LRem(key string, count int64, value interface{}) (int64, error) Ping() (string, error) Set(key string, value interface{}, expiration time.Duration) (string, error) }
RedisClient is an interface which can interfact with a redis server.
func NewRedisClient ¶
func NewRedisClient(addr string) (RedisClient, error)
NewRedisClient creates an instance of RedisClient. It will attempt multiple times using a backoff policy.
type RedisNoteRepository ¶
type RedisNoteRepository struct {
// contains filtered or unexported fields
}
RedisNoteRepository is an implementation of NoteRepository backed by Redis.
func (*RedisNoteRepository) Create ¶
func (nr *RedisNoteRepository) Create(content string) (*Note, error)
Create creates a new note.
func (*RedisNoteRepository) Delete ¶
func (nr *RedisNoteRepository) Delete(id string) error
Delete deletes an existing note.
func (*RedisNoteRepository) List ¶
func (nr *RedisNoteRepository) List() ([]Note, error)
List retrieves all the notes.
type RedisNoteRepositoryOption ¶
type RedisNoteRepositoryOption func(*RedisNoteRepository) error
RedisNoteRepositoryOption is an option for configuring RedisNoteRepository.
func NoteBase ¶
func NoteBase(base string) RedisNoteRepositoryOption
NoteBase is the base string for all note keys.
func NoteIDGenFn ¶
func NoteIDGenFn(idGen func() string) RedisNoteRepositoryOption
NoteIDGenFn sets the id generator for RedisNoteRepository.
func RedisClientOption ¶
func RedisClientOption(rc RedisClient) RedisNoteRepositoryOption
RedisClientOption sets the Redis client for RedisNoteRepository.