msgbroker

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: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NewBatchCreatedTopic is the topic name for new-batch-created messages.
	NewBatchCreatedTopic TopicName = "new-batch-created"
	// NewBatchPreparedTopic is the topic name for new-batch-prepared messages.
	NewBatchPreparedTopic = "new-batch-prepared"
	// ReadyToBatchTopic is the topic name for ready-to-batch messages.
	ReadyToBatchTopic = "ready-to-batch"
	// ReadyToCreateDealsTopic is the topic name for ready-to-create-deals messages.
	ReadyToCreateDealsTopic = "ready-to-create-deals"
	// FinalizedDealTopic is the topic name for finalized-deal messages.
	FinalizedDealTopic = "finalized-deal"
	// DealProposalAcceptedTopic is the topic name for deal-proposal-accepted messages.
	DealProposalAcceptedTopic = "deal-proposal-accepted"
	// BoostDealProposalAcceptedTopic is the topic name for boost-deal-proposal-accepted messages.
	BoostDealProposalAcceptedTopic = "boost-deal-proposal-accepted"

	// ReadyToAuctionTopic is the topic name for ready-to-auction messages.
	ReadyToAuctionTopic = "ready-to-auction"

	// AuctionClosedTopic is the topic name for auction-closed messages.
	AuctionClosedTopic = "auction-closed"
	// AuctionStartedTopic is the topic name for auction-started messages.
	AuctionStartedTopic = "auction-started"
	// AuctionBidReceivedTopic is the topic name for auction-bid-received messages.
	AuctionBidReceivedTopic = "auction-bid-received"
	// AuctionWinnerSelectedTopic is the topic name for auction-winner-selected messages.
	AuctionWinnerSelectedTopic = "auction-winner-selected"
	// AuctionWinnerAckedTopic is the topic name for auction-winner-acked messages.
	AuctionWinnerAckedTopic = "auction-winner-acked"
	// AuctionProposalCidDeliveredTopic is the topic name for auction-proposal-cid-delivered messages.
	AuctionProposalCidDeliveredTopic = "auction-proposal-cid-delivered"
)

Variables

View Source
var DefaultRegisterHandlerConfig = RegisterHandlerConfig{
	AckDeadline: time.Second * 10,
}

DefaultRegisterHandlerConfig is the default configuration for topic subscriptions.

Functions

func AuctionToPbSummary

func AuctionToPbSummary(a *auctioneer.Auction) *pb.AuctionSummary

AuctionToPbSummary converts auctioneer.Auction to pb.

func PublishMsgAuctionBidReceived

func PublishMsgAuctionBidReceived(ctx context.Context, mb MsgBroker, a *pb.AuctionSummary, b *auctioneer.Bid) error

PublishMsgAuctionBidReceived .

func PublishMsgAuctionClosed

func PublishMsgAuctionClosed(ctx context.Context, mb MsgBroker, au broker.ClosedAuction) error

PublishMsgAuctionClosed publishes a message to the auction-closed topic.

func PublishMsgAuctionProposalCidDelivered

func PublishMsgAuctionProposalCidDelivered(ctx context.Context, mb MsgBroker, auctionID auction.ID,
	bidderID peer.ID, bidID auction.BidID, proposalCid cid.Cid, errorCause string) error

PublishMsgAuctionProposalCidDelivered .

func PublishMsgAuctionStarted

func PublishMsgAuctionStarted(ctx context.Context, mb MsgBroker, a *pb.AuctionSummary) error

PublishMsgAuctionStarted .

func PublishMsgAuctionWinnerAcked

func PublishMsgAuctionWinnerAcked(ctx context.Context, mb MsgBroker, a *pb.AuctionSummary, b *auctioneer.Bid) error

PublishMsgAuctionWinnerAcked .

func PublishMsgAuctionWinnerSelected

func PublishMsgAuctionWinnerSelected(ctx context.Context, mb MsgBroker, a *pb.AuctionSummary, b *auctioneer.Bid) error

PublishMsgAuctionWinnerSelected .

func PublishMsgBoostDealProposalAccepted

