pipeline.go 1.4 KB
Newer Older
Y
Your Name 已提交
1
package redispluginproxy
E
eoLinker API Management 已提交
2 3 4

import (
	"github.com/eolinker/goku-plugin"
删除  
黄孟柱 已提交
5
	"github.com/go-redis/redis"
E
eoLinker API Management 已提交
6 7
)

Y
Your Name 已提交
8
//PipelineProxy pipelineProxy
E
eoLinker API Management 已提交
9 10 11 12 13
type PipelineProxy struct {
	RedisProxy
	pipeliner redis.Pipeliner
}

Y
Your Name 已提交
14
//Auth auth
E
eoLinker API Management 已提交
15 16 17 18
func (p *PipelineProxy) Auth(password string) goku_plugin.StatusCmd {
	return p.pipeliner.Auth(password)
}

Y
Your Name 已提交
19
//Select select
E
eoLinker API Management 已提交
20 21 22 23
func (p *PipelineProxy) Select(index int) goku_plugin.StatusCmd {
	return p.pipeliner.Select(index)
}

Y
Your Name 已提交
24
//SwapDB swapDB
E
eoLinker API Management 已提交
25 26 27 28
func (p *PipelineProxy) SwapDB(index1, index2 int) goku_plugin.StatusCmd {
	return p.pipeliner.SwapDB(index1, index2)
}

Y
Your Name 已提交
29
//ClientSetName clientSetName
E
eoLinker API Management 已提交
30 31 32 33
func (p *PipelineProxy) ClientSetName(name string) goku_plugin.BoolCmd {
	return p.pipeliner.ClientSetName(name)
}

Y
Your Name 已提交
34
//Do do
E
eoLinker API Management 已提交
35 36 37 38
func (p *PipelineProxy) Do(args ...interface{}) goku_plugin.Cmd {
	return p.pipeliner.Do(args...)
}

Y
Your Name 已提交
39
//Process process
E
eoLinker API Management 已提交
40 41 42 43 44
func (p *PipelineProxy) Process(cmd goku_plugin.Cmder) error {
	arg := cmd.Args()
	return p.pipeliner.Process(redis.NewCmd(arg...))
}

Y
Your Name 已提交
45
//Close close
E
eoLinker API Management 已提交
46 47 48 49
func (p *PipelineProxy) Close() error {
	return p.pipeliner.Close()
}

Y
Your Name 已提交
50
//Discard discard
E
eoLinker API Management 已提交
51 52 53 54
func (p *PipelineProxy) Discard() error {
	return p.pipeliner.Discard()
}

Y
Your Name 已提交
55
//Exec exec
E
eoLinker API Management 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68
func (p *PipelineProxy) Exec() ([]goku_plugin.Cmder, error) {

	cmders, err := p.pipeliner.Exec()
	if err != nil {
		return nil, err
	}

	cmds := make([]goku_plugin.Cmder, 0, len(cmders))
	for _, c := range cmders {
		cmds = append(cmds, c)
	}
	return cmds, nil
}