modificato con i chanel in modalita' producer-consumer
This commit is contained in:
parent
b3b1332ce8
commit
12a27241f7
4 changed files with 158 additions and 94 deletions
32
producer.go
Normal file
32
producer.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
// iterator
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/garyburd/redigo/redis"
|
||||
"log"
|
||||
)
|
||||
|
||||
func producer() {
|
||||
conn := dbs.rdb.Get()
|
||||
defer conn.Close()
|
||||
|
||||
for loop {
|
||||
// estrae un userid dalla lista degli utenti che hanno fatto login
|
||||
user, err := redis.String(conn.Do("spop", "llindex"))
|
||||
if opts.Debug {
|
||||
log.Printf("SPOP: %+v %+v - conn: %d\n\r", user, err)
|
||||
fmt.Printf("SPOP: %+v %+v - conn: %d\n\r", user, err)
|
||||
}
|
||||
// se non ci sono piu' userid esce
|
||||
if err != nil {
|
||||
if opts.Debug {
|
||||
log.Printf("LLINDEX empty: %v\n\r", err)
|
||||
fmt.Printf("LLINDEX empty: %v\n\r", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
msgs <- user
|
||||
}
|
||||
done <- true
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue