Change Set methods in Requests interface
authorMaciej Wereski <m.wereski@partner.samsung.com>
Wed, 4 Oct 2017 10:40:09 +0000 (12:40 +0200)
committerMaciej Wereski <m.wereski@partner.samsung.com>
Thu, 12 Oct 2017 16:44:17 +0000 (18:44 +0200)
One UpdateRequest() public method is introduced instead of three Set
methods. Also Priority values are shifted by one. This will be required
to check if user has set Priority field (which takes zero value when it
wasn't set).

Change-Id: I2be2573edb93cb4a70f7f155786e6a18ba520270
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
Reviewed-on: https://mcdsrvbld02.digital.local/review/49545
Reviewed-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
Tested-by: Aleksander Mistewicz <a.mistewicz@samsung.com>
boruta.go
requests/queue_test.go

index 898cc81..8e1eb6d 100644 (file)
--- a/boruta.go
+++ b/boruta.go
@@ -72,9 +72,9 @@ type Priority uint8
 
 const (
        // HiPrio - most important priority (minimum value).
-       HiPrio Priority = 0
+       HiPrio Priority = 1
        // LoPrio - least important priority (maximum value).
-       LoPrio Priority = 15
+       LoPrio Priority = 16
 )
 
 // UserInfo is a definition of the User or the Admin.
@@ -139,12 +139,9 @@ type Requests interface {
        // CloseRequest sets the Request's State to CANCEL (removes from the Queue)
        // or DONE (finishes the Job).
        CloseRequest(reqID ReqID) error
-       // SetRequestPriority sets the Request's Priority after it has been created.
-       SetRequestPriority(reqID ReqID, priority Priority) error
-       // SetRequestValidAfter sets the Request's ValidAfter after it has been created.
-       SetRequestValidAfter(reqID ReqID, validAfter time.Time) error
-       // SetRequestDeadline sets the Request's Deadline after it has been created.
-       SetRequestDeadline(reqID ReqID, deadline time.Time) error
+       // UpdateRequest modifies existing request. Request can be modified only
+       // when it is in WAIT state.
+       UpdateRequest(reqInfo *ReqInfo) error
        // GetRequestInfo returns ReqInfo associated with ReqID.
        GetRequestInfo(reqID ReqID) (ReqInfo, error)
        // ListRequests returns ReqInfo matching the filter
index 2359d5a..b758bc4 100644 (file)
@@ -37,11 +37,11 @@ func TestQueue(t *testing.T) {
                pr Priority
        }{
                {ReqID(1), Priority(7)},
-               {ReqID(2), Priority(0)},
-               {ReqID(3), Priority(1)},
+               {ReqID(2), Priority(1)},
+               {ReqID(3), Priority(2)},
                {ReqID(4), Priority(12)},
-               {ReqID(5), Priority(2)},
-               {ReqID(6), Priority(2)},
+               {ReqID(5), Priority(3)},
+               {ReqID(6), Priority(3)},
        }
        sorted := []ReqID{ReqID(2), ReqID(3), ReqID(5), ReqID(6), ReqID(1), ReqID(4)}