employees

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmployeeExists

func IsEmployeeExists(ctx context.Context, employeeID int, repo repository.EmployeeRepoIface) (bool, models.Employee)

IsEmployeeExists checks if an employee with the given ID exists in the repository.

func ValidateEmployee

func ValidateEmployee(email, phone string) (bool, bool)

ValidateEmployee validates the email and phone number of an employee.

Types

type Staff

type Staff struct {
	// contains filtered or unexported fields
}

Staff represents an employee service that manages employee-related operations. It contains a logger for logging, a repository interface for data access, metrics for performance monitoring, a client for external service communication, and a last known hash for tracking state.

func NewStaff

func NewStaff(
	log *slog.Logger,
	repo repository.EmployeeRepoIface,
	metrics *metrics.Metrics,
	hermesClient pb.ScraperServiceClient,
	adminIdentifier string,
) *Staff

NewStaff creates a new instance of Staff with the provided logger, employee repository, metrics, and Hermes client.

Parameters:

  • log: A logger for logging purposes.
  • repo: An interface for employee repository operations.
  • metrics: A metrics object for tracking performance.
  • hermesClient: A client for interacting with the ScraperService.

Returns:

A pointer to the newly created Staff instance.

func (*Staff) ProcessEmployee

func (s *Staff) ProcessEmployee(pctx context.Context) error

ProcessEmployee retrieves employee data from the Hermes service, processes the data, and updates the local repository with new or modified employee records. It uses a context with a timeout to ensure that the operation does not run indefinitely. If no new employee data is found, it logs the information and updates the last known hash. In case of errors during the retrieval or processing of employee data, it returns an error with relevant details. Metrics are recorded for success and failure cases.

func (*Staff) Ready added in v1.3.2

func (s *Staff) Ready() <-chan struct{}

Ready returns a channel that will be closed when the initial employee synchronization is complete. This allows other services to wait for employees to be loaded before starting their own initialization.

func (*Staff) Start

func (s *Staff) Start(ctx context.Context, interval time.Duration) error

Start executes the staff service logic by fetching employees, validating their email addresses, and either updating existing employees or saving new ones to the repository.

Jump to

Keyboard shortcuts

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