@@ -19,12 +19,13 @@ const (
1919
2020type (
2121 Producer interface {
22- atWithWrapper (body []byte , at time.Time ) (string , error )
2322 At (body []byte , at time.Time ) (string , error )
2423 Close () error
25- delayWithWrapper (body []byte , delay time.Duration ) (string , error )
2624 Delay (body []byte , delay time.Duration ) (string , error )
2725 Revoke (ids string ) error
26+
27+ at (body []byte , at time.Time ) (string , error )
28+ delay (body []byte , delay time.Duration ) (string , error )
2829 }
2930
3031 producerCluster struct {
@@ -57,9 +58,7 @@ func NewProducer(beanstalks []Beanstalk) Producer {
5758
5859func (p * producerCluster ) At (body []byte , at time.Time ) (string , error ) {
5960 wrapped := wrap (body , at )
60- return p .insert (func (node Producer ) (string , error ) {
61- return node .atWithWrapper (wrapped , at )
62- })
61+ return p .at (wrapped , at )
6362}
6463
6564func (p * producerCluster ) Close () error {
@@ -74,9 +73,7 @@ func (p *producerCluster) Close() error {
7473
7574func (p * producerCluster ) Delay (body []byte , delay time.Duration ) (string , error ) {
7675 wrapped := wrap (body , time .Now ().Add (delay ))
77- return p .insert (func (node Producer ) (string , error ) {
78- return node .delayWithWrapper (wrapped , delay )
79- })
76+ return p .delay (wrapped , delay )
8077}
8178
8279func (p * producerCluster ) Revoke (ids string ) error {
@@ -98,10 +95,22 @@ func (p *producerCluster) Revoke(ids string) error {
9895 return be .Err ()
9996}
10097
98+ func (p * producerCluster ) at (body []byte , at time.Time ) (string , error ) {
99+ return p .insert (func (node Producer ) (string , error ) {
100+ return node .at (body , at )
101+ })
102+ }
103+
101104func (p * producerCluster ) cloneNodes () []Producer {
102105 return append ([]Producer (nil ), p .nodes ... )
103106}
104107
108+ func (p * producerCluster ) delay (body []byte , delay time.Duration ) (string , error ) {
109+ return p .insert (func (node Producer ) (string , error ) {
110+ return node .delay (body , delay )
111+ })
112+ }
113+
105114func (p * producerCluster ) getWriteNodes () []Producer {
106115 if len (p .nodes ) <= replicaNodes {
107116 return p .nodes
@@ -156,15 +165,3 @@ func (p *producerCluster) insert(fn func(node Producer) (string, error)) (string
156165
157166 return "" , be .Err ()
158167}
159-
160- func (p * producerCluster ) atWithWrapper (body []byte , at time.Time ) (string , error ) {
161- return p .insert (func (node Producer ) (string , error ) {
162- return node .atWithWrapper (body , at )
163- })
164- }
165-
166- func (p * producerCluster ) delayWithWrapper (body []byte , delay time.Duration ) (string , error ) {
167- return p .insert (func (node Producer ) (string , error ) {
168- return node .delayWithWrapper (body , delay )
169- })
170- }
0 commit comments