application

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEntitiesFound = errors.New("no entities found")

ErrNoEntitiesFound occurs when fetching entities in the repository, none was returned. This is mainly used to decouple the error from any type of repository

View Source
var ErrNoRecordsFound = errors.New("no records found")

ErrNoRecordsFound occurs when fetching records in the repository, none was returned.

Functions

This section is empty.

Types

type Application

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

Application glues different layers of the service in order to perform actions

func NewApplication

func NewApplication(
	entityRepository EntityRepository,
	recordRepository RecordRepository,
	recordSanitizer domain.RecordSanitizer,
) (*Application, error)

NewApplication creates an instance of Application

func (*Application) CreateRecord added in v1.3.0

func (app *Application) CreateRecord(
	ctx context.Context,
	entity *domain.Entity,
	record *pubdomain.Record,
) (*pubdomain.Record, error)

CreateRecord creates a new record in the data store related to an entity

func (*Application) DeleteRecord added in v1.7.0

func (app *Application) DeleteRecord(
	ctx context.Context,
	entity *domain.Entity,
	recordId string,
) error

DeleteRecord deletes a record in the data store related to an entity

func (*Application) GetEntityByName

func (app *Application) GetEntityByName(ctx context.Context, entityId string) (*domain.Entity, error)

GetEntityByName returns an entity related to its name

func (*Application) GetRecord added in v1.5.0

func (app *Application) GetRecord(
	ctx context.Context,
	entity *domain.Entity,
	recordId string,
) (*pubdomain.Record, error)

GetRecord gets a record from the data store related to an entity

func (*Application) IsZero

func (app *Application) IsZero() bool

IsZero defines if the entity application is empty

func (*Application) ListRecords added in v1.9.0

func (app *Application) ListRecords(
	ctx context.Context,
	entity *domain.Entity,
	pager *pubdomain.Pager,
) ([]*pubdomain.Record, uint64, error)

ListRecords gets a record list from the data store related to an entity

func (*Application) UpdateRecord added in v1.6.0

func (app *Application) UpdateRecord(
	ctx context.Context,
	entity *domain.Entity,
	recordId string,
	partialRecord *pubdomain.Record,
) (*pubdomain.Record, error)

UpdateRecord updates a record in the data store related to an entity

type EntityRepository

type EntityRepository interface {
	// GetEntityByName returns one single entity defined by its name
	GetEntityByName(context.Context, string) (*domain.Entity, error)
}

EntityRepository defines the repository that stores, modifies and deletes entities in a data store or db

type RecordRepository added in v1.3.0

type RecordRepository interface {
	// CreateRecord creates a new record in the data store related to an entity
	CreateRecord(context.Context, *domain.Entity, *pubdomain.Record) (*pubdomain.Record, error)
	// GetRecord gets a record from the data store related to an entity
	GetRecord(context.Context, *domain.Entity, string) (*pubdomain.Record, error)
	// UpdateRecord updates a record in the data store related to an entity
	UpdateRecord(context.Context, *domain.Entity, string, *pubdomain.Record) (*pubdomain.Record, error)
	// DeleteRecord deletes a record in the data store related to an entity
	DeleteRecord(context.Context, *domain.Entity, string) error
	// ListRecords gets a record list from the data store related to an entity
	ListRecords(context.Context, *domain.Entity, *pubdomain.Pager) ([]*pubdomain.Record, error)
	// CountRecords returns the count of the records in the data store related to an entity
	CountRecords(context.Context, *domain.Entity) (uint64, error)
}

RecordRepository defines the repository that stores, modifies and deletes record in a data store or db

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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