4 - quickly accept incoming tasks,
5 - return the task result upon request
6 - if there is no result, return the appropriate status
/*
Processor - a service that performs a long, resource-intensive operation. It is already implemented
Errors it returns are exclusively related to incorrect input data, are stable, and re-requesting them is pointless
*/
type Processor interface {
Process([]byte) ([]byte, error)
}
/*
We assume that we have a generator of unique identifiers (for example, UUID).
The generator guarantees that there will be no collisions
*/
type ID string
// func NewID() ID
/*
Scheduler accepts tasks from clients, queues them, and starts processing.
Ensures that no more than 'threads' methods of process are running simultaneously
Provides the ability to check the task status and get the result
does not block its public interface methods for processing
*/
type Scheduler struct {
processor Processor
}
func NewScheduler(
prc Processor,
threads int,
) *Scheduler {
// todo initialization logic
return &Scheduler{
processor: prc,
}
}
func (s *Scheduler) Queue(request []byte) ID {
// todo implement
return ""
}