app

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package app provides business logic.

Package app is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrContactExists = errors.New("contact already exists")
)

Errors.

View Source
var (
	Metric def.Metrics // Common metrics used by all packages.
)

Functions

func InitMetrics added in v1.0.0

func InitMetrics(reg *prometheus.Registry)

InitMetrics must be called once before using this package. It registers and initializes metrics used by this package.

Types

type App

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

App implements interface Appl.

func New

func New(repo Repo) *App

func (*App) AddContact

func (a *App) AddContact(ctx Ctx, auth Auth, name string) (*Contact, error)

func (*App) Contacts

func (a *App) Contacts(ctx Ctx, auth Auth) ([]Contact, error)

type Appl added in v1.0.0

type Appl interface {
	// Contacts returns all contacts.
	// Errors: none.
	Contacts(Ctx, Auth) ([]Contact, error)
	// AddContact adds new contact.
	// Errors: ErrContactExists.
	AddContact(_ Ctx, _ Auth, name string) (*Contact, error)
}

Appl provides application features (use cases) service.

type Auth

type Auth struct {
	UserID string
}

Auth describes authentication.

type Contact

type Contact struct {
	ID   int
	Name string
}

Contact describes record in address book.

type Ctx

type Ctx = context.Context

Ctx is a synonym for convenience.

type MockAppl added in v1.0.0

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

MockAppl is a mock of Appl interface

func NewMockAppl added in v1.0.0

func NewMockAppl(ctrl *gomock.Controller) *MockAppl

NewMockAppl creates a new mock instance

func (*MockAppl) AddContact added in v1.0.0

func (m *MockAppl) AddContact(arg0 Ctx, arg1 Auth, name string) (*Contact, error)

AddContact mocks base method

func (*MockAppl) Contacts added in v1.0.0

func (m *MockAppl) Contacts(arg0 Ctx, arg1 Auth) ([]Contact, error)

Contacts mocks base method

func (*MockAppl) EXPECT added in v1.0.0

func (m *MockAppl) EXPECT() *MockApplMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

type MockApplMockRecorder added in v1.0.0

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

MockApplMockRecorder is the mock recorder for MockAppl

func (*MockApplMockRecorder) AddContact added in v1.0.0

func (mr *MockApplMockRecorder) AddContact(arg0, arg1, name interface{}) *gomock.Call

AddContact indicates an expected call of AddContact

func (*MockApplMockRecorder) Contacts added in v1.0.0

func (mr *MockApplMockRecorder) Contacts(arg0, arg1 interface{}) *gomock.Call

Contacts indicates an expected call of Contacts

type MockRepo added in v1.0.0

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

MockRepo is a mock of Repo interface

func NewMockRepo added in v1.0.0

func NewMockRepo(ctrl *gomock.Controller) *MockRepo

NewMockRepo creates a new mock instance

func (*MockRepo) AddContact added in v1.0.0

func (m *MockRepo) AddContact(arg0 Ctx, arg1 *Contact) error

AddContact mocks base method

func (*MockRepo) Contacts added in v1.0.0

func (m *MockRepo) Contacts(arg0 Ctx) ([]Contact, error)

Contacts mocks base method

func (*MockRepo) EXPECT added in v1.0.0

func (m *MockRepo) EXPECT() *MockRepoMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

type MockRepoMockRecorder added in v1.0.0

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

MockRepoMockRecorder is the mock recorder for MockRepo

func (*MockRepoMockRecorder) AddContact added in v1.0.0

func (mr *MockRepoMockRecorder) AddContact(arg0, arg1 interface{}) *gomock.Call

AddContact indicates an expected call of AddContact

func (*MockRepoMockRecorder) Contacts added in v1.0.0

func (mr *MockRepoMockRecorder) Contacts(arg0 interface{}) *gomock.Call

Contacts indicates an expected call of Contacts

type Repo added in v1.0.0

type Repo interface {
	// Contacts returns all contacts.
	// Errors: none.
	Contacts(Ctx) ([]Contact, error)
	// AddContact adds new contact and set ID.
	// Errors: ErrContactExists.
	AddContact(Ctx, *Contact) error
}

Repo provides data storage.

Jump to

Keyboard shortcuts

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