server

package
v0.0.0-...-ae75a06 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 28 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Required      = "REQUIRED"
	Alphanumeric  = "ALPHANUMERIC"
	Alpha         = "ALPHA"
	Numeric       = "NUMERIC"
	Float         = "FLOAT"
	ParseFailed   = "PARSE_FAILED"
	InvalidOption = "INVALID_OPTION"
	NotFound      = "NOT_FOUND"
)

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

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.TaskEvent
	TaskReadRepo   repository.TaskRead
	TaskEventQuery query.TaskEvent
	TaskReadQuery  query.TaskRead
	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

func (*TaskServer) CancelTask

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

func (*TaskServer) CompleteTask

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

func (*TaskServer) CreateTaskDomainByCode

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

func (TaskServer) FindAllTasks

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

func (TaskServer) FindFilteredTasks

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

func (*TaskServer) FindTaskByID

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

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

func (*TaskServer) SetTaskAsDue

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

func (*TaskServer) UpdateTask

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

Jump to

Keyboard shortcuts

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