Created
October 13, 2013 01:50
-
-
Save raliste/6957127 to your computer and use it in GitHub Desktop.
Super easy and scalable async queues with Python and Golang. And see nice stats by doing `gem install resque` and then `resque-web`. You might need to add your goworker queue into redis to make it show up in resque-web.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
RESQUE_QUEUE = 'resque:queue:%s' | |
def test(n=0): | |
r = redis.Redis() | |
r.rpush(RESQUE_QUEUE % 'notifications', '{"class":"EmailNotification","args":["hi","there %s"]}' % n) | |
if __name__ == '__main__': | |
for i in xrange(100): | |
test(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"github.com/benmanns/goworker" | |
) | |
func init() { | |
goworker.Register("EmailNotification", emailNotification) | |
} | |
func emailNotification(queue string, args ...interface{}) error { | |
log.Println("emailNotification") | |
log.Println("args:", args) | |
return nil | |
} | |
func main() { | |
log.Println("Running notifications workers...") | |
if err := goworker.Work(); err != nil { | |
log.Fatal("Error:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment