tree

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

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) Delete

func (s *TreeService) Delete(ctx context.Context, id int32) error

func (*TreeService) GetAll

func (s *TreeService) GetAll(ctx context.Context, query entities.TreeQuery) ([]*entities.Tree, int64, error)

func (*TreeService) GetByID

func (s *TreeService) GetByID(ctx context.Context, id int32) (*entities.Tree, error)

func (*TreeService) GetBySensorID

func (s *TreeService) GetBySensorID(ctx context.Context, id string) (*entities.Tree, error)

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

Jump to

Keyboard shortcuts

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