From: Lukasz Wojciechowski Date: Fri, 27 Oct 2017 18:39:23 +0000 (+0200) Subject: Add JobsManager interface X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06115172a441a253cd8c636b3245bca61d92ec20;p=tools%2Fboruta.git Add JobsManager interface JobsManager interface defines API for taking actions on jobs. The mock implementation of interface is provided in matcher package. It is generated using mockgen command: mockgen -package matcher \ -destination=matcher/jobsmanager_mock_test.go \ -write_package_comment=false \ git.tizen.org/tools/boruta/matcher JobsManager Change-Id: I950b68cbadd2a2e7be3d65406d36082d6ac29ee4 Signed-off-by: Lukasz Wojciechowski --- diff --git a/matcher/jobsmanager.go b/matcher/jobsmanager.go new file mode 100644 index 0000000..1af346f --- /dev/null +++ b/matcher/jobsmanager.go @@ -0,0 +1,36 @@ +/* + * 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/jobsmanager.go defines JobsManager interface with API +// for managing jobs. + +package matcher + +import ( + . "git.tizen.org/tools/boruta" + "git.tizen.org/tools/boruta/workers" +) + +// JobsManager defines API for internal boruta management of jobs. +type JobsManager interface { + // Create prepares a new job for the worker. + Create(ReqID, WorkerUUID) error + // Get returns pointer to a Job from JobsManager or error if no job for + // the worker is found. + Get(WorkerUUID) (*workers.Job, error) + // Finish cleans up after job is done. + Finish(WorkerUUID) error +} diff --git a/matcher/jobsmanager_mock_test.go b/matcher/jobsmanager_mock_test.go new file mode 100644 index 0000000..b125ab9 --- /dev/null +++ b/matcher/jobsmanager_mock_test.go @@ -0,0 +1,71 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: git.tizen.org/tools/boruta/matcher (interfaces: JobsManager) + +package matcher + +import ( + boruta "git.tizen.org/tools/boruta" + workers "git.tizen.org/tools/boruta/workers" + gomock "github.com/golang/mock/gomock" + reflect "reflect" +) + +// MockJobsManager is a mock of JobsManager interface +type MockJobsManager struct { + ctrl *gomock.Controller + recorder *MockJobsManagerMockRecorder +} + +// MockJobsManagerMockRecorder is the mock recorder for MockJobsManager +type MockJobsManagerMockRecorder struct { + mock *MockJobsManager +} + +// NewMockJobsManager creates a new mock instance +func NewMockJobsManager(ctrl *gomock.Controller) *MockJobsManager { + mock := &MockJobsManager{ctrl: ctrl} + mock.recorder = &MockJobsManagerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockJobsManager) EXPECT() *MockJobsManagerMockRecorder { + return m.recorder +} + +// Create mocks base method +func (m *MockJobsManager) Create(arg0 boruta.ReqID, arg1 boruta.WorkerUUID) error { + ret := m.ctrl.Call(m, "Create", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Create indicates an expected call of Create +func (mr *MockJobsManagerMockRecorder) Create(arg0, arg1 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockJobsManager)(nil).Create), arg0, arg1) +} + +// Finish mocks base method +func (m *MockJobsManager) Finish(arg0 boruta.WorkerUUID) error { + ret := m.ctrl.Call(m, "Finish", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Finish indicates an expected call of Finish +func (mr *MockJobsManagerMockRecorder) Finish(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Finish", reflect.TypeOf((*MockJobsManager)(nil).Finish), arg0) +} + +// Get mocks base method +func (m *MockJobsManager) Get(arg0 boruta.WorkerUUID) (*workers.Job, error) { + ret := m.ctrl.Call(m, "Get", arg0) + ret0, _ := ret[0].(*workers.Job) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get +func (mr *MockJobsManagerMockRecorder) Get(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockJobsManager)(nil).Get), arg0) +} diff --git a/workers/job.go b/workers/job.go new file mode 100644 index 0000000..b8ef4c3 --- /dev/null +++ b/workers/job.go @@ -0,0 +1,33 @@ +/* + * 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 + */ + +package workers + +import ( + . "git.tizen.org/tools/boruta" + "git.tizen.org/tools/boruta/tunnels" +) + +// Job describes worker job. +type Job struct { + // Access describes details of the connection to Dryad. It is returned to the request + // owner when a job for request is run and acquired by the user. + Access AccessInfo + // Tunnel is a connection to Dryad for the user. + Tunnel tunnels.Tunneler + // Req is ID of the worked request. + Req ReqID +}