// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
|
|
|
|
package container
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// 日志代理创建器
|
|
// @Implement LAPP_ACURA_MOM_BACKEND/container/CallerBrokerBuilder
|
|
type LogBrokerBuilder struct {
|
|
// 代码文件
|
|
codeFile string
|
|
// 服务方法
|
|
method string
|
|
// 描述
|
|
description string
|
|
}
|
|
|
|
// 创建日志代理创建器
|
|
// 参数:
|
|
// 1.代码文件
|
|
// 2.服务方法
|
|
// 3.描述
|
|
// 返回值:
|
|
// 1.日志代理创建器
|
|
// 异常:
|
|
// 1.方法名不能为空
|
|
func NewLogBrokerBuilder(codeFile string, method string, description string) *LogBrokerBuilder {
|
|
//if codeFile == "" {
|
|
// return nil, errors.New(fmt.Sprintf("方法类型不能为空!"))
|
|
//}
|
|
if method == "" {
|
|
panic(fmt.Sprintf("方法名不能为空!"))
|
|
}
|
|
//if description == "" {
|
|
// return nil, errors.New(fmt.Sprintf("方法类型不能为空!"))
|
|
//}
|
|
return &LogBrokerBuilder{codeFile, method, description}
|
|
}
|
|
|
|
// @Reference LAPP_ACURA_MOM_BACKEND/container/CallerBrokerBuilder.Check
|
|
func (builder *LogBrokerBuilder) Check(methodType Method) error {
|
|
if methodType == nil {
|
|
return errors.New(fmt.Sprintf("方法类型不能为空!"))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// @Reference LAPP_ACURA_MOM_BACKEND/container/CallerBrokerBuilder.Build
|
|
func (builder *LogBrokerBuilder) Build(_ *SessionContext, caller Caller) (Caller, error) {
|
|
if caller == nil {
|
|
return nil, errors.New(fmt.Sprintf("调用器不能为空!"))
|
|
}
|
|
return (&LogBroker{caller, builder.codeFile, builder.method, builder.description}).Call, nil
|
|
}
|