func PublishMsgBoostDealProposalAccepted(
	ctx context.Context,
	mb MsgBroker,
	sdID broker.BatchID,
	auctionID auction.ID,
	bidID auction.BidID,
	storageProviderID string,
	dealUID string) error

PublishMsgBoostDealProposalAccepted publishes a message to the deal-proposal-accepted topic.

func PublishMsgDealProposalAccepted

func PublishMsgDealProposalAccepted(
	ctx context.Context,
	mb MsgBroker,
	sdID broker.BatchID,
	auctionID auction.ID,
	bidID auction.BidID,
	storageProviderID string,
	propCid cid.Cid) error

PublishMsgDealProposalAccepted publishes a message to the deal-proposal-accepted topic.

func PublishMsgFinalizedDeal

func PublishMsgFinalizedDeal(ctx context.Context, mb MsgBroker, fd broker.FinalizedDeal) error

PublishMsgFinalizedDeal publishes a message to the finalized-deal topic.

func PublishMsgNewBatchCreated

func PublishMsgNewBatchCreated(
	ctx context.Context,
	mb MsgBroker,
	batchID broker.BatchID,
	batchCid cid.Cid,
	batchSize int64,
	srIDs []broker.StorageRequestID,
	origin string,
	manifest []byte,
	carURL string) error

PublishMsgNewBatchCreated publishes a message to the new-batch-created topic.

func PublishMsgNewBatchPrepared

func PublishMsgNewBatchPrepared(
	ctx context.Context,
	mb MsgBroker,
	baID broker.BatchID,
	pieceCid cid.Cid,
	pieceSize uint64) error

PublishMsgNewBatchPrepared publishes a message to the new-batch-prepared topic.

func PublishMsgReadyToAuction

func PublishMsgReadyToAuction(
	ctx context.Context,
	mb MsgBroker,
	id auction.ID,
	BatchID broker.BatchID,
	payloadCid cid.Cid,
	dealSize uint64,
	dealDuration,
	dealReplication int,
	dealVerified bool,
	excludedStorageProviders []string,
	filEpochDeadline uint64,
	sources auction.Sources,
	clientAddress string,
	providers []address.Address) error

PublishMsgReadyToAuction publishes a message to the ready-to-auction topic.

func PublishMsgReadyToBatch

func PublishMsgReadyToBatch(ctx context.Context, mb MsgBroker, dataCids []ReadyToBatchData) error

PublishMsgReadyToBatch publishes a message to the ready-to-batch topic.

func PublishMsgReadyToCreateDeals

func PublishMsgReadyToCreateDeals(
	ctx context.Context,
	mb MsgBroker,
	ads dealer.AuctionDeals) error

PublishMsgReadyToCreateDeals publishes a message to the ready-to-create-deals topic.

func RegisterHandlers

func RegisterHandlers(mb MsgBroker, s interface{}, opts ...Option) error

RegisterHandlers automatically calls mb.RegisterTopicHandler in the methods that s might satisfy on known XXXListener interfaces. This allows to automatically wire s to receive messages from topics of implemented handlers.

Types

type AuctionClosedListener

type AuctionClosedListener interface {
	OnAuctionClosed(context.Context, OperationID, broker.ClosedAuction) error
}

AuctionClosedListener is a handler for auction-closed topic.

type AuctionEventsListener

type AuctionEventsListener interface {
	OnAuctionStarted(context.Context, time.Time, *pb.AuctionSummary)
	OnAuctionBidReceived(context.Context, time.Time, *pb.AuctionSummary, *auctioneer.Bid)
	OnAuctionWinnerSelected(context.Context, time.Time, *pb.AuctionSummary, *auctioneer.Bid)
	OnAuctionWinnerAcked(context.Context, time.Time, *pb.AuctionSummary, *auctioneer.Bid)
	OnAuctionProposalCidDelivered(ctx context.Context, ts time.Time, auctionID,
		bidderID, bidID, proposalCid, errorCause string)
	AuctionClosedListener
}

AuctionEventsListener is a handler for auction events related topics. Note that the methods do not return error, since the caller can do nothing if something happens on the consuming side.

type BoostDealProposalAcceptedListener

type BoostDealProposalAcceptedListener interface {
	OnBoostDealProposalAccepted(context.Context, auction.ID, auction.BidID, string) error
}

BoostDealProposalAcceptedListener is a handler for boost-deal-proposal-accepted topic.

type DealProposalAcceptedListener

type DealProposalAcceptedListener interface {
	OnDealProposalAccepted(context.Context, auction.ID, auction.BidID, cid.Cid) error
}

DealProposalAcceptedListener is a handler for deal-proposal-accepted topic.

type FinalizedDealListener

type FinalizedDealListener interface {
	OnFinalizedDeal(context.Context, OperationID, broker.FinalizedDeal) error
}

FinalizedDealListener is a handler for finalized-deal topic.

type MsgBroker

type MsgBroker interface {
	// RegisterTopicHandler registers a handler to a topic, with a defined
	// subscription defined by the underlying implementation. Is highly recommended
	// to register handlers in a type-safe way using RegisterHandlers().
	RegisterTopicHandler(topic TopicName, handler TopicHandler, opts ...Option) error

	// PublishMsg publishes a message to the desired topic.
	PublishMsg(ctx context.Context, topicName TopicName, data []byte) error
}

MsgBroker is a message-broker for async message communication.

type NewBatchCreatedListener

type NewBatchCreatedListener interface {
	OnNewBatchCreated(
		context.Context,
		broker.BatchID,
		cid.Cid,
		int64,
		[]broker.StorageRequestID,
		string,
		[]byte,
		*url.URL) error
}

NewBatchCreatedListener is a handler for new-batch-created topic.

type NewBatchPreparedListener

type NewBatchPreparedListener interface {
	OnNewBatchPrepared(context.Context, broker.BatchID, broker.DataPreparationResult) error
}

NewBatchPreparedListener is a handler for new-batch-prepared topic.

type OperationID

type OperationID string

OperationID is a unique identifier for messages.

type Option

type Option func(*RegisterHandlerConfig) error

Option applies a configuration on RegisterHandlerConfig.

func WithACKDeadline

func WithACKDeadline(deadline time.Duration) Option

WithACKDeadline configures the deadline for the message broker subscription. The duration can't be greater than 10min.

type ReadyToAuctionListener

type ReadyToAuctionListener interface {
	OnReadyToAuction(
		ctx context.Context,
		id auction.ID,
		BatchID broker.BatchID,
		payloadCid cid.Cid,
		dealSize uint64,
		dealDuration uint64,
		dealReplication uint32,
		dealVerified bool,
		excludedStorageProviders []string,
		filEpochDeadline uint64,
		sources auction.Sources,
		clientAddress string,
		providers []string,
	) error
}

ReadyToAuctionListener is a handler for finalized-deal topic.

type ReadyToBatchData

type ReadyToBatchData struct {
	StorageRequestID broker.StorageRequestID
	DataCid          cid.Cid
	Origin           string
}

ReadyToBatchData contains storage request data information to be batched.

type ReadyToBatchListener

type ReadyToBatchListener interface {
	OnReadyToBatch(context.Context, OperationID, []ReadyToBatchData) error
}

ReadyToBatchListener is a handler for ready-to-batch topic.

type ReadyToCreateDealsListener

type ReadyToCreateDealsListener interface {
	OnReadyToCreateDeals(context.Context, dealer.AuctionDeals) error
}

ReadyToCreateDealsListener is a handler for ready-to-create-deals topic.

type RegisterHandlerConfig

type RegisterHandlerConfig struct {
	AckDeadline time.Duration
}

RegisterHandlerConfig contains configuration for topic subscriptions.

func ApplyRegisterHandlerOptions

func ApplyRegisterHandlerOptions(opts ...Option) (RegisterHandlerConfig, error)

ApplyRegisterHandlerOptions applies a list of Option to the default configuration.

type TopicHandler

type TopicHandler func(context.Context, []byte) error

TopicHandler is function that processes a received message. If no error is returned, the message will be automatically acked. If an error is returned, the message will be automatically nacked.

type TopicName

type TopicName string

TopicName is a topic name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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