Last active
August 29, 2015 14:27
-
-
Save gregtap/15f8bab4c91e65dd3a29 to your computer and use it in GitHub Desktop.
src/ondemand/main.go:24: StasdClient declared and not used
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 | |
| type hub struct { | |
| // Registered connections. | |
| connections map[*connection]bool | |
| // Inbound messages from the connections. | |
| broadcast chan []byte | |
| // Register requests from the connections. | |
| register chan *connection | |
| // Unregister requests from connections. | |
| unregister chan *connection | |
| } | |
| var h = hub{ | |
| broadcast: make(chan []byte), | |
| register: make(chan *connection), | |
| unregister: make(chan *connection), | |
| connections: make(map[*connection]bool), | |
| } | |
| func (h *hub) run() { | |
| for { | |
| select { | |
| // Register a connection (Websocket *, send []byte) | |
| case c := <-h.register: | |
| h.connections[c] = true | |
| // HERE | |
| StasdClient.Increment("bucket", 1, 1) | |
| } | |
| } | |
| } |
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 ( | |
| "fmt" | |
| "github.com/cyberdelia/statsd" | |
| "github.com/spf13/viper" | |
| "log" | |
| "net/http" | |
| ) | |
| var StasdClient *statsd.Client | |
| var err Error | |
| func main() { | |
| StasdClient, err = statsd.Dial("localhost:8125") | |
| if err != nil { | |
| log.Fatal("Cant connect to statsd") | |
| } | |
| // Start hub as a go routine. | |
| go h.run() | |
| // ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment