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: 24 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 MapDeviceToDeviceRead

func MapDeviceToDeviceRead(device *domain.Device) *storage.DeviceRead

MapDeviceToDeviceRead is used ...

func Message

func Message(errorCode string) string

Message translates error code to meaningful message

Types

type DeviceServer

type DeviceServer struct {
	DeviceEventRepo  repository.DeviceEventRepository
	DeviceReadRepo   repository.DeviceReadRepository
	DeviceEventQuery query.DeviceEventQuery
	DeviceReadQuery  query.DeviceReadQuery
	DeviceService    domain.DeviceService
	EventBus         eventbus.TaniaEventBus
}

DeviceServer ties the routes and handlers with injected dependencies

func NewDeviceServer

func NewDeviceServer(
	db *sql.DB,
	bus eventbus.TaniaEventBus,
	cropStorage *cropstorage.CropReadStorage,
	areaStorage *assetsstorage.AreaReadStorage,
	materialStorage *assetsstorage.MaterialReadStorage,
	deviceEventStorage *storage.DeviceEventStorage,
	deviceReadStorage *storage.DeviceReadStorage) (*DeviceServer, error)

NewDeviceServer initializes DeviceServer's dependencies and create new DeviceServer struct

func (*DeviceServer) AppendDeviceDomainDetails

func (s *DeviceServer) AppendDeviceDomainDetails(device *storage.DeviceRead) error

AppendDeviceDomainDetails is used ...

func (*DeviceServer) CreateDeviceDomainByCode

func (s *DeviceServer) CreateDeviceDomainByCode(domaincode string, c echo.Context) (domain.DeviceDomain, error)

CreateDeviceDomainByCode is used...

func (*DeviceServer) InitSubscriber

func (s *DeviceServer) InitSubscriber()

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

func (*DeviceServer) Mount

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

Mount defines the DeviceServer's endpoints with its handlers

func (*DeviceServer) SaveDevice

func (s *DeviceServer) SaveDevice(c echo.Context) error

SaveDevice is a DeviceServer's handler to save new Device

func (*DeviceServer) SaveToDeviceReadModel

func (s *DeviceServer) SaveToDeviceReadModel(event interface{}) error

SaveToDeviceReadModel is used ...

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

Jump to

Keyboard shortcuts

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