Skip to content

Commit

Permalink
feature: 增加短信提醒。
Browse files Browse the repository at this point in the history
超过2级告警线2分钟后,将发短信给用户提醒。
  • Loading branch information
koch3092 committed Oct 10, 2022
1 parent 3a97fa0 commit cca55f8
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config/ali_sms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package config

type AliSms struct {
AccessKey string `mapstructure:"access-key" json:"access_key" yaml:"access-key"` // 账号Access Key
AccessSecret string `mapstructure:"access-secret" json:"access_secret" yaml:"access-secret"` // 账号Access Secret
SignName string `mapstructure:"sign-name" json:"sign_name" yaml:"sign-name"` // 短信的 SignName
}
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ type Server struct {
AliAmqpCred AliAmqpCredential `mapstructure:"ali-amqp-cred" json:"ali_amqp_cred" yaml:"ali-amqp-cred"`
Cordons Cordons `mapstructure:"cordons" json:"cordons" yaml:"cordons"`
Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
AliSms AliSms `mapstructure:"ali-sms" json:"ali_sms" yaml:"ali-sms"`
}
2 changes: 2 additions & 0 deletions global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package global
import (
"bhms-ali-iot/config"
"database/sql"
dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
"github.com/go-redis/redis/v8"
"go.uber.org/zap"
)
Expand All @@ -13,4 +14,5 @@ var (
Logger *zap.Logger
TDengine *sql.DB
Redis *redis.Client
AliSms *dysmsapi20170525.Client
)
29 changes: 29 additions & 0 deletions initialize/ali_sms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package initialize

import (
openapi "github.com/alibabacloud-go/darabonba-openapi/client"
dysmsapi20170525 "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
"github.com/alibabacloud-go/tea/tea"
)

// CreateClient
/**
* 使用AK&SK初始化账号Client
* @param accessKeyId
* @param accessKeySecret
* @return Client
* @throws Exception
*/
func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsapi20170525.Client, _err error) {
config := &openapi.Config{
// 您的AccessKey ID
AccessKeyId: accessKeyId,
// 您的AccessKey Secret
AccessKeySecret: accessKeySecret,
}
// 访问的域名
config.Endpoint = tea.String("dysmsapi.aliyuncs.com")
_result = &dysmsapi20170525.Client{}
_result, _err = dysmsapi20170525.NewClient(config)
return _result, _err
}
Loading

0 comments on commit cca55f8

Please sign in to comment.