Fix rpc and workers separation 15/188715/6
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 7 Sep 2018 18:08:33 +0000 (20:08 +0200)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 17 Sep 2018 10:02:59 +0000 (12:02 +0200)
commit40ffff48d5b3094411486bebedf6e067e4a4bc9e
tree6cee0cbae7e699caec251a8e72121aa320817627
parentee11489c16e225fa7b95206e1938ca9feb841d7f
Fix rpc and workers separation

rpc package:

The rpc package should use Superviser interface for accessing workers,
but the implementation was based on direct access to WorkerList.
Tests also used methods not included in Superviser interface.

This patch fixes that, making rpc package independent of workers package.
It uses Superviser interface and MockSuperviser type for tests.

The test coverage of the rpc package has been increased
from 75.9% to 96.3% leaving only errors from net package's functions
not covered.

workers package:

All internal functions from workers package have been changed
to lowercase, unexported methods.

All exported methods are part of interfaces now:
* Superviser (used by Dryad through RPC calls):
 > Register
 > SetFail
* Workers (used by external HTTP clients):
 > SetState
 > SetGroups
 > Deregister
 > ListWorkers
 > GetWorkerInfo
* WorkersManager (used by higher internal layers (matcher, requests)):
 > GetWorkerSSHAddr
 > GetWorkerKey
 > TakeBestMatchingWorker
 > PrepareWorker
 > SetChangeListener

Change-Id: Ied9763b276ca02d05a904f4df2a7757a1892a772
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
rpc/superviser/reception.go
rpc/superviser/reception_test.go
workers/worker_list_test.go
workers/workers.go