Documentation
¶
Index ¶
- func NewTreeService(repoTree storage.TreeRepository, repoSensor storage.SensorRepository, ...) service.TreeService
- type TreeService
- func (s *TreeService) Create(ctx context.Context, treeCreate *entities.TreeCreate) (*entities.Tree, error)
- func (s *TreeService) Delete(ctx context.Context, id int32) error
- func (s *TreeService) GetAll(ctx context.Context, query entities.TreeQuery) ([]*entities.Tree, int64, error)
- func (s *TreeService) GetByID(ctx context.Context, id int32) (*entities.Tree, error)
- func (s *TreeService) GetBySensorID(ctx context.Context, id string) (*entities.Tree, error)
- func (s *TreeService) HandleNewSensorData(ctx context.Context, event *entities.EventNewSensorData) error
- func (s *TreeService) Ready() bool
- func (s *TreeService) Update(ctx context.Context, id int32, tu *entities.TreeUpdate) (*entities.Tree, error)
- func (s *TreeService) UpdateWateringStatuses(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTreeService ¶
func NewTreeService( repoTree storage.TreeRepository, repoSensor storage.SensorRepository, treeClusterRepo storage.TreeClusterRepository, eventManager *worker.EventManager, ) service.TreeService
Types ¶
type TreeService ¶
type TreeService struct {
// contains filtered or unexported fields
}
func (*TreeService) Create ¶
func (s *TreeService) Create(ctx context.Context, treeCreate *entities.TreeCreate) (*entities.Tree, error)
func (*TreeService) GetBySensorID ¶
func (*TreeService) HandleNewSensorData ¶
func (s *TreeService) HandleNewSensorData(ctx context.Context, event *entities.EventNewSensorData) error
HandleNewSensorData processes new sensor data and updates the tree's watering status if necessary.
The function retrieves the tree associated with the given sensor ID, calculates the new watering status, and updates it if there is a change. If the status is updated, an update event is published.
Parameters:
- ctx: The request context, enabling logging and tracing.
- event: Contains the new sensor data, including the sensor ID and measured watermarks.
Returns:
- error: An error if updating the tree fails; otherwise, nil.
func (*TreeService) Ready ¶
func (s *TreeService) Ready() bool
func (*TreeService) Update ¶
func (s *TreeService) Update(ctx context.Context, id int32, tu *entities.TreeUpdate) (*entities.Tree, error)
func (*TreeService) UpdateWateringStatuses ¶
func (s *TreeService) UpdateWateringStatuses(ctx context.Context) error
Click to show internal directories.
Click to hide internal directories.