Skip to content

Commit 429b313

Browse files
committed
Config not embedded anymore on outbox struct
1 parent 70c3a6d commit 429b313

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

pss/outbox/outbox.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ type Config struct {
2525
}
2626

2727
type outbox struct {
28-
Config
28+
forward forwardFunc
29+
quitC chan struct{}
2930
queue []*outboxMsg
3031
slots chan int
3132
process chan int
@@ -34,7 +35,8 @@ type forwardFunc func(msg interface{}) error
3435

3536
func NewOutbox(config *Config) *outbox {
3637
outbox := outbox{
37-
Config: *config,
38+
forward: config.Forward,
39+
quitC: config.QuitC,
3840
process: make(chan int),
3941
slots: make(chan int, config.NumberSlots),
4042
queue: make([]*outboxMsg, config.NumberSlots),
@@ -57,7 +59,7 @@ func (o *outbox) Enqueue(outboxmsg *outboxMsg) error {
5759
// we send this message slot to process
5860
select {
5961
case o.process <- slot:
60-
case <-o.QuitC:
62+
case <-o.quitC:
6163
}
6264
return nil
6365
default:
@@ -71,7 +73,7 @@ func (o *outbox) ProcessOutbox() {
7173
go func(slot int) {
7274
msg := o.msg(slot)
7375
metrics.GetOrRegisterResettingTimer("pss.handle.outbox", nil).UpdateSince(msg.startedAt)
74-
if err := o.Forward(msg.msg); err != nil {
76+
if err := o.forward(msg.msg); err != nil {
7577
metrics.GetOrRegisterCounter("pss.forward.err", nil).Inc(1)
7678
// if we failed to forward, re-insert message in the queue
7779
log.Debug(err.Error())
@@ -88,7 +90,7 @@ func (o *outbox) ProcessOutbox() {
8890
}
8991

9092
func (o *outbox) SetForwardFunction(f forwardFunc) {
91-
o.Forward = f
93+
o.forward = f
9294
}
9395

9496
func (o *outbox) msg(slot int) *outboxMsg {
@@ -102,7 +104,7 @@ func (o *outbox) free(slot int) {
102104
func (o *outbox) reenqueue(slot int) {
103105
select {
104106
case o.process <- slot:
105-
case <-o.QuitC:
107+
case <-o.quitC:
106108
}
107109
}
108110

pss/outbox/outbox_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestMessageOutbox(t *testing.T) {
5555
return errors.New("forced test error forwarding message")
5656
}
5757

58-
outbox.Forward = failedForward
58+
outbox.forward = failedForward
5959

6060
err = outbox.Enqueue(outboxMessage)
6161
if err != nil {
@@ -72,7 +72,7 @@ func TestMessageOutbox(t *testing.T) {
7272
t.Fatal("Incorrect number of failed messages, expected 1 got 0")
7373
}
7474
// The message will be retried once we send to continueC, so first, we change the forward function
75-
outbox.Forward = forward
75+
outbox.forward = forward
7676
continueC <- struct{}{}
7777
select {
7878
case <-successC:

pss/pss.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ func (p *Pss) forward(msg interface{}) error {
707707
var pssMsg *PssMsg
708708
pssMsg, ok := msg.(*PssMsg)
709709
if !ok {
710-
return errors.New("cannot forward a non pssMsg pssMsg")
710+
return errors.New("cannot forward a non pssMsg")
711711
}
712712

713713
metrics.GetOrRegisterCounter("pss.forward", nil).Inc(1)

0 commit comments

Comments
 (0)