Skip to content

Commit

Permalink
Merge pull request redis#965 from go-redis/feature/pipeline-custom-cmd
Browse files Browse the repository at this point in the history
Support custom command in pipeline
  • Loading branch information
vmihailenco authored Feb 8, 2019
2 parents 228e43b + 5240e14 commit 7081903
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 7081903

Please sign in to comment.