grpc.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package model
  2. import "go-common/library/time"
  3. // GRPCQuickStartRequest GRPCModel grpc models
  4. type GRPCQuickStartRequest struct {
  5. GRPCAddScriptRequest
  6. }
  7. // GRPCAddScriptRequest GRPC Add Script Request
  8. type GRPCAddScriptRequest struct {
  9. TaskName string `json:"task_name"`
  10. Department string `json:"department"`
  11. Project string `json:"project"`
  12. APP string `json:"app"`
  13. Active int `json:"active"`
  14. HostName string `json:"host_name,"`
  15. Port int `json:"port"`
  16. ServiceName string `json:"service_name"`
  17. ProtoClassName string `json:"proto_class_name"`
  18. PkgPath string `json:"pkg_path"`
  19. AsynCall int `json:"asyn_call"`
  20. RequestType string `json:"request_type"`
  21. RequestMethod string `json:"request_method"`
  22. RequestContent string `json:"request_content"`
  23. ResponseType string `json:"response_type"`
  24. ScriptPath string `json:"script_path"`
  25. JarPath string `json:"jar_path"`
  26. ThreadsSum int `json:"threads_sum"`
  27. RampUp int `json:"ramp_up"`
  28. Loops int `json:"loops"`
  29. LoadTime int `json:"load_time"`
  30. UpdateBy string `json:"update_by"`
  31. Ctime time.Time `json:"ctime"`
  32. Mtime time.Time `json:"mtime"`
  33. IsDebug int `json:"is_debug" gorm:"-"` // 判断是否调试,不落库
  34. IsAsync bool `json:"is_async" form:"is_async"`
  35. AsyncInfo interface{} `json:"async_info" gorm:"-"`
  36. ParamEnable string `json:"param_enable" `
  37. ParamDelimiter string `json:"param_delimiter"`
  38. ParamFilePath string `json:"param_file_path" gorm:"param_file_path"`
  39. ParamNames string `json:"param_names"`
  40. }
  41. // GRPCUpdateScriptRequest GRPC Update Script Request
  42. type GRPCUpdateScriptRequest struct {
  43. ID int `json:"id"`
  44. GRPCAddScriptRequest
  45. }
  46. // GRPCExecuteScriptRequest GRPC Execute Script Request
  47. type GRPCExecuteScriptRequest struct {
  48. ScriptID int `json:"script_id"`
  49. }
  50. // TableName Table Name
  51. func (g GRPC) TableName() string {
  52. return "grpc"
  53. }
  54. // TableName Table Name
  55. func (g GRPCSnap) TableName() string {
  56. return "grpc_snap"
  57. }
  58. // QueryGRPCRequest grpc of query request
  59. type QueryGRPCRequest struct {
  60. Executor string `json:"executor" form:"executor"`
  61. GRPC
  62. Pagination
  63. }
  64. // QueryGRPCResponse grpc of query response
  65. type QueryGRPCResponse struct {
  66. GRPCS []*GRPC `json:"grpcs"`
  67. Pagination
  68. }
  69. // GRPCReqToGRPC GRPC Req To GRPC
  70. func GRPCReqToGRPC(grpcReq *GRPCAddScriptRequest) (grpc *GRPC) {
  71. grpc = &GRPC{}
  72. grpc.TaskName = grpcReq.TaskName
  73. grpc.Department = grpcReq.Department
  74. grpc.Project = grpcReq.Project
  75. grpc.APP = grpcReq.APP
  76. grpc.Active = grpcReq.Active
  77. grpc.HostName = grpcReq.HostName
  78. grpc.Port = grpcReq.Port
  79. grpc.ServiceName = grpcReq.ServiceName
  80. grpc.ProtoClassName = grpcReq.ProtoClassName
  81. grpc.PkgPath = grpcReq.PkgPath
  82. grpc.AsynCall = grpcReq.AsynCall
  83. grpc.RequestType = grpcReq.RequestType
  84. grpc.RequestMethod = grpcReq.RequestMethod
  85. grpc.RequestContent = grpcReq.RequestContent
  86. grpc.ResponseType = grpcReq.ResponseType
  87. grpc.ScriptPath = grpcReq.ScriptPath
  88. grpc.JarPath = grpcReq.JarPath
  89. grpc.ThreadsSum = grpcReq.ThreadsSum
  90. grpc.RampUp = grpcReq.RampUp
  91. grpc.Loops = grpcReq.Loops
  92. grpc.LoadTime = grpcReq.LoadTime
  93. grpc.UpdateBy = grpcReq.UpdateBy
  94. grpc.IsAsync = grpcReq.IsAsync
  95. grpc.AsyncInfo = grpcReq.AsyncInfo
  96. grpc.ParamEnable = grpcReq.ParamEnable
  97. grpc.ParamDelimiter = grpcReq.ParamDelimiter
  98. grpc.ParamFilePath = grpcReq.ParamFilePath
  99. grpc.ParamNames = grpcReq.ParamNames
  100. return
  101. }