Merge pull request #965 from go-redis/feature/pipeline-custom-cmd

Support custom command in pipeline
This commit is contained in:
Vladimir Mihailenco 2019-02-08 13:36:14 +02:00 committed by GitHub
commit 70819034d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -31,6 +31,12 @@ type Pipeline struct {
closed bool
}
func (c *Pipeline) Do(args ...interface{}) *Cmd {
cmd := NewCmd(args...)
_ = c.Process(cmd)
return cmd
}
// Process queues the cmd for later execution.
func (c *Pipeline) Process(cmd Cmder) error {
c.mu.Lock()

View File

@ -60,6 +60,13 @@ var _ = Describe("pipelining", func() {
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("value"))
})
It("supports custom command", func() {
pipe.Do("ping")
cmds, err := pipe.Exec()
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(1))
})
}
Describe("Pipeline", func() {