orders

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// OrderError represents errors with orders
	OrderError = errs.Class("order")
)

Functions

This section is empty.

Types

type ArchivedInfo

type ArchivedInfo struct {
	Limit  *pb.OrderLimit2
	Order  *pb.Order2
	Uplink *identity.PeerIdentity

	Status     Status
	ArchivedAt time.Time
}

ArchivedInfo contains full information about an archived order.

type DB

type DB interface {
	// Enqueue inserts order to the list of orders needing to be sent to the satellite.
	Enqueue(ctx context.Context, info *Info) error
	// ListUnsent returns orders that haven't been sent yet.
	ListUnsent(ctx context.Context, limit int) ([]*Info, error)
	// ListUnsentBySatellite returns orders that haven't been sent yet grouped by satellite.
	ListUnsentBySatellite(ctx context.Context) (map[storj.NodeID][]*Info, error)

	// Archive marks order as being handled.
	Archive(ctx context.Context, satellite storj.NodeID, serial storj.SerialNumber, status Status) error

	// ListArchived returns orders that have been sent.
	ListArchived(ctx context.Context, limit int) ([]*ArchivedInfo, error)
}

DB implements storing orders for sending to the satellite.

type Info

type Info struct {
	Limit  *pb.OrderLimit2
	Order  *pb.Order2
	Uplink *identity.PeerIdentity
}

Info contains full information about an order.

type Sender

type Sender struct {
	Loop sync2.Cycle
	// contains filtered or unexported fields
}

Sender sends every interval unsent orders to the satellite.

func NewSender

func NewSender(log *zap.Logger, transport transport.Client, kademlia *kademlia.Kademlia, orders DB, config SenderConfig) *Sender

NewSender creates an order sender.

func (*Sender) Close

func (sender *Sender) Close() error

Close stops the sending service.

func (*Sender) Run

func (sender *Sender) Run(ctx context.Context) (err error)

Run sends orders on every interval to the appropriate satellites.

func (*Sender) Settle

func (sender *Sender) Settle(ctx context.Context, satelliteID storj.NodeID, orders []*Info)

Settle uploads orders to the satellite.

type SenderConfig

type SenderConfig struct {
	Interval time.Duration `help:"duration between sending" default:"1h0m0s"`
	Timeout  time.Duration `help:"timeout for sending" default:"1h0m0s"`
}

SenderConfig defines configuration for sending orders.

type Status

type Status byte

Status is the archival status of the order.

const (
	StatusUnsent Status = iota
	StatusAccepted
	StatusRejected
)

Statuses for satellite responses.

Jump to

Keyboard shortcuts

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