shorten

package
v0.0.0-...-82364ab Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package shorten is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	ID   int64
	URL  string
	Hash 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) ByHash

func (m *MockStorage) ByHash(ctx context.Context, runner storage.Runner, hash string) (shorten.Entity, error)

ByHash mocks base method

func (*MockStorage) Delete

func (m *MockStorage) Delete(ctx context.Context, runner storage.Runner, id int64) 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) List

func (m *MockStorage) List(ctx context.Context, run storage.Runner, pager shorten.Pager) ([]shorten.Entity, error)

List mocks base method

func (*MockStorage) Persist

func (m *MockStorage) Persist(ctx context.Context, run storage.Runner, shorten shorten.Entity) (int64, error)

Persist mocks base method

func (*MockStorage) Retrieve

func (m *MockStorage) Retrieve(ctx context.Context, run storage.Runner, id int64) (shorten.Entity, error)

Retrieve mocks base method

type MockStorageMockRecorder

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

MockStorageMockRecorder is the mock recorder for MockStorage

func (*MockStorageMockRecorder) ByHash

func (mr *MockStorageMockRecorder) ByHash(ctx, runner, hash interface{}) *gomock.Call

ByHash indicates an expected call of ByHash

func (*MockStorageMockRecorder) Delete

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

Delete indicates an expected call of Delete

func (*MockStorageMockRecorder) List

func (mr *MockStorageMockRecorder) List(ctx, run, pager interface{}) *gomock.Call

List indicates an expected call of List

func (*MockStorageMockRecorder) Persist

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

Persist indicates an expected call of Persist

func (*MockStorageMockRecorder) Retrieve

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

Retrieve indicates an expected call of Retrieve

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 Pager

type Pager = shorten.Pager

type Service

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

Service allows to CR_D shorten entity.

func NewService

func NewService(tr Transactioner, storage Storage) *Service

NewService returns initialized shorten service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, short Entity) (int64, error)

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

func (*Service) Delete

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

func (*Service) Get

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

func (*Service) List

func (s *Service) List(ctx context.Context, pager Pager) ([]Entity, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, hash string) (string, error)

type Storage

type Storage interface {
	// Persist saves the shorten and returns it's unique generated ID.
	Persist(ctx context.Context, run storage.Runner, shorten shorten.Entity) (int64, error)
	// Retrieve returns shorten by supplied 'id'.
	// If shorten doesn't exist it returns an error.
	Retrieve(ctx context.Context, run storage.Runner, id int64) (shorten.Entity, error)
	List(ctx context.Context, run storage.Runner, pager shorten.Pager) ([]shorten.Entity, error)
	// Delete deletes shorten entity by its identifier.
	Delete(ctx context.Context, runner storage.Runner, id int64) error
	// ByHash returns shorten by supplied 'hash'.
	ByHash(ctx context.Context, runner storage.Runner, hash string) (shorten.Entity, error)
}

Storage is a persistence storage for the shorten 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