import uuid
from datetime import datetime
from uuid import UUID

from pydantic import Field
from tacoq.core.models.avro_serializable_base_model import (
    AvroSerializableBaseModel,
    avro_schema_path,
)


@avro_schema_path("schemas/avro/task_running_update.json")
class TaskRunningUpdate(AvroSerializableBaseModel):
    """Update of a task starting execution by a worker."""

    id: UUID = Field(default_factory=uuid.uuid4)
    """The unique ID of the task. Generated by the client so that it can be 
    communicated to the relay and the workers directly."""

    started_at: datetime = Field(default_factory=lambda: datetime.now())
    """ The time the task was started at. """

    executed_by: str
    """ The name of the worker that is executing the task. """
