queue

package
v0.0.0-...-269d6e4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BidEventTypeStartFetching is an alias.
	BidEventTypeStartFetching = db.BidEventTypeStartFetching
	// BidEventTypeErrorFetching is an alias.
	BidEventTypeErrorFetching = db.BidEventTypeErrorFetching
	// BidEventTypeStartImporting is an alias.
	BidEventTypeStartImporting = db.BidEventTypeStartImporting
	// BidEventTypeEndImporting is an alias.
	BidEventTypeEndImporting = db.BidEventTypeEndImporting
	// BidEventTypeFinalized is an alias.
	BidEventTypeFinalized = db.BidEventTypeFinalized
	// BidEventTypeErrored is an alias.
	BidEventTypeErrored = db.BidEventTypeErrored
)

Variables

View Source
var (

	// StartDelay is the time delay before the queue will process queued auctions on start.
	StartDelay = time.Second * 10

	// MaxConcurrency is the maximum number of auctions that will be handled concurrently.
	MaxConcurrency = 1

	// ErrAuctionNotFound indicates the requested auction was not found.
	ErrAuctionNotFound = errors.New("auction not found")

	// ErrBidNotFound indicates the requested bid was not found.
	ErrBidNotFound = errors.New("bid not found")
)

Functions

This section is empty.

Types

type BidEventType

type BidEventType = db.BidEventType

BidEventType is an alias.

type Finalizer

type Finalizer func(ctx context.Context, auction *auctioneer.Auction) error

Finalizer is called when an auction moves from "started" to "finalized".

type Handler

type Handler func(
	ctx context.Context,
	auction auctioneer.Auction,
	addBid func(bid auctioneer.Bid) error,
) (map[auction.BidID]auctioneer.WinningBid, error)

Handler is called when an auction moves from "queued" to "started".

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue is a persistent worker-based task queue.

func NewQueue

func NewQueue(postgresURI string, handler Handler, finalizer Finalizer) (*Queue, error)

NewQueue returns a new Queue using handler to process auctions.

func (*Queue) Close

func (q *Queue) Close() error

Close the queue. This will wait for "started" auctions.

func (*Queue) CreateAuction

func (q *Queue) CreateAuction(ctx context.Context, a auctioneer.Auction) error

CreateAuction adds a new auction to the queue. The new auction will be handled immediately if workers are not busy.

func (*Queue) GetAuction

func (q *Queue) GetAuction(ctx context.Context, id auction.ID) (a *auctioneer.Auction, err error)

GetAuction returns an auction by id. If an auction is not found for id, ErrAuctionNotFound is returned.

func (*Queue) GetFinalizedAuctionBid

func (q *Queue) GetFinalizedAuctionBid(
	ctx context.Context,
	id auction.ID,
	bid auction.BidID,
) (*auctioneer.Bid, error)

GetFinalizedAuctionBid returns the bid given an auction ID and a bid ID. If an auction is not found for id, ErrAuctionNotFound is returned. If a bid is not found or id, ErrBidNotFound is returned. It also errors if the auction is not finalized or finalized with error.

func (*Queue) GetProviderFailureRates

func (q *Queue) GetProviderFailureRates(ctx context.Context) (map[string]int, error)

GetProviderFailureRates gets the recent failure rate (wins the auction but fails to make the deal) of storage providers.

func (*Queue) GetProviderOnChainEpoches

func (q *Queue) GetProviderOnChainEpoches(ctx context.Context) (map[string]uint64, error)

GetProviderOnChainEpoches gets the maximum epoches taken to make a deal on chain for storage providers.

func (*Queue) GetProviderWinningRates

func (q *Queue) GetProviderWinningRates(ctx context.Context) (map[string]int, error)

GetProviderWinningRates gets the recent winning rate of storage providers.

func (*Queue) MarkDealAsConfirmed

func (q *Queue) MarkDealAsConfirmed(
	ctx context.Context,
	auctionID auction.ID,
	bidID auction.BidID) error

MarkDealAsConfirmed marks the deal as confirmed by recording its confirmation time.

func (*Queue) MarkDealAsFailed

