2 * Copyright 2020 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 type TaskBaseIf interface {
21 OnRequest(data string) TaskCode
23 OnFork(wkSpace interface{}, param interface{}) int
24 GetErrCode() (ErrCode, string)
27 SetSerErrInfo(serErr *SerErrInfo)
30 type TaskBase struct {
38 func (t *TaskBase) WithName(name string) {
42 func (t *TaskBase) Parse(params string) {
43 t.Param = append(t.Param, params)
46 func (t *TaskBase) OnFork(wkSpace interface{}, param interface{}) int {
50 func (t *TaskBase) OnStop() int {
57 TaskFinish TaskCode = iota
62 func (t *TaskBase) OnRequest(wkSpace interface{}) TaskCode {
66 func (t *TaskBase) SetFirstErrorCode(code ErrCode, msg string) {
67 if t.resultCode > TaskOK {
74 func (t *TaskBase) GetErrCode() (ErrCode, string) {
75 return t.resultCode, t.errMsg
78 func (t *TaskBase) SetSerErrInfo(serErr *SerErrInfo) {
82 func (t *TaskBase) GetSerErrInfo() *SerErrInfo {
86 type StepMap map[string]interface{}
88 var StepData StepMap = StepMap{}
90 func NameMap(name string, obj interface{}, listenOn string) bool {