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:
#!/bin/bash | |
set -e | |
GVERSION="1.7.1" | |
GFILE="go$GVERSION.linux-amd64.tar.gz" | |
GOPATH="$HOME/gocode" | |
GOROOT="/usr/local/go" | |
if [ -d $GOROOT ]; then | |
echo "Installation directories already exist $GOROOT" |
A running example of the code from:
Small refactorings made to original code:
package main | |
const MaxLength = 1 << 20 | |
var ( | |
addr = flag.String("listen", ":8000", "listen for requests") | |
numprocs = flag.Int("p", runtime.NumCPU(), "number of workers to start") | |
maxqueue = flag.Int("q", runtime.NumCPU()*2, "largest queue size") | |
jobs chan Job |
package pool | |
type Task interface { | |
Execute(id int) | |
} | |
type Pool struct { | |
tasks chan Task | |
kill chan bool | |
} |
// Worker represents the worker that executes the job | |
type Worker struct { | |
JobChannel chan Job | |
quit chan bool | |
} | |
func NewWorker(jobChannel chan Job) Worker { | |
return Worker{ | |
JobChannel: jobChannel, | |
quit: make(chan bool)} |
package main | |
import ( | |
"bufio" | |
"encoding/csv" | |
"encoding/json" | |
"fmt" | |
"io" | |
"os" | |
"path/filepath" |
contract SimpleWallet { | |
// address is the owner | |
address owner; | |
struct WithdrawlStruct { | |
address to; | |
uint amount; | |
} |
#!/bin/bash | |
echo "-- New Migration" > "`dirname $0`/../src/main/resources/db/migrations/V`date +%s`__$1.sql" |
Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups
command.
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe
Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.