Documentation ¶
Overview ¶
Copyright 2019 The Swarm Authors This file is part of the Swarm library.
The Swarm library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Swarm library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Swarm library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2019 The Swarm Authors This file is part of the Swarm library.
The Swarm library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Swarm library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Swarm library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2019 The Swarm Authors This file is part of the Swarm library.
The Swarm library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The Swarm library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with the Swarm library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrOutboxFull = errors.New("outbox full")
ErrOutboxFull is returned when a caller tries to enqueue a message and all slots are busy.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { NumberSlots int // number of slots for messages in Outbox and number of workers. Forward forwardFunction // function that executes the actual forwarding. MaxRetryTime *time.Duration // max time a message will be retried in the outbox. Clock clock.Clock // clock dependency to calculate elapsed time. }
Config contains the Outbox configuration.
type Outbox ¶
type Outbox struct {
// contains filtered or unexported fields
}
Outbox will be in charge of forwarding messages. These will be enqueued and retry until successfully forwarded.
func NewMock ¶
NewMock creates an Outbox mock. Config can be nil, in that case default values will be set.
func NewOutbox ¶
NewOutbox creates a new Outbox. Config must be provided. IF NumWorkers is not providers, default will be used.
func (*Outbox) Enqueue ¶
func (o *Outbox) Enqueue(outboxMsg *outboxMsg)
Enqueue a new element in the outbox if there is any slot available. Then send it to process. This method is blocking if there is no workers available.
func (*Outbox) NewOutboxMessage ¶
NewOutboxMessage creates a new outbox message wrapping a pss message and set the startedTime using the clock
func (*Outbox) SetForward ¶
func (o *Outbox) SetForward(forwardFunc forwardFunction)
SetForward set the forward function that will be executed on each message.