user

package
v0.0.0-...-0fe9a67 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package user is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Old, New interface{}
}

type Changes

type Changes map[string]Change

func (Changes) Add

func (cs Changes) Add(property string, o, n interface{})

type Entity

type Entity struct {
	FirstName string
	LastName  string
	Nickname  string
	Email     string
	Password  string
	Country   string
}

type MockStorage

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

MockStorage is a mock of Storage interface

func NewMockStorage

func NewMockStorage(ctrl *gomock.Controller) *MockStorage

NewMockStorage creates a new mock instance

func (*MockStorage) Delete

func (m *MockStorage) Delete(ctx context.Context, runner storage.Runner, id string) error

Delete mocks base method

func (*MockStorage) EXPECT

func (m *MockStorage) EXPECT() *MockStorageMockRecorder

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

func (*MockStorage) Persist

func (m *MockStorage) Persist(ctx context.Context, run storage.Runner, user storage.User) (string, error)

Persist mocks base method

func (*MockStorage) Retrieve

func (m *MockStorage) Retrieve(ctx context.Context, run storage.Runner, id string, forUpdate bool) (storage.User, error)

Retrieve mocks base method

func (*MockStorage) Update

func (m *MockStorage) Update(ctx context.Context, runner storage.Runner, id string, user storage.User) (storage.User, error)

Update mocks base method

func (*MockStorage) WithTx

func (m *MockStorage) WithTx(arg0 context.Context, arg1 func(storage.Runner) error) error

WithTx mocks base method

func (*MockStorage) WithoutTx

func (m *MockStorage) WithoutTx(arg0 context.Context, arg1 func(storage.Runner) error) error

WithoutTx mocks base method

type MockStorageMockRecorder

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

MockStorageMockRecorder is the mock recorder for MockStorage

func (*MockStorageMockRecorder) Delete

func (mr *MockStorageMockRecorder) Delete(ctx, runner, id interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockStorageMockRecorder) Persist

func (mr *MockStorageMockRecorder) Persist(ctx, run, user interface{}) *gomock.Call

Persist indicates an expected call of Persist

func (*MockStorageMockRecorder) Retrieve

func (mr *MockStorageMockRecorder) Retrieve(ctx, run, id, forUpdate interface{}) *gomock.Call

Retrieve indicates an expected call of Retrieve

func (*MockStorageMockRecorder) Update

func (mr *MockStorageMockRecorder) Update(ctx, runner, id, user interface{}) *gomock.Call

Update indicates an expected call of Update

func (*MockStorageMockRecorder) WithTx

func (mr *MockStorageMockRecorder) WithTx(arg0, arg1 interface{}) *gomock.Call

WithTx indicates an expected call of WithTx

func (*MockStorageMockRecorder) WithoutTx

func (mr *MockStorageMockRecorder) WithoutTx(arg0, arg1 interface{}) *gomock.Call

WithoutTx indicates an expected call of WithoutTx

type MockTransactioner

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

MockTransactioner is a mock of Transactioner interface

func NewMockTransactioner

func NewMockTransactioner(ctrl *gomock.Controller) *MockTransactioner

NewMockTransactioner creates a new mock instance

func (*MockTransactioner) EXPECT

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

func (*MockTransactioner) WithTx

func (m *MockTransactioner) WithTx(arg0 context.Context, arg1 func(storage.Runner) error) error

WithTx mocks base method

func (*MockTransactioner) WithoutTx

func (m *MockTransactioner) WithoutTx(arg0 context.Context, arg1 func(storage.Runner) error) error

WithoutTx mocks base method

type MockTransactionerMockRecorder

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

MockTransactionerMockRecorder is the mock recorder for MockTransactioner

func (*MockTransactionerMockRecorder) WithTx

func (mr *MockTransactionerMockRecorder) WithTx(arg0, arg1 interface{}) *gomock.Call

WithTx indicates an expected call of WithTx

func (*MockTransactionerMockRecorder) WithoutTx

func (mr *MockTransactionerMockRecorder) WithoutTx(arg0, arg1 interface{}) *gomock.Call

WithoutTx indicates an expected call of WithoutTx

type Service

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

Service allows to CRUD user entity. On each user modification it sends a notification about changes made to user entity.

func NewService

func NewService(storage Storage) *Service

NewService returns initialized user service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, user Entity) (string, error)

Create creates a new user entity and returns back its unique ID.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (Entity, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, user Entity) error

type Storage

type Storage interface {
	Transactioner
	// Persist saves the user and returns it's unique generated ID.
	// It returns an error in case email or nickname is not unique.
	Persist(ctx context.Context, run storage.Runner, user storage.User) (string, error)
	// Retrieve returns user by supplied 'id'.
	// If user doesn't exist it returns an error.
	Retrieve(ctx context.Context, run storage.Runner, id string, forUpdate bool) (storage.User, error)
	// Update updates properties of the existing user and returns entity with old values.
	// If user doesn't exist it returns an error.
	Update(ctx context.Context, runner storage.Runner, id string, user storage.User) (storage.User, error)
	// Delete deletes user entity by its identifier.
	Delete(ctx context.Context, runner storage.Runner, id string) error
}

Storage is a persistence storage for the user entity.

type Transactioner

type Transactioner interface {
	// WithTx executes provided callback inside of the transaction.
	// If callback returns an error the transaction will be rolled back, otherwise it will be committed.
	WithTx(context.Context, func(runner storage.Runner) error) error
	// WithoutTx executes provided callback without explicitly open transaction.
	WithoutTx(context.Context, func(runner storage.Runner) error) error
}

Transactioner executes statements with/without explicitly open transaction.

type ValidationError

type ValidationError struct {
	// Cause should be one of pre-defined standard errors.
	Cause error
	// Details any additional details about validation failure.
	Details map[string]interface{}
}

ValidationError encapsulates in it validation failure details.

func (ValidationError) Error

func (ve ValidationError) Error() string

func (ValidationError) Is

func (ve ValidationError) Is(err error) bool

Jump to

Keyboard shortcuts

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