A running example of the code from:
- http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang
- http://nesv.github.io/golang/2014/02/25/worker-queues-in-go.html
Small refactorings made to original code:
| # Guide | |
| # Configure the essential configurations below and do the following: | |
| # | |
| # Repository Creation: | |
| # cap deploy:repository:create | |
| # git add . | |
| # git commit -am "initial commit" | |
| # git push origin master | |
| # | |
| # Initial Deployment: |
| package main | |
| import ( | |
| "fmt" | |
| "github.com/tuxychandru/pubsub" | |
| "time" | |
| ) | |
| type Event struct { | |
| Command string |
| package main | |
| type Event struct { | |
| Command string | |
| Payload interface{} | |
| } | |
| type EventMananger struct { | |
| eventsChan chan *Event | |
| events map[string]func(interface{}) |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
A running example of the code from:
Small refactorings made to original code:
| package main | |
| import ( | |
| "net" | |
| "os/exec" | |
| "github.com/k0kubun/pp" | |
| ) | |
| func Hosts(cidr string) ([]string, error) { |
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "github.com/nats-io/nuid" | |
| "log" | |
| "net/http" | |
| ) |
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "net/http" | |
| "runtime" | |
| "sync" | |
| "time" | |
| ) |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "github.com/nats-io/go-nats" | |
| "strconv" | |
| "strings" | |
| "sync" | |
| "time" |