outbox

package
v0.5.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

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

View Source
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

func NewMock(config *Config) (outboxMock *Outbox)

NewMock creates an Outbox mock. Config can be nil, in that case default values will be set.

func NewOutbox

func NewOutbox(config *Config) *Outbox

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) Len

func (o *Outbox) Len() int

func (*Outbox) NewOutboxMessage

func (o *Outbox) NewOutboxMessage(msg *message.Message) *outboxMsg

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.

func (*Outbox) Start

func (o *Outbox) Start()

Start launches the processing of messages in the outbox.

func (*Outbox) Stop

func (o *Outbox) Stop()

Stop stops the processing of messages in the outbox.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL