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 ¶
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 ¶
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.