ReCodEx - Task Broker
ReCodEx is complex programmer testing solution, primary targeted to technical universities. It's highly customizable and based on modern technologies.
worker_registry Class Reference

#include <worker_registry.h>

Public Types

typedef std::shared_ptr< workerworker_ptr
 

Public Member Functions

 worker_registry ()
 
virtual void add_worker (worker_ptr worker)
 
virtual void remove_worker (worker_ptr worker)
 
virtual worker_ptr find_worker (const request::headers_t &headers)
 
virtual worker_ptr find_worker_by_identity (const std::string &identity)
 
virtual void deprioritize_worker (worker_ptr worker)
 
virtual const std::vector< worker_ptr > & get_workers () const
 

Detailed Description

Service that stores information about worker machines and routes tasks to them.

Definition at line 14 of file worker_registry.h.

Member Typedef Documentation

§ worker_ptr

typedef std::shared_ptr<worker> worker_registry::worker_ptr

Pointer to worker instance type.

Definition at line 18 of file worker_registry.h.

Constructor & Destructor Documentation

§ worker_registry()

worker_registry::worker_registry ( )

Default constructor, initializes empty list of workers.

Definition at line 6 of file worker_registry.cpp.

Member Function Documentation

§ add_worker()

void worker_registry::add_worker ( worker_ptr  worker)
virtual

Adds new worker to the registry.

Parameters
workerWorker instance to be added.

Definition at line 10 of file worker_registry.cpp.

§ deprioritize_worker()

void worker_registry::deprioritize_worker ( worker_registry::worker_ptr  worker)
virtual

Reduce the priority of a worker so that it's less likely to be found by subsequent finds. Now it means change order in worker queue to the last position, so most of the finds will succeed earlier.

Parameters
workerInstance of worker whose priority will be lowered.

Definition at line 55 of file worker_registry.cpp.

§ find_worker()

worker_registry::worker_ptr worker_registry::find_worker ( const request::headers_t headers)
virtual

Find suitable worker on the basis of request headers.

Parameters
headersReqeust headers which we want to be fulfiled by any worker.
Returns
Instance to first suitable worker found or nullptr.

Definition at line 24 of file worker_registry.cpp.

§ find_worker_by_identity()

worker_registry::worker_ptr worker_registry::find_worker_by_identity ( const std::string &  identity)
virtual

Find worker by it's unique identifier.

Parameters
identityID of worker we want to get instance.
Returns
Instance of worker with given ID or nullptr.

Definition at line 44 of file worker_registry.cpp.

§ get_workers()

const std::vector< worker_registry::worker_ptr > & worker_registry::get_workers ( ) const
virtual

Get all workers known to this service.

Returns
Collection of all known workers.

Definition at line 65 of file worker_registry.cpp.

§ remove_worker()

void worker_registry::remove_worker ( worker_ptr  worker)
virtual

Remove worker from registry, for example when connection is lost.

Parameters
workerWorker instance to be removed.

Definition at line 15 of file worker_registry.cpp.


The documentation for this class was generated from the following files: