Skip to content

Commit 5973a94

Browse files
committed
pss: outbox refactor minor changes
1 parent 49b7cb5 commit 5973a94

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pss/outbox/outbox.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ const (
1010
defaultOutboxCapacity = 100000
1111
)
1212

13+
var ErrOutboxfull = errors.New("outbox full")
14+
1315
type Outbox interface {
14-
Enqueue(outboxmsg *outboxMsg) error
16+
Enqueue(*outboxMsg) error
1517
ProcessOutbox()
16-
SetForwardFunction(forwardFunc func(msg interface{}) error) //Eventually this will not be needed, when pss has a newMock that creates a mock outbox, this is used just for a test outside of outbox package
18+
SetForwardFunction(forwardFunc) //Eventually this will not be needed, when pss has a newMock that creates a mock outbox, this is used just for a test outside of outbox package
1719
}
1820

1921
type Config struct {
2022
NumberSlots int
2123
QuitC chan struct{}
22-
Forward func(msg interface{}) error
24+
Forward forwardFunc
2325
}
2426

2527
type outbox struct {
@@ -28,6 +30,7 @@ type outbox struct {
2830
slots chan int
2931
process chan int
3032
}
33+
type forwardFunc func(msg interface{}) error
3134

3235
func NewOutbox(config *Config) *outbox {
3336
outbox := outbox{
@@ -59,7 +62,7 @@ func (o *outbox) Enqueue(outboxmsg *outboxMsg) error {
5962
return nil
6063
default:
6164
metrics.GetOrRegisterCounter("pss.enqueue.outbox.full", nil).Inc(1)
62-
return errors.New("outbox full")
65+
return ErrOutboxfull
6366
}
6467
}
6568

@@ -84,8 +87,8 @@ func (o *outbox) ProcessOutbox() {
8487
}
8588
}
8689

87-
func (o *outbox) SetForwardFunction(forwardFunc func(msg interface{}) error) {
88-
o.Forward = forwardFunc
90+
func (o *outbox) SetForwardFunction(f forwardFunc) {
91+
o.Forward = f
8992
}
9093

9194
func (o *outbox) msg(slot int) *outboxMsg {

0 commit comments

Comments
 (0)