/
mns_engine.go
65 lines (64 loc) · 1.59 KB
/
mns_engine.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package event
//import (
// "encoding/json"
// "github.com/gingerxman/eel/config"
// "github.com/gingerxman/eel/log"
// ali_mns "github.com/gingerxman/eel/aliyun/mns"
//)
//
//type mnsConf struct{
// endpoint string
// accessId string
// accessKey string
// topic string
//}
//
//var conf *mnsConf
//
//type mnsEngine struct{
// engineType string
//}
//
//func newMnsEngine() *mnsEngine{
// eg := new(mnsEngine)
// eg.engineType = "mns"
// return eg
//}
//
//func (this *mnsEngine) getMnsClient() ali_mns.MNSClient{
// return ali_mns.NewAliMNSClient(conf.endpoint, conf.accessId, conf.accessKey)
//}
//
//func (this *mnsEngine) getFormattedMessage(data map[string]interface{}, tag string) ali_mns.MessagePublishRequest{
// dataStr, _ := json.Marshal(data)
// return ali_mns.MessagePublishRequest{
// MessageBody: string(dataStr),
// MessageTag: tag,
// MessageAttributes: nil,
// }
//}
//
//func (this *mnsEngine) Send(ctx context.Context, data map[string]interface{}, tag string){
// client := this.getMnsClient()
// topicName := conf.topic
// topic := ali_mns.NewMNSTopic(topicName, client)
//
// _, err := topic.PublishMessage(this.getFormattedMessage(data, tag))
// if err != nil{
// log.Logger.Error(err)
// }
//
//}
//
//
//func init(){
//
// eg := newMnsEngine()
// registerEngine(eg.engineType, eg)
//
// conf = new(mnsConf)
// conf.accessId = config.ServiceConfig.String("aliyun::MNS_ACCESS_ID")
// conf.accessKey = config.ServiceConfig.String("aliyun::MNS_ACCESS_KEY")
// conf.endpoint = config.ServiceConfig.String("aliyun::MNS_ENDPOINT")
// conf.topic = config.ServiceConfig.String("aliyun::MNS_TOPIC")
//}