service

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package service holds service layer methods and repository/database abstractions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository added in v0.3.0

type Repository interface {
	FindUser(ctx context.Context, id string) (model.User, error)
	CreateUser(ctx context.Context, user model.User) (string, error)
	UpdateUser(ctx context.Context, user model.User) error
	DeleteUser(ctx context.Context, id string) error
	FindAllUsers(ctx context.Context, offset int64, limit int64) ([]model.User, error)
}

Repository abstracts the data access layer.

type Service

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

Service represents the user domain service layer.

func New added in v0.3.1

func New(repo Repository, timer Timer) *Service

New instantiates a Service

func (*Service) CreateUser added in v0.2.0

func (s *Service) CreateUser(ctx context.Context, user model.User) (model.User, error)

CreateUser - Creates a new user. Returns the created user or an error if anything fails.

func (*Service) DeleteUser added in v0.2.0

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

DeleteUser - Removes a user from the database. It returns an error if anything fails.

func (*Service) FindAllUsers added in v0.8.0

func (s *Service) FindAllUsers(ctx context.Context, offset int64, limit int64) ([]model.User, error)

FindAllUsers - Returns all users, for a given limit and offset

func (*Service) FindUser added in v0.2.0

func (s *Service) FindUser(ctx context.Context, id string) (model.User, error)

FindUser - Returns a new user for a given ID. Returns the user or an error if anything fails.

func (*Service) UpdateUser added in v0.2.0

func (s *Service) UpdateUser(ctx context.Context, id string, userUpdate request.UserUpdate) (model.User, error)

UpdateUser - Updates an existing user. It returns the updated user or returns an error if anything fails.

type Timer added in v0.6.0

type Timer interface {
	Now() time.Time
}

Timer abstraction layer for time operations.

Jump to

Keyboard shortcuts

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