data_providers

package
v0.38.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: AGPL-3.0 Imports: 12 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"
)

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

Variables

This section is empty.

Functions

This section is empty.

Types

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,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*BlockDigestsDataProvider, error)

NewBlockDigestsDataProvider creates a new instance of BlockDigestsDataProvider.

func (BlockDigestsDataProvider) Close

func (b BlockDigestsDataProvider) Close() error

Close terminates the data provider.

No errors are expected during normal operations.

func (BlockDigestsDataProvider) ID

func (b BlockDigestsDataProvider) ID() uuid.UUID

ID returns the unique identifier of the 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,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*BlockHeadersDataProvider, error)

NewBlockHeadersDataProvider creates a new instance of BlockHeadersDataProvider.

func (BlockHeadersDataProvider) Close

func (b BlockHeadersDataProvider) Close() error

Close terminates the data provider.

No errors are expected during normal operations.

func (BlockHeadersDataProvider) ID

func (b BlockHeadersDataProvider) ID() uuid.UUID

ID returns the unique identifier of the 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 BlocksArguments

type BlocksArguments struct {
	StartBlockID     flow.Identifier  // ID of the block to start subscription from
	StartBlockHeight uint64           // Height of the block to start subscription from
	BlockStatus      flow.BlockStatus // Status of blocks to subscribe to
}

BlocksArguments contains the arguments required for subscribing to blocks / block headers / block digests

func ParseBlocksArguments

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

ParseBlocksArguments validates and initializes the blocks arguments.

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,
	topic string,
	arguments models.Arguments,
	send chan<- interface{},
) (*BlocksDataProvider, error)

NewBlocksDataProvider creates a new instance of BlocksDataProvider.

func (BlocksDataProvider) Close

func (b BlocksDataProvider) Close() error

Close terminates the data provider.

No errors are expected during normal operations.

func (BlocksDataProvider) ID

func (b BlocksDataProvider) ID() uuid.UUID

ID returns the unique identifier of the 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() uuid.UUID
	// Topic returns the topic associated with the data provider.
	Topic() string
	// Close terminates the data provider.
	//
	// No errors are expected during normal operations.
	Close() error
	// 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 ID, 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, topic string, arguments 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,
) *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,
	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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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