crea l'ID con user+data+ip usando la data nel formato yymmggThh
This commit is contained in:
parent
8bff28e0dc
commit
1b36fde70a
3 changed files with 13 additions and 3 deletions
|
@ -35,6 +35,8 @@ func consumer() {
|
|||
|
||||
prod := <-consume
|
||||
|
||||
start := time.Now()
|
||||
|
||||
status = _Consumer
|
||||
|
||||
var bulk = make(map[string]*mgo.Bulk)
|
||||
|
@ -56,7 +58,6 @@ func consumer() {
|
|||
empty: true,
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
for i := range prod.logins {
|
||||
login := prod.logins[i]
|
||||
// se la riga di login e' vuota
|
||||
|
@ -81,7 +82,7 @@ func consumer() {
|
|||
}
|
||||
ml := MongoLogin{
|
||||
// genera l' _ID con user e timestamp
|
||||
ID: hash([]byte(fmt.Sprintf("%s%s", prod.user, time.Unix(date, 0).Format("20060102T1504")))), // Format("20060102T150405")
|
||||
ID: hash([]byte(fmt.Sprintf("%s%s%s", prod.user, time.Unix(date, 0).Format("20060102T15"), sval[2]))), // Format("20060102T150405")
|
||||
User: prod.user,
|
||||
Protocol: sval[0],
|
||||
IP: sval[2],
|
||||
|
@ -270,6 +271,10 @@ func consumer() {
|
|||
fmt.Printf("CONS: user=%s logins=%d in %v - active=%d\n", prod.user, len(prod.logins), time.Since(start), dbs.rdb.ActiveCount())
|
||||
}
|
||||
|
||||
if opts.Debug && len(prod.logins) > 10 {
|
||||
fmt.Printf("LOGS: %+v\n", cons.logins)
|
||||
}
|
||||
|
||||
// wg.Done()
|
||||
remove <- cons
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
_Version = "v3.1.1"
|
||||
_Version = "v3.2.0"
|
||||
_Producer = 0
|
||||
_Consumer = 1
|
||||
_Remover = 2
|
||||
|
|
|
@ -70,10 +70,15 @@ func producer() {
|
|||
val: 1,
|
||||
}
|
||||
|
||||
if opts.Debug {
|
||||
fmt.Printf("PROD: %+v\n", time.Since(start))
|
||||
}
|
||||
|
||||
consume <- produced{
|
||||
user: user,
|
||||
logins: logs,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
done <- true
|
||||
|
|
Loading…
Add table
Reference in a new issue