server

package
v0.0.0-...-87346ed Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(c echo.Context, err error) error

Error wraps errors from application layer and domain layer to some format in JSON for response

func MapTaskToTaskRead

func MapTaskToTaskRead(task *domain.Task) *storage.TaskRead

MapTaskToTaskRead is used ...

func Message

func Message(errorCode string) string

Message translates error code to meaningful message

Types

type RequestValidation

type RequestValidation struct {
}

RequestValidation sanitizes request inputs and convert the input to its correct data type. This is mostly used to prevent issues like invalid data type or potential SQL Injection. So we can focus on processing data without converting data type after this sanitizing. This validation doesn't aim to validate business process. The business process validation will be handled in each entity's behaviour.

type RequestValidationError

type RequestValidationError struct {
	FieldName    string `json:"field_name"`
	ErrorCode    string `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

RequestValidationError contains fields used for JSON error response

func NewRequestValidationError

func NewRequestValidationError(errorCode, fieldName string) RequestValidationError

NewRequestValidationError initializes new RequestValidation struct

func (RequestValidationError) Error

func (rve RequestValidationError) Error() string

type TaskServer

type TaskServer struct {
	TaskEventRepo  repository.TaskEventRepository
	TaskReadRepo   repository.TaskReadRepository
	TaskEventQuery query.TaskEventQuery
	TaskReadQuery  query.TaskReadQuery
	TaskService    domain.TaskService
	EventBus       eventbus.TaniaEventBus
}

TaskServer ties the routes and handlers with injected dependencies

func NewTaskServer

func NewTaskServer(
	db *sql.DB,
	bus eventbus.TaniaEventBus,
	cropStorage *cropstorage.CropReadStorage,
	areaStorage *assetsstorage.AreaReadStorage,
	materialStorage *assetsstorage.MaterialReadStorage,
	reservoirStorage *assetsstorage.ReservoirReadStorage,
	taskEventStorage *storage.TaskEventStorage,
	taskReadStorage *storage.TaskReadStorage) (*TaskServer, error)

NewTaskServer initializes TaskServer's dependencies and create new TaskServer struct

func (*TaskServer) AppendTaskDomainDetails

func (s *TaskServer) AppendTaskDomainDetails(task *storage.TaskRead) error

AppendTaskDomainDetails is used ...

func (*TaskServer) CancelTask

func (s *TaskServer) CancelTask(c echo.Context) error

CancelTask is used ...

func (*TaskServer) CompleteTask

func (s *TaskServer) CompleteTask(c echo.Context) error

CompleteTask is used ...

func (*TaskServer) CreateTaskDomainByCode

func (s *TaskServer) CreateTaskDomainByCode(domaincode string, c echo.Context) (domain.TaskDomain, error)

CreateTaskDomainByCode is used ...

func (TaskServer) FindAllTasks

func (s TaskServer) FindAllTasks(c echo.Context) error

FindAllTasks is used

func (TaskServer) FindFilteredTasks

func (s TaskServer) FindFilteredTasks(c echo.Context) error

FindFilteredTasks is used ...

func (*TaskServer) FindTaskByID

func (s *TaskServer) FindTaskByID(c echo.Context) error

FindTaskByID is used ...

func (*TaskServer) InitSubscriber

func (s *TaskServer) InitSubscriber()

InitSubscriber defines the mapping of which event this domain listen with their handler

func (*TaskServer) Mount

func (s *TaskServer) Mount(g *echo.Group)

Mount defines the TaskServer's endpoints with its handlers

func (*TaskServer) SaveTask

func (s *TaskServer) SaveTask(c echo.Context) error

SaveTask is a TaskServer's handler to save new Task

func (*TaskServer) SaveToTaskReadModel

func (s *TaskServer) SaveToTaskReadModel(event interface{}) error

SaveToTaskReadModel is used ...

func (*TaskServer) SetTaskAsDue

func (s *TaskServer) SetTaskAsDue(c echo.Context) error

SetTaskAsDue is used ...

func (*TaskServer) UpdateTask

func (s *TaskServer) UpdateTask(c echo.Context) error

UpdateTask is used ...

Jump to

Keyboard shortcuts

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