func (q *Queue) MarkDealAsFailed(
	ctx context.Context,
	auctionID auction.ID,
	bidID auction.BidID) error

MarkDealAsFailed marks the deal as failed by recording its failed time.

func (*Queue) SaveBidEvent

func (q *Queue) SaveBidEvent(ctx context.Context, eventType BidEventType, bidID string,
	attempts uint32, err string, ts time.Time) error

SaveBidEvent saves bid events.

func (*Queue) SaveStorageProvider

func (q *Queue) SaveStorageProvider(ctx context.Context, id string, version string, dealStartWindow uint64,
	cidGravityConfigured, cidGravityStrict bool) error

SaveStorageProvider saves the storage provider info.

func (*Queue) SetProposalCidDelivered

func (q *Queue) SetProposalCidDelivered(
	ctx context.Context,
	auctionID auction.ID,
	bidID auction.BidID,
	identifier string) error

SetProposalCidDelivered saves the proposal CID for the bid.

func (*Queue) SetProposalCidDeliveryError

func (q *Queue) SetProposalCidDeliveryError(
	ctx context.Context,
	auctionID auction.ID,
	bidID auction.BidID,
	errCause string) error

SetProposalCidDeliveryError saves the error happened when delivering the proposal cid to the winner.

func (*Queue) SetStorageProviderUnhealthy

func (q *Queue) SetStorageProviderUnhealthy(ctx context.Context, id string, err string) error

SetStorageProviderUnhealthy sets the storage provider to be unhealthy at the current point.

Directories

Path Synopsis
internal
db
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql migrations/002_bids_support_calculating_rates.down.sql migrations/002_bids_support_calculating_rates.up.sql migrations/003_auctions_add_client_address.down.sql migrations/003_auctions_add_client_address.up.sql migrations/004_bids_add_won_reason.down.sql migrations/004_bids_add_won_reason.up.sql migrations/005_auctions_add_providers.down.sql migrations/005_auctions_add_providers.up.sql migrations/006_consume_bidbot_events.down.sql migrations/006_consume_bidbot_events.up.sql migrations/007_bids_add_deal_failed_at.down.sql migrations/007_bids_add_deal_failed_at.up.sql migrations/008_leader_board.down.sql migrations/008_leader_board.up.sql migrations/009_leader_board_update.down.sql migrations/009_leader_board_update.up.sql migrations/010_leader_board_update2.down.sql migrations/010_leader_board_update2.up.sql migrations/011_leader_board_update3.down.sql migrations/011_leader_board_update3.up.sql migrations/012_leader_board_update4.down.sql migrations/012_leader_board_update4.up.sql migrations/013_leader_board_update5.down.sql migrations/013_leader_board_update5.up.sql migrations/014_leader_board_update6.down.sql migrations/014_leader_board_update6.up.sql
Package migrations generated by go-bindata.// sources: migrations/001_init.down.sql migrations/001_init.up.sql migrations/002_bids_support_calculating_rates.down.sql migrations/002_bids_support_calculating_rates.up.sql migrations/003_auctions_add_client_address.down.sql migrations/003_auctions_add_client_address.up.sql migrations/004_bids_add_won_reason.down.sql migrations/004_bids_add_won_reason.up.sql migrations/005_auctions_add_providers.down.sql migrations/005_auctions_add_providers.up.sql migrations/006_consume_bidbot_events.down.sql migrations/006_consume_bidbot_events.up.sql migrations/007_bids_add_deal_failed_at.down.sql migrations/007_bids_add_deal_failed_at.up.sql migrations/008_leader_board.down.sql migrations/008_leader_board.up.sql migrations/009_leader_board_update.down.sql migrations/009_leader_board_update.up.sql migrations/010_leader_board_update2.down.sql migrations/010_leader_board_update2.up.sql migrations/011_leader_board_update3.down.sql migrations/011_leader_board_update3.up.sql migrations/012_leader_board_update4.down.sql migrations/012_leader_board_update4.up.sql migrations/013_leader_board_update5.down.sql migrations/013_leader_board_update5.up.sql migrations/014_leader_board_update6.down.sql migrations/014_leader_board_update6.up.sql

Jump to

Keyboard shortcuts

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