You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package container
  3. import (
  4. "errors"
  5. "fmt"
  6. )
  7. // 日志代理创建器
  8. // @Implement LAPP_LF_MOM_BACKEND/container/CallerBrokerBuilder
  9. type LogBrokerBuilder struct {
  10. // 代码文件
  11. codeFile string
  12. // 服务方法
  13. method string
  14. // 描述
  15. description string
  16. }
  17. // 创建日志代理创建器
  18. // 参数:
  19. // 1.代码文件
  20. // 2.服务方法
  21. // 3.描述
  22. // 返回值:
  23. // 1.日志代理创建器
  24. // 异常:
  25. // 1.方法名不能为空
  26. func NewLogBrokerBuilder(codeFile string, method string, description string) *LogBrokerBuilder {
  27. //if codeFile == "" {
  28. // return nil, errors.New(fmt.Sprintf("方法类型不能为空!"))
  29. //}
  30. if method == "" {
  31. panic(fmt.Sprintf("方法名不能为空!"))
  32. }
  33. //if description == "" {
  34. // return nil, errors.New(fmt.Sprintf("方法类型不能为空!"))
  35. //}
  36. return &LogBrokerBuilder{codeFile, method, description}
  37. }
  38. // @Reference LAPP_LF_MOM_BACKEND/container/CallerBrokerBuilder.Check
  39. func (builder *LogBrokerBuilder) Check(methodType Method) error {
  40. if methodType == nil {
  41. return errors.New(fmt.Sprintf("方法类型不能为空!"))
  42. }
  43. return nil
  44. }
  45. // @Reference LAPP_LF_MOM_BACKEND/container/CallerBrokerBuilder.Build
  46. func (builder *LogBrokerBuilder) Build(_ *SessionContext, caller Caller) (Caller, error) {
  47. if caller == nil {
  48. return nil, errors.New(fmt.Sprintf("调用器不能为空!"))
  49. }
  50. return (&LogBroker{caller, builder.codeFile, builder.method, builder.description}).Call, nil
  51. }