Created
January 13, 2016 00:26
-
-
Save lancecarlson/4670b4bbcfd1b377f70c to your computer and use it in GitHub Desktop.
This file contains 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 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