Skip to content

Commit

Permalink
will not use uuid.
Browse files Browse the repository at this point in the history
Reason: github.com/nu7hatch/gouuid is not well supported by
goimports.
  • Loading branch information
monnand committed Nov 7, 2013
1 parent 725c456 commit 416e3f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions pushbackend.go
Expand Up @@ -18,7 +18,6 @@
package main

import (
"github.com/nu7hatch/gouuid"
. "github.com/uniqush/log"
. "github.com/uniqush/uniqush-push/db"
. "github.com/uniqush/uniqush-push/push"
Expand Down Expand Up @@ -83,8 +82,8 @@ func (self *PushBackEnd) Unsubscribe(service, sub string, dp *DeliveryPoint) err

func (self *PushBackEnd) processError() {
for err := range self.errChan {
rid, _ := uuid.NewV4()
e := self.fixError(rid.String(), err, self.loggers[LOGGER_PUSH], 0*time.Second)
rid := randomUniqId()
e := self.fixError(rid, err, self.loggers[LOGGER_PUSH], 0*time.Second)
switch e0 := e.(type) {
case *InfoReport:
self.loggers[LOGGER_PUSH].Infof("%v", e0)
Expand Down
14 changes: 12 additions & 2 deletions restapi.go
Expand Up @@ -18,6 +18,10 @@
package main

import (
"crypto/rand"
"encoding/base64"
"time"

"fmt"

"github.com/uniqush/log"
Expand All @@ -39,6 +43,12 @@ type RestAPI struct {
stopChan chan<- bool
}

func randomUniqId() string {
var d [16]byte
io.ReadFull(rand.Reader, d[:])
return fmt.Sprintf("%x-%v", time.Now().Unix(), base64.URLEncoding.EncodeToString(d[:]))
}

// loggers: sequence is web, add
func NewRestAPI(psm *PushServiceManager, loggers []log.Logger, version string, backend *PushBackEnd) *RestAPI {
ret := new(RestAPI)
Expand Down Expand Up @@ -334,8 +344,8 @@ func (self *RestAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case PUSH_NOTIFICATION_URL:
weblogger := log.NewLogger(writer, "[Push]", logLevel)
logger := log.MultiLogger(weblogger, self.loggers[LOGGER_PUSH])
rid, _ := uuid.NewV4()
self.pushNotification(rid.String(), kv, perdp, logger, remoteAddr)
rid := randomUniqId()
self.pushNotification(rid, kv, perdp, logger, remoteAddr)
}
}

Expand Down

0 comments on commit 416e3f8

Please sign in to comment.