summaryrefslogtreecommitdiff
path: root/boruta.go
diff options
context:
space:
mode:
authorMaciej Wereski <m.wereski@partner.samsung.com>2017-09-12 12:56:20 +0200
committerMaciej Wereski <m.wereski@partner.samsung.com>2017-09-13 17:07:08 +0200
commit1e85a24b8cc48946d8d5443140d0bd074276dc01 (patch)
treed0e3501ba0b8d492f1aab1d119698cf123d69bcb /boruta.go
parent1fd7dc73861fcd2753e9478c6c37dbeae8bf56d0 (diff)
downloadboruta-1e85a24b8cc48946d8d5443140d0bd074276dc01.tar.gz
boruta-1e85a24b8cc48946d8d5443140d0bd074276dc01.tar.bz2
boruta-1e85a24b8cc48946d8d5443140d0bd074276dc01.zip
Rework interfaces definitions
Current methods division between interfaces is done in a way that causes situation where no package implements full interface. This change fixes this situation. Change-Id: Ifcfba7d740c86e853410b71da954810ceaf813f3 Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com> Reviewed-on: https://mcdsrvbld02.digital.local/review/49448 Reviewed-by: Aleksander Mistewicz <a.mistewicz@samsung.com> Tested-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Diffstat (limited to 'boruta.go')
-rw-r--r--boruta.go32
1 files changed, 18 insertions, 14 deletions
diff --git a/boruta.go b/boruta.go
index 5b320b6..90d34e4 100644
--- a/boruta.go
+++ b/boruta.go
@@ -120,8 +120,8 @@ type WorkerInfo struct {
// ListFilter is used to filter Requests in the Queue.
type ListFilter struct{}
-// User defines an interaction of the User with the Queue.
-type User interface {
+// Requests defines an interaction of a user with Requests Queue.
+type Requests interface {
// NewRequest creates a Request with given features and adds it to the Queue.
// It returns ID of the created Request.
NewRequest(caps Capabilities, priority Priority, owner UserInfo,
@@ -148,15 +148,10 @@ type User interface {
// ProlongAccess sets the Job's Deadline to a predefined time.Duration from the time.Now().
// It can be called multiple times, but is limited.
ProlongAccess(reqID ReqID) error
- // ListWorkers returns a list of all Workers matching Groups and Capabilities
- // or all registered Workers if both arguments are empty.
- ListWorkers(groups Groups, caps Capabilities) ([]WorkerInfo, error)
- // GetWorkerInfo returns WorkerInfo of specified worker.
- GetWorkerInfo(uuid WorkerUUID) (WorkerInfo, error)
}
-// Worker defines actions that can be done by Worker only.
-type Worker interface {
+// Superviser defines registration and repost actions that can be done by a worker only.
+type Superviser interface {
// Register adds a new Worker to the system in the MAINTENANCE state.
// Capabilities are set on the Worker and can be changed by subsequent Register calls.
Register(caps Capabilities) error
@@ -165,8 +160,17 @@ type Worker interface {
SetFail(uuid WorkerUUID, reason string) error
}
-// Admin is responsible for management of the Workers.
-type Admin interface {
+// Workers defines all actions that can be done by users and admins on workers.
+// Users (and admins) can also call methods from Requests interface.
+type Workers interface {
+ // ListWorkers returns a list of all Workers matching Groups and Capabilities
+ // or all registered Workers if both arguments are empty.
+ ListWorkers(groups Groups, caps Capabilities) ([]WorkerInfo, error)
+ // GetWorkerInfo returns WorkerInfo of specified worker.
+ GetWorkerInfo(uuid WorkerUUID) (WorkerInfo, error)
+
+ // Following methods are for administrators only.
+
// SetState sets the Worker's state to either MAINTENANCE or IDLE.
SetState(uuid WorkerUUID, state WorkerState) error
// SetGroups updates the groups parameter of the Worker.
@@ -179,7 +183,7 @@ type Admin interface {
// Server combines all interfaces for regular Users, Admins and Workers
// It can also implement HTTP API.
type Server interface {
- User
- Worker
- Admin
+ Requests
+ Superviser
+ Workers
}