Skip to content

Commit

Permalink
1:chan Callback 改为 chan *Callback
Browse files Browse the repository at this point in the history
  • Loading branch information
xluohome committed Feb 23, 2017
1 parent bc23d2c commit 9734bbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Callback struct {
}

var (
callback = make(chan Callback)
callback = make(chan *Callback)
)

func RunCallbackTask() {
Expand All @@ -37,14 +37,14 @@ func AddCallbackTask(sms *SMS, flag string) {
data.Set("service", sms.serviceName)
data.Set("uxtime", fmt.Sprintf("%d", sms.NowTime.Unix()))
data.Set("flag", flag)
callback <- Callback{sms.Config.Callback, data, 0}
callback <- &Callback{sms.Config.Callback, data, 0}
}

func (c Callback) Do(cbs <-chan Callback) {
func (c *Callback) Do(cbs <-chan *Callback) {

for cb := range cbs {

go func() {
go func(cb *Callback) {
//延时 2,4,6,8,16,32,64,128 ... 秒
<-time.After(time.Duration(1<<cb.callnums) * time.Second)

Expand All @@ -70,7 +70,7 @@ func (c Callback) Do(cbs <-chan Callback) {

callback <- cb

}()
}(cb)

}
}
2 changes: 1 addition & 1 deletion f_hywx.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (h *Hywx) Send(sms *SMS) error {
}

if h.Code != 2 {
log.Error("%v", h)
log.Errorf("%v", h)
return fmt.Errorf("%s", h.Msg)
}

Expand Down

0 comments on commit 9734bbe

Please sign in to comment.