@@ -19,8 +19,10 @@ const (
1919
2020type (
2121 Producer interface {
22+ atWithWrapper (body []byte , at time.Time ) (string , error )
2223 At (body []byte , at time.Time ) (string , error )
2324 Close () error
25+ delayWithWrapper (body []byte , delay time.Duration ) (string , error )
2426 Delay (body []byte , delay time.Duration ) (string , error )
2527 Revoke (ids string ) error
2628 }
@@ -54,8 +56,9 @@ func NewProducer(beanstalks []Beanstalk) Producer {
5456}
5557
5658func (p * producerCluster ) At (body []byte , at time.Time ) (string , error ) {
59+ wrapped := wrap (body , at )
5760 return p .insert (func (node Producer ) (string , error ) {
58- return node .At ( body , at )
61+ return node .atWithWrapper ( wrapped , at )
5962 })
6063}
6164
@@ -70,8 +73,9 @@ func (p *producerCluster) Close() error {
7073}
7174
7275func (p * producerCluster ) Delay (body []byte , delay time.Duration ) (string , error ) {
76+ wrapped := wrap (body , time .Now ().Add (delay ))
7377 return p .insert (func (node Producer ) (string , error ) {
74- return node .Delay ( body , delay )
78+ return node .delayWithWrapper ( wrapped , delay )
7579 })
7680}
7781
@@ -152,3 +156,15 @@ func (p *producerCluster) insert(fn func(node Producer) (string, error)) (string
152156
153157 return "" , be .Err ()
154158}
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