users

package
v0.0.0-...-c825c05 Latest Latest
Warning

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

Go to latest
Published: May 27, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Users package is a sample business domain object package for application users

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeHandler

func MakeHandler(us Service, logger kitlog.Logger) http.Handler

Types

type MockRepository

type MockRepository struct {
	// contains filtered or unexported fields
}

Mock of Repository interface

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

func (*MockRepository) EXPECT

func (_m *MockRepository) EXPECT() *_MockRepositoryRecorder

func (*MockRepository) Find

func (_m *MockRepository) Find(id int) (*User, error)

func (*MockRepository) FindAll

func (_m *MockRepository) FindAll() []*User

func (*MockRepository) Store

func (_m *MockRepository) Store(user *User) error

type MockService

type MockService struct {
	// contains filtered or unexported fields
}

Mock of Service interface

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

func (*MockService) CreateUser

func (_m *MockService) CreateUser(id int, fname string, lname string, color string) (int, error)

func (*MockService) EXPECT

func (_m *MockService) EXPECT() *_MockServiceRecorder

func (*MockService) ReadUser

func (_m *MockService) ReadUser(id int) (User, error)

func (*MockService) UpdateUserColor

func (_m *MockService) UpdateUserColor(id int, color string) error

func (*MockService) Users

func (_m *MockService) Users() []*User

type Repository

type Repository interface {
	// Store a new user in the repository
	Store(user *User) error

	// Find a user in the repository by ID
	Find(id int) (*User, error)

	// FindAll users in the repository
	FindAll() []*User
}

(User) Repository is the set of behavior a repository, or "store", of users must conform to.

type Service

type Service interface {
	// CreateUser defines a new user and returns its id
	CreateUser(id int, fname string, lname string, color string) (int, error)

	// ReadUser finds a user model by id
	ReadUser(id int) (User, error)

	// UpdateUserColor sets a user's favorite color
	UpdateUserColor(id int, color string) error

	// Users returns all users
	Users() []*User
}

Service describes the behavior of a user service e.g. CRUD actions

func NewInstrumentingService

func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service

NewInstrumentingService generates a new instance of our instrumented files service

func NewLoggingService

func NewLoggingService(logger log.Logger, s Service) Service

NewLoggingService generates a new logging service

func NewService

func NewService(repo Repository) Service

NewService returns a new userService

type User

type User struct {
	ID            int    `json:"id"`
	FirstName     string `json:"first_name"`
	LastName      string `json:"last_name"`
	FavoriteColor string `json:"fav_color,omitempty"`
}

User describes an application user business object

func New

func New(id int, fname string, lname string) *User

New returns a reference to a new user instance

Jump to

Keyboard shortcuts

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