Documentation ¶
Index ¶
- func Error(c echo.Context, err error) error
- func MapDeviceToDeviceRead(device *domain.Device) *storage.DeviceRead
- func Message(errorCode string) string
- type DeviceServer
- func (s *DeviceServer) AppendDeviceDomainDetails(device *storage.DeviceRead) error
- func (s *DeviceServer) CreateDeviceDomainByCode(domaincode string, c echo.Context) (domain.DeviceDomain, error)
- func (s *DeviceServer) InitSubscriber()
- func (s *DeviceServer) Mount(g *echo.Group)
- func (s *DeviceServer) SaveDevice(c echo.Context) error
- func (s *DeviceServer) SaveToDeviceReadModel(event interface{}) error
- type RequestValidation
- type RequestValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func 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 ...
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