Back to

Package server

Latest Go to latest

The highest tagged major version is .

Published: Dec 24, 2019 | License: Apache-2.0 | Module:



const (
	ALPHA          = "ALPHA"
	FLOAT          = "FLOAT"

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

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier