data_providers

package
v0.38.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventsTopic                        = "events"
	AccountStatusesTopic               = "account_statuses"
	BlocksTopic                        = "blocks"
	BlockHeadersTopic                  = "block_headers"
	BlockDigestsTopic                  = "block_digests"
	TransactionStatusesTopic           = "transaction_statuses"
	SendAndGetTransactionStatusesTopic = "send_and_get_transaction_statuses"
)

Constants defining various topic names used to specify different types of data providers.

Variables

This section is empty.

Functions

func ParseBlocksArguments

func ParseBlocksArguments(arguments models.Arguments) (blocksArguments, error)

ParseBlocksArguments validates and initializes the blocks arguments.

func ParseStartBlock

func ParseStartBlock(arguments models.Arguments) (flow.Identifier, uint64, error)

Types

type AccountStatusesDataProvider

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

func NewAccountStatusesDataProvider

func NewAccountStatusesDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	stateStreamApi state_stream.API,
	subscriptionID string,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
	chain flow.Chain,
	eventFilterConfig state_stream.EventFilterConfig,
	heartbeatInterval uint64,
) (*AccountStatusesDataProvider, error)

NewAccountStatusesDataProvider creates a new instance of AccountStatusesDataProvider.

func (AccountStatusesDataProvider) Arguments

func (b AccountStatusesDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (AccountStatusesDataProvider) Close

func (b AccountStatusesDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (AccountStatusesDataProvider) ID

func (b AccountStatusesDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*AccountStatusesDataProvider) Run

Run starts processing the subscription for events and handles responses.

No errors are expected during normal operations.

func (AccountStatusesDataProvider) Topic

func (b AccountStatusesDataProvider) Topic() string

Topic returns the topic associated with the data provider.

type BlockDigestsDataProvider

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

BlockDigestsDataProvider is responsible for providing block digests

func NewBlockDigestsDataProvider

func NewBlockDigestsDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	api access.API,
	subscriptionID string,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*BlockDigestsDataProvider, error)

NewBlockDigestsDataProvider creates a new instance of BlockDigestsDataProvider.

func (BlockDigestsDataProvider) Arguments

func (b BlockDigestsDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (BlockDigestsDataProvider) Close

func (b BlockDigestsDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (BlockDigestsDataProvider) ID

func (b BlockDigestsDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*BlockDigestsDataProvider) Run

Run starts processing the subscription for block digests and handles responses.

No errors are expected during normal operations.

func (BlockDigestsDataProvider) Topic

func (b BlockDigestsDataProvider) Topic() string

Topic returns the topic associated with the data provider.

type BlockHeadersDataProvider

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

BlockHeadersDataProvider is responsible for providing block headers

func NewBlockHeadersDataProvider

func NewBlockHeadersDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	api access.API,
	subscriptionID string,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*BlockHeadersDataProvider, error)

NewBlockHeadersDataProvider creates a new instance of BlockHeadersDataProvider.

func (BlockHeadersDataProvider) Arguments

func (b BlockHeadersDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (BlockHeadersDataProvider) Close

func (b BlockHeadersDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (BlockHeadersDataProvider) ID

func (b BlockHeadersDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*BlockHeadersDataProvider) Run

Run starts processing the subscription for block headers and handles responses.

No errors are expected during normal operations.

func (BlockHeadersDataProvider) Topic

func (b BlockHeadersDataProvider) Topic() string

Topic returns the topic associated with the data provider.

type BlocksDataProvider

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

BlocksDataProvider is responsible for providing blocks

func NewBlocksDataProvider

func NewBlocksDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	api access.API,
	subscriptionID string,
	linkGenerator commonmodels.LinkGenerator,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*BlocksDataProvider, error)

NewBlocksDataProvider creates a new instance of BlocksDataProvider.

func (BlocksDataProvider) Arguments

func (b BlocksDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (BlocksDataProvider) Close

func (b BlocksDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (BlocksDataProvider) ID

func (b BlocksDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*BlocksDataProvider) Run

func (p *BlocksDataProvider) Run() error

Run starts processing the subscription for blocks and handles responses.

No errors are expected during normal operations.

func (BlocksDataProvider) Topic

func (b BlocksDataProvider) Topic() string

Topic returns the topic associated with the data provider.

type DataProvider

type DataProvider interface {
	// ID returns the unique identifier of the data provider.
	ID() string
	// Topic returns the topic associated with the data provider.
	Topic() string
	// Arguments returns the arguments associated with the data provider.
	Arguments() models.Arguments
	// Close terminates the data provider.
	//
	// No errors are expected during normal operations.
	Close()
	// Run starts processing the subscription and handles responses.
	//
	// The separation of the data provider's creation and its Run() method
	// allows for better control over the subscription lifecycle. By doing so,
	// a confirmation message can be sent to the client immediately upon
	// successful subscription creation or failure. This ensures any required
	// setup or preparation steps can be handled prior to initiating the
	// subscription and data streaming process.
	//
	// Run() begins the actual processing of the subscription. At this point,
	// the context used for provider creation is no longer needed, as all
	// necessary preparation steps should have been completed.
	//
	// No errors are expected during normal operations.
	Run() error
}

The DataProvider is the interface abstracts of the actual data provider used by the WebSocketCollector. It provides methods for retrieving the provider's unique SubscriptionID, topic, and a methods to close and run the provider.

type DataProviderFactory

type DataProviderFactory interface {
	// NewDataProvider creates a new data provider based on the specified topic
	// and configuration parameters.
	//
	// No errors are expected during normal operations.
	NewDataProvider(
		ctx context.Context,
		subscriptionID string,
		topic string,
		args models.Arguments,
		ch chan<- interface{},
	) (DataProvider, error)
}

DataProviderFactory defines an interface for creating data providers based on specified topics. The factory abstracts the creation process and ensures consistent access to required APIs.

type DataProviderFactoryImpl

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

DataProviderFactoryImpl is an implementation of the DataProviderFactory interface. It is responsible for creating data providers based on the requested topic. It manages access to logging and relevant APIs needed to retrieve data.

func NewDataProviderFactory

func NewDataProviderFactory(
	logger zerolog.Logger,
	stateStreamApi state_stream.API,
	accessApi access.API,
	chain flow.Chain,
	eventFilterConfig state_stream.EventFilterConfig,
	heartbeatInterval uint64,
	linkGenerator commonmodels.LinkGenerator,
) *DataProviderFactoryImpl

NewDataProviderFactory creates a new DataProviderFactory

Parameters: - logger: Used for logging within the data providers. - eventFilterConfig: Configuration for filtering events from state streams. - stateStreamApi: API for accessing data from the Flow state stream API. - accessApi: API for accessing data from the Flow Access API.

func (*DataProviderFactoryImpl) NewDataProvider

func (s *DataProviderFactoryImpl) NewDataProvider(ctx context.Context, subscriptionID string, topic string, arguments models.Arguments, ch chan<- interface{}) (DataProvider, error)

NewDataProvider creates a new data provider based on the specified topic and configuration parameters.

Parameters: - ctx: Context for managing request lifetime and cancellation. - topic: The topic for which a data provider is to be created. - arguments: Configuration arguments for the data provider. - ch: Channel to which the data provider sends data.

No errors are expected during normal operations.

type EventsDataProvider

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

EventsDataProvider is responsible for providing events

func NewEventsDataProvider

func NewEventsDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	stateStreamApi state_stream.API,
	subscriptionID string,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
	chain flow.Chain,
	eventFilterConfig state_stream.EventFilterConfig,
	heartbeatInterval uint64,
) (*EventsDataProvider, error)

NewEventsDataProvider creates a new instance of EventsDataProvider.

func (EventsDataProvider) Arguments

func (b EventsDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (EventsDataProvider) Close

func (b EventsDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (EventsDataProvider) ID

func (b EventsDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*EventsDataProvider) Run

func (p *EventsDataProvider) Run() error

Run starts processing the subscription for events and handles responses.

No errors are expected during normal operations.

func (EventsDataProvider) Topic

func (b EventsDataProvider) Topic() string

Topic returns the topic associated with the data provider.

type SendAndGetTransactionStatusesDataProvider

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

func NewSendAndGetTransactionStatusesDataProvider

func NewSendAndGetTransactionStatusesDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	api access.API,
	subscriptionID string,
	linkGenerator commonmodels.LinkGenerator,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*SendAndGetTransactionStatusesDataProvider, error)

func (SendAndGetTransactionStatusesDataProvider) Arguments

func (b SendAndGetTransactionStatusesDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (SendAndGetTransactionStatusesDataProvider) Close

func (b SendAndGetTransactionStatusesDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (SendAndGetTransactionStatusesDataProvider) ID

func (b SendAndGetTransactionStatusesDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*SendAndGetTransactionStatusesDataProvider) Run

Run starts processing the subscription for events and handles responses.

No errors are expected during normal operations.

func (SendAndGetTransactionStatusesDataProvider) Topic

func (b SendAndGetTransactionStatusesDataProvider) Topic() string

Topic returns the topic associated with the data provider.

type TransactionStatusesDataProvider

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

TransactionStatusesDataProvider is responsible for providing tx statuses

func NewTransactionStatusesDataProvider

func NewTransactionStatusesDataProvider(
	ctx context.Context,
	logger zerolog.Logger,
	api access.API,
	subscriptionID string,
	linkGenerator commonmodels.LinkGenerator,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*TransactionStatusesDataProvider, error)

func (TransactionStatusesDataProvider) Arguments

func (b TransactionStatusesDataProvider) Arguments() models.Arguments

Arguments returns the arguments associated with the data provider.

func (TransactionStatusesDataProvider) Close

func (b TransactionStatusesDataProvider) Close()

Close terminates the data provider.

No errors are expected during normal operations.

func (TransactionStatusesDataProvider) ID

func (b TransactionStatusesDataProvider) ID() string

ID returns the subscription ID associated with current data provider

func (*TransactionStatusesDataProvider) Run

Run starts processing the subscription for events and handles responses.

No errors are expected during normal operations.

func (TransactionStatusesDataProvider) Topic

func (b TransactionStatusesDataProvider) Topic() string

Topic returns the topic associated with the data provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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