Browse Source

wip:告警优化

wangshan 11 tháng trước cách đây
mục cha
commit
f44f1f46cc
6 tập tin đã thay đổi với 40 bổ sung4 xóa
  1. 8 0
      .idea/.gitignore
  2. 9 0
      .idea/Sms_Service.iml
  3. 8 0
      .idea/modules.xml
  4. 6 0
      .idea/vcs.xml
  5. BIN
      src/Sms_Service
  6. 9 4
      src/service/weiwangtonglian.go

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 9 - 0
.idea/Sms_Service.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/Sms_Service.iml" filepath="$PROJECT_DIR$/.idea/Sms_Service.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

BIN
src/Sms_Service


+ 9 - 4
src/service/weiwangtonglian.go

@@ -16,7 +16,7 @@ import (
 	"github.com/donnie4w/go-logger/logger"
 )
 
-//微网通联短信平台
+// 微网通联短信平台
 var Weiwangtonglian = &weiwangtonglian{
 	t: "微网通联",
 }
@@ -25,7 +25,7 @@ type weiwangtonglian struct {
 	t string
 }
 
-//提交模板短信
+// 提交模板短信
 func (w *weiwangtonglian) Execute(reqData *ReqData) {
 	TempCode := Config.Weiwangtonglian.IdToTpl[reqData.Id]
 	if TempCode == 0 {
@@ -59,7 +59,12 @@ func (w *weiwangtonglian) Execute(reqData *ReqData) {
 	}
 	json.Unmarshal(b, &result)
 	if result.Result != "succ" {
-		go http.Get(fmt.Sprintf(Config.Warn, url.QueryEscape(reqData.Phones+":"+result.Reason)))
+		go func() {
+			res, err := http.Get(fmt.Sprintf(Config.Warn, url.QueryEscape(reqData.Phones+":"+result.Reason)))
+			if err == nil {
+				res.Body.Close()
+			}
+		}()
 	}
 }
 
@@ -75,7 +80,7 @@ func (w *weiwangtonglian) Mmd5(val string) string {
 	return fmt.Sprintf("%x", m5.Sum(nil))
 }
 
-//删除模板(短信/视频短信)
+// 删除模板(短信/视频短信)
 func (w *weiwangtonglian) delTemplate() {
 	r := rand.New(rand.NewSource(time.Now().UnixNano()))
 	randInt := r.Intn(999999) + 5