aggiunta l'opzione per scrivere la somma su influxdb

This commit is contained in:
Michele 2017-03-20 17:20:26 +01:00
parent a6a959427d
commit 87bd709630
8 changed files with 125 additions and 99 deletions

View file

@ -29,7 +29,7 @@ func producer() {
loop := true
start := time.Now()
startp := time.Now()
users := make(map[string]bool)
for loop {
@ -56,7 +56,7 @@ func producer() {
}
if opts.Debug {
fmt.Printf("\nKEYS: %+v\n", time.Since(start))
fmt.Printf("\nKEYS: %+v\n", time.Since(startp))
}
max := 0
@ -75,95 +75,3 @@ func producer() {
done <- true
}
/*
keys, err := redis.Strings(conn.Do("KEYS", "*"))
if err != nil {
if opts.Debug {
fmt.Printf("Keys error: %v\n", err)
}
log.Printf("Keys error: %v\n", err)
exit()
}
users := make(map[string]bool)
for _, key := range keys {
user := key[:strings.Index(key, "@")]
users[user] = true
}
uq := make([]userQuota, 0)
max := 0
for key, _ := range users {
if !loop {
break
}
// wg.Wait()
status = _Producer
start := time.Now()
if opts.Test {
fmt.Printf("MGET: %s (%d)\n", key, max)
}
// estrae un userid dalla lista degli utenti che hanno fatto login
quota, err := redis.Strings(conn.Do("mget", fmt.Sprintf("%s@tiscali.it/quota/messages", key), fmt.Sprintf("%s@tiscali.it/quota/storage", key)))
// se non ci sono piu' userid esce
if err != nil {
if opts.Debug {
fmt.Printf("MGET err: %v\n", err)
}
log.Printf("MGET err: %v\n", err)
continue
}
counter <- Counterchan{
tipo: "user",
val: 1,
}
msg, err := strconv.Atoi(quota[0])
if err != nil {
msg = 0
}
store, err := strconv.Atoi(quota[1])
if err != nil {
store = 0
}
uq = append(uq, userQuota{
user: key,
messages: msg,
storage: store,
})
if opts.Test {
fmt.Printf("User: %s - %+v\n", key, quota)
}
if max >= opts.MaxBulk {
if opts.Debug {
fmt.Printf("\nPROD: %+v\n", time.Since(start))
}
// wg.Add(1)
// counter <- Counterchan{
// tipo: "wg",
// val: 1,
// }
consume <- uq
uq = make([]userQuota, 0)
max = 0
}
max += 1
}
done <- true
*/