service

package
v0.0.0-...-c3afde3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package service defines the business logic of the requirement. The general flow of the requirements are explicitly stated in the code.

Index

Constants

View Source
const (

	// DefaultGetAllUsersLimit is deliberately set to 10 because it is enough for simple application.
	DefaultGetAllUsersLimit = uint(defaultLimit)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteUser

type DeleteUser interface {
	// HardDelete hard-deletes all users.
	HardDelete(ctx context.Context, id string) error
}

DeleteUser defines the interface to delete a user.

type DeleteUserProvider

type DeleteUserProvider interface {
	// HardDelete hard-deletes a single user from the provider.
	// If the user can't be found, it doesn't return error.
	HardDelete(ctx context.Context, id string) error
}

DeleteUserProvider defines the interface to delete user from the provider.

type DeleteUserRepository

type DeleteUserRepository interface {
	// GetByID gets a user by ID.
	GetByID(ctx context.Context, id string) (*entity.User, error)
	// HardDeleteWithTx hard-deletes a single user from the repository using transaction.
	// If the user can't be found, it doesn't return error.
	HardDeleteWithTx(ctx context.Context, tx uow.Tx, id string) error
}

DeleteUserRepository defines interface to delete user from repository.

type GetUser

type GetUser interface {
	// GetAll gets all users.
	GetAll(ctx context.Context, limit uint) ([]*entity.User, error)
}

GetUser defines the interface to get user.

type GetUserRepository

type GetUserRepository interface {
	// GetAll gets all users available in repository.
	// If there isn't any user in repository, it returns empty list of user and nil error.
	GetAll(ctx context.Context, limit uint) ([]*entity.User, error)
}

GetUserRepository defines the interface to get user from the repository.

type RegisterUser

type RegisterUser interface {
	// Register registers a user and store it in the storage.
	// It returns the ID of the newly created user.
	// It must check the uniqueness of the user.
	Register(ctx context.Context, user *entity.User) (string, error)
}

RegisterUser defines the interface to register a user.

type RegisterUserOutboxRepository

type RegisterUserOutboxRepository interface {
	// InsertWithTx inserts user outbox to repository using transaction.
	InsertWithTx(ctx context.Context, tx uow.Tx, payload *entity.UserOutbox) error
}

RegisterUserOutboxRepository defines interface to register user outbox to repository.

type RegisterUserRepository

type RegisterUserRepository interface {
	// InsertWithTx inserts user to repository using transaction.
	InsertWithTx(ctx context.Context, tx uow.Tx, user *entity.User) error
}

RegisterUserRepository defines interface to register user to repository.

type RelayRegisterUser

type RelayRegisterUser interface {
	// RelayRegister relays user registration.
	RelayRegister(ctx context.Context, user *entity.UserOutbox) (string, error)
}

RelayRegisterUser defines the interface to relay the user registration.

type RelayRegisterUserOrchestration

type RelayRegisterUserOrchestration interface {
	// RegisterUser registers the user into the repository or 3rd party needed.
	// It also validates if the user's email is unique.
	// It returns the ID of the created user.
	RegisterUser(ctx context.Context, input *entity.RegisterUserInput) (*entity.RegisterUserOutput, error)
}

RelayRegisterUserOrchestration defines the interface to orchestrate user registration.

type RelayRegisterUserOutboxRepository

type RelayRegisterUserOutboxRepository interface {
	// GetAllReady gets all ready records.
	GetAllReady(ctx context.Context, limit uint) ([]*entity.UserOutbox, error)
	// SetProcessed sets record as processed.
	SetProcessed(ctx context.Context, id string) error
	// SetDelivered sets record as delivered.
	SetDelivered(ctx context.Context, id string) error
	// SetFailed sets record as failed.
	SetFailed(ctx context.Context, id string) error
}

RelayRegisterUserOutboxRepository defines interface to register user outbox to repository.

type UserDeleter

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

UserDeleter is responsible for deleting a user.

func NewUserDeleter

NewUserDeleter creates an instance of UserDeleter.

func (*UserDeleter) HardDelete

func (td *UserDeleter) HardDelete(ctx context.Context, id string) error

HardDelete hard-deletes a user in system.

type UserGetter

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

UserGetter is responsible for getting user.

func NewUserGetter

func NewUserGetter(repo GetUserRepository) *UserGetter

NewUserGetter creates an instance of UserGetter.

func (*UserGetter) GetAll

func (ug *UserGetter) GetAll(ctx context.Context, limit uint) ([]*entity.User, error)

GetAll gets all users available in repository. If there isn't any user in repository, it returns empty list of user and nil error.

type UserRegistrar

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

UserRegistrar is responsible for registering a new user.

func NewUserRegistrar

NewUserRegistrar creates an instance of UserRegistrar.

func (*UserRegistrar) Register

func (ur *UserRegistrar) Register(ctx context.Context, user *entity.User) (string, error)

Register registers a user and store it in the storage. It returns the ID of the newly created user. It checks the email for duplication.

type UserRelayRegistrar

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

UserRelayRegistrar is responsible for registering a new user.

func NewUserRelayRegistrar

NewUserRelayRegistrar creates an instance of UserRelayRegistrar.

func (*UserRelayRegistrar) Register

func (ur *UserRelayRegistrar) Register(ctx context.Context) error

Register registers a user and store it in the storage. It returns the ID of the newly created user. It checks the email for duplication.

Jump to

Keyboard shortcuts

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