NO-JIRA: [go] add -prefetch option to receive.go example
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d6e5360d Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d6e5360d Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d6e5360d Branch: refs/heads/go1 Commit: d6e5360dcf4ea60633a291dad54040e73174cf57 Parents: cd056f3 Author: Alan Conway <[email protected]> Authored: Wed Dec 13 17:13:19 2017 -0500 Committer: Alan Conway <[email protected]> Committed: Wed Dec 13 17:13:19 2017 -0500 ---------------------------------------------------------------------- examples/go/electron/receive.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d6e5360d/examples/go/electron/receive.go ---------------------------------------------------------------------- diff --git a/examples/go/electron/receive.go b/examples/go/electron/receive.go index 568fcc9..9cab2eb 100644 --- a/examples/go/electron/receive.go +++ b/examples/go/electron/receive.go @@ -40,6 +40,7 @@ URLs are of the form "amqp://<host>:<port>/<amqp-address>" } var count = flag.Uint64("count", 1, "Stop after receiving this many messages in total") +var prefetch = flag.Int("prefetch", 0, "enable a pre-fetch window to improve throughput") var debug = flag.Bool("debug", false, "Print detailed debug output") var debugf = func(format string, data ...interface{}) {} // Default no debugging output @@ -78,7 +79,11 @@ func main() { fatalIf(err) connections <- c // Save connection so we can Close() when main() ends addr := strings.TrimPrefix(url.Path, "/") - r, err := c.Receiver(electron.Source(addr)) + opts := []electron.LinkOption{electron.Source(addr)} + if *prefetch > 0 { + opts = append(opts, electron.Capacity(*prefetch), electron.Prefetch(true)) + } + r, err := c.Receiver(opts...) fatalIf(err) // Loop receiving messages and sending them to the main() goroutine for { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
