omniscient

package
v0.0.0-...-121e2de Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HitCounter

func HitCounter() echo.MiddlewareFunc

HitCounter tracks hits.

Types

type App

type App struct {
	Mux http.Handler
	// contains filtered or unexported fields
}

App is the application.

func NewApp

func NewApp(opts ...AppOption) (*App, error)

NewApp creates an instance of App.

type AppOption

type AppOption func(*App) error

AppOption is an option for configuring App.

func AppHealth

func AppHealth(h *Health) AppOption

AppHealth sets the app health checker option.

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.

func (*Health) IsOK

func (h *Health) IsOK() bool

IsOK returns the current health status. True for OK, and false for not.

func (*Health) Start

func (h *Health) Start() error

Start starts the health check verification loop.

func (*Health) Stop

func (h *Health) Stop() error

Stop stops the health check verification loop.

type HealthCheckFn

type HealthCheckFn func() bool

HealthCheckFn is a health check function that returns true for success.

type HealthOption

type HealthOption func(*Health) error

HealthOption is a Healh configuration option.

func HealthCheckOption

func HealthCheckOption(hc HealthCheckFn) HealthOption

HealthCheckOption adds a health check.

type MockNoteRepository

type MockNoteRepository struct {
	mock.Mock
}

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)

func (*MockNoteRepository) Retrieve

func (_m *MockNoteRepository) Retrieve(id string) (*Note, error)

func (*MockNoteRepository) Update

func (_m *MockNoteRepository) Update(id string, content string) (*Note, error)

type MockRedisClient

type MockRedisClient struct {
	mock.Mock
}

func (*MockRedisClient) Delete

func (_m *MockRedisClient) Delete(keys ...string) (int64, error)

func (*MockRedisClient) HGetAllMap

func (_m *MockRedisClient) HGetAllMap(key string) (map[string]string, error)

func (*MockRedisClient) HMSet

func (_m *MockRedisClient) HMSet(key string, field string, value string, pairs ...string) (string, error)

func (*MockRedisClient) LPush

func (_m *MockRedisClient) LPush(key string, values ...string) (int64, error)

func (*MockRedisClient) LRange

func (_m *MockRedisClient) LRange(key string, start int64, stop int64) ([]string, 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)

func (*MockRedisClient) Set

func (_m *MockRedisClient) Set(key string, value interface{}, expiration time.Duration) (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.

func (*RedisNoteRepository) Retrieve

func (nr *RedisNoteRepository) Retrieve(id string) (*Note, error)

Retrieve retrieves an existing note.

func (*RedisNoteRepository) Update

func (nr *RedisNoteRepository) Update(id, content string) (*Note, error)

Update updates an existing note.

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.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL