Skip to content

Instantly share code, notes, and snippets.

@lancecarlson
Created January 13, 2016 00:26
Show Gist options
  • Save lancecarlson/4670b4bbcfd1b377f70c to your computer and use it in GitHub Desktop.
Save lancecarlson/4670b4bbcfd1b377f70c to your computer and use it in GitHub Desktop.
package mq
import (
"github.com/pebbe/zmq4"
"github.com/tylertreat/mq-benchmarking/benchmark"
)
func NewZeromqPipeline(numberOfMessages int, testLatency bool) *Zeromq {
ctx, _ := zmq4.NewContext()
pub, _ := ctx.NewSocket(zmq4.PUSH)
pub.Bind("tcp://*:5555")
sub, _ := ctx.NewSocket(zmq4.PULL)
sub.Connect("tcp://localhost:5555")
var handler benchmark.MessageHandler
if testLatency {
handler = &benchmark.LatencyMessageHandler{
NumberOfMessages: numberOfMessages,
Latencies: []float32{},
}
} else {
handler = &benchmark.ThroughputMessageHandler{NumberOfMessages: numberOfMessages}
}
return &Zeromq{
handler: handler,
sender: pub,
receiver: sub,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment