diff options
author | Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> | 2017-10-06 19:49:32 +0200 |
---|---|---|
committer | Lukasz Wojciechowski <l.wojciechow@partner.samsung.com> | 2018-04-27 17:34:20 +0200 |
commit | 1fceedd42bc6f61b2b151503421b3bc04e989b49 (patch) | |
tree | 6cb42c0bdfe905ed1481d6671cf88d1b4b2ab177 | |
parent | 86b502f77e01973d9c3e98c8b6c3e0591b7880e7 (diff) | |
download | boruta-1fceedd42bc6f61b2b151503421b3bc04e989b49.tar.gz boruta-1fceedd42bc6f61b2b151503421b3bc04e989b49.tar.bz2 boruta-1fceedd42bc6f61b2b151503421b3bc04e989b49.zip |
Add RequestsManager interface
RequestsManager interface defines API for taking actions
triggered by matcher events on requests structures.
The mock implementation of interface is provided in matcher package.
It is generated using mockgen command:
mockgen -package matcher \
-destination=matcher/requestsmanager_mock_test.go \
-write_package_comment=false \
git.tizen.org/tools/boruta/matcher RequestsManager
Change-Id: Idbf83988dba4cfa761dbfe8cae0a33d0a39245ac
Signed-off-by: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
-rw-r--r-- | matcher/requestsmanager.go | 51 | ||||
-rw-r--r-- | matcher/requestsmanager_mock_test.go | 130 |
2 files changed, 181 insertions, 0 deletions
diff --git a/matcher/requestsmanager.go b/matcher/requestsmanager.go new file mode 100644 index 0000000..4920166 --- /dev/null +++ b/matcher/requestsmanager.go @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +// File matcher/requestsmanager.go defines RequestManager interface with API +// for taking actions triggered by matcher events on requests structures. + +package matcher + +import ( + "time" + + . "git.tizen.org/tools/boruta" +) + +// RequestsManager interface defines API for internal boruta management of requests. +type RequestsManager interface { + // InitIteration starts iteration over requests pending in queue. + // Method returns error if iterations are already started and have not been + // terminated with TerminateIteration() + InitIteration() error + // TerminateIteration finishes iterating over requests formerly started with InitIteration. + TerminateIteration() + // Next gets next ID from request queue. + // Method returns {ID, true} if there is pending request + // or {ReqID(0), false} if queue's end has been reached. + Next() (ReqID, bool) + // VerifyIfReady checks if the request is ready to be run on worker. + VerifyIfReady(ReqID, time.Time) bool + // Get retrieves full request information or error if no request is found. + Get(ReqID) (ReqInfo, error) + // Timeout sets request to TIMEOUT state after Deadline time is exceeded. + Timeout(ReqID) error + // Close closes request setting it in DONE state, closing job + // and releasing worker after run time of the request has been exceeded. + Close(ReqID) error + // Run starts job performing the request on the worker. + Run(ReqID, WorkerUUID) error +} diff --git a/matcher/requestsmanager_mock_test.go b/matcher/requestsmanager_mock_test.go new file mode 100644 index 0000000..51a99ba --- /dev/null +++ b/matcher/requestsmanager_mock_test.go @@ -0,0 +1,130 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: git.tizen.org/tools/boruta/matcher (interfaces: RequestsManager) + +package matcher + +import ( + boruta "git.tizen.org/tools/boruta" + gomock "github.com/golang/mock/gomock" + reflect "reflect" + time "time" +) + +// MockRequestsManager is a mock of RequestsManager interface +type MockRequestsManager struct { + ctrl *gomock.Controller + recorder *MockRequestsManagerMockRecorder +} + +// MockRequestsManagerMockRecorder is the mock recorder for MockRequestsManager +type MockRequestsManagerMockRecorder struct { + mock *MockRequestsManager +} + +// NewMockRequestsManager creates a new mock instance +func NewMockRequestsManager(ctrl *gomock.Controller) *MockRequestsManager { + mock := &MockRequestsManager{ctrl: ctrl} + mock.recorder = &MockRequestsManagerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockRequestsManager) EXPECT() *MockRequestsManagerMockRecorder { + return m.recorder +} + +// Close mocks base method +func (m *MockRequestsManager) Close(arg0 boruta.ReqID) error { + ret := m.ctrl.Call(m, "Close", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close +func (mr *MockRequestsManagerMockRecorder) Close(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockRequestsManager)(nil).Close), arg0) +} + +// Get mocks base method +func (m *MockRequestsManager) Get(arg0 boruta.ReqID) (boruta.ReqInfo, error) { + ret := m.ctrl.Call(m, "Get", arg0) + ret0, _ := ret[0].(boruta.ReqInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get +func (mr *MockRequestsManagerMockRecorder) Get(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRequestsManager)(nil).Get), arg0) +} + +// InitIteration mocks base method +func (m *MockRequestsManager) InitIteration() error { + ret := m.ctrl.Call(m, "InitIteration") + ret0, _ := ret[0].(error) + return ret0 +} + +// InitIteration indicates an expected call of InitIteration +func (mr *MockRequestsManagerMockRecorder) InitIteration() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitIteration", reflect.TypeOf((*MockRequestsManager)(nil).InitIteration)) +} + +// Next mocks base method +func (m *MockRequestsManager) Next() (boruta.ReqID, bool) { + ret := m.ctrl.Call(m, "Next") + ret0, _ := ret[0].(boruta.ReqID) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + +// Next indicates an expected call of Next +func (mr *MockRequestsManagerMockRecorder) Next() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Next", reflect.TypeOf((*MockRequestsManager)(nil).Next)) +} + +// Run mocks base method +func (m *MockRequestsManager) Run(arg0 boruta.ReqID, arg1 boruta.WorkerUUID) error { + ret := m.ctrl.Call(m, "Run", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Run indicates an expected call of Run +func (mr *MockRequestsManagerMockRecorder) Run(arg0, arg1 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockRequestsManager)(nil).Run), arg0, arg1) +} + +// TerminateIteration mocks base method +func (m *MockRequestsManager) TerminateIteration() { + m.ctrl.Call(m, "TerminateIteration") +} + +// TerminateIteration indicates an expected call of TerminateIteration +func (mr *MockRequestsManagerMockRecorder) TerminateIteration() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TerminateIteration", reflect.TypeOf((*MockRequestsManager)(nil).TerminateIteration)) +} + +// Timeout mocks base method +func (m *MockRequestsManager) Timeout(arg0 boruta.ReqID) error { + ret := m.ctrl.Call(m, "Timeout", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Timeout indicates an expected call of Timeout +func (mr *MockRequestsManagerMockRecorder) Timeout(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Timeout", reflect.TypeOf((*MockRequestsManager)(nil).Timeout), arg0) +} + +// VerifyIfReady mocks base method +func (m *MockRequestsManager) VerifyIfReady(arg0 boruta.ReqID, arg1 time.Time) bool { + ret := m.ctrl.Call(m, "VerifyIfReady", arg0, arg1) + ret0, _ := ret[0].(bool) + return ret0 +} + +// VerifyIfReady indicates an expected call of VerifyIfReady +func (mr *MockRequestsManagerMockRecorder) VerifyIfReady(arg0, arg1 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyIfReady", reflect.TypeOf((*MockRequestsManager)(nil).VerifyIfReady), arg0, arg1) +} |