From 4271cd1529a78175e327570894988cc2cb21228f Mon Sep 17 00:00:00 2001 From: Matt Reiferson Date: Sat, 2 May 2015 08:41:49 -0700 Subject: [PATCH] add DPUB --- command.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/command.go b/command.go index c17c639b..80e47436 100644 --- a/command.go +++ b/command.go @@ -133,8 +133,15 @@ func Publish(topic string, body []byte) *Command { return &Command{[]byte("PUB"), params, body} } -// MultiPublish creates a new Command to write more than one message to a given topic. -// This is useful for high-throughput situations to avoid roundtrips and saturate the pipe. +// DeferredPublish creates a new Command to write a message to a given topic +// where the message will queue at the channel level until the timeout expires +func DeferredPublish(topic string, delay time.Duration, body []byte) *Command { + var params = [][]byte{[]byte(topic), []byte(strconv.Itoa(int(delay / time.Millisecond)))} + return &Command{[]byte("DPUB"), params, body} +} + +// MultiPublish creates a new Command to write more than one message to a given topic +// (useful for high-throughput situations to avoid roundtrips and saturate the pipe) func MultiPublish(topic string, bodies [][]byte) (*Command, error) { var params = [][]byte{[]byte(topic)}