Help us shape the future of Go! Take the 2026 Go Developer Survey

app

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 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

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, cfg Config) *App

New creates and returns new 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, page SeekPage) ([]Contact, error)

func (*App) HealthCheck added in v1.2.0

func (a *App) HealthCheck(_ Ctx) (interface{}, error)

type Appl

type Appl interface {
	// HealthCheck returns error if service is unhealthy or current
	// status otherwise.
	// Errors: none.
	HealthCheck(Ctx) (interface{}, error)
	// Contacts returns all contacts.
	// Errors: none.
	Contacts(Ctx, Auth, SeekPage) ([]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 Config added in v1.4.0

type Config struct{}

Config contains configuration for business-logic.

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

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

MockAppl is a mock of Appl interface.

func NewMockAppl

func NewMockAppl(ctrl *gomock.Controller) *MockAppl

NewMockAppl creates a new mock instance.

func (*MockAppl) AddContact

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

AddContact mocks base method.

func (*MockAppl) Contacts

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

Contacts mocks base method.

func (*MockAppl) EXPECT

func (m *MockAppl) EXPECT() *MockApplMockRecorder

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

func (*MockAppl) HealthCheck added in v1.2.0

func (m *MockAppl) HealthCheck(arg0 Ctx) (interface{}, error)

HealthCheck mocks base method.

type MockApplMockRecorder

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

MockApplMockRecorder is the mock recorder for MockAppl.

func (*MockApplMockRecorder) AddContact

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

AddContact indicates an expected call of AddContact.

func (*MockApplMockRecorder) Contacts

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

Contacts indicates an expected call of Contacts.

func (*MockApplMockRecorder) HealthCheck added in v1.2.0

func (mr *MockApplMockRecorder) HealthCheck(arg0 interface{}) *gomock.Call

HealthCheck indicates an expected call of HealthCheck.

type MockRepo

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

MockRepo is a mock of Repo interface.

func NewMockRepo

func NewMockRepo(ctrl *gomock.Controller) *MockRepo

NewMockRepo creates a new mock instance.

func (*MockRepo) AddContact

func (m *MockRepo) AddContact(arg0 Ctx, name string) (int, error)

AddContact mocks base method.

func (*MockRepo) EXPECT

func (m *MockRepo) EXPECT() *MockRepoMockRecorder

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

func (*MockRepo) LstContacts added in v1.3.0

func (m *MockRepo) LstContacts(arg0 Ctx, arg1 SeekPage) ([]Contact, error)

LstContacts mocks base method.

type MockRepoMockRecorder

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

MockRepoMockRecorder is the mock recorder for MockRepo.

func (*MockRepoMockRecorder) AddContact

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

AddContact indicates an expected call of AddContact.

func (*MockRepoMockRecorder) LstContacts added in v1.3.0

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

LstContacts indicates an expected call of LstContacts.

type Repo

type Repo interface {
	// LstContacts returns up to limit contacts with ID > sinceID,
	// ordered by ID.
	// Errors: none.
	LstContacts(Ctx, SeekPage) ([]Contact, error)
	// AddContact adds new contact and returns it ID.
	// Errors: ErrContactExists.
	AddContact(_ Ctx, name string) (id int, err error)
}

Repo provides data storage.

type SeekPage added in v1.3.0

type SeekPage struct {
	SinceID int
	Limit   int
}

SeekPage describes seek pagination.

Jump to

Keyboard shortcuts

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