Documentation
¶
Index ¶
Constants ¶
const ( // DefaultRequestProviderWorkers is the default number of workers used to process entity requests. DefaultRequestProviderWorkers = uint(5) // DefaultEntityRequestCacheSize is the default max message queue size for the provider engine. // This equates to ~5GB of memory usage with a full queue (10M*500) DefaultEntityRequestCacheSize = 500 // DefaultMaxEntityIDs is the default maximum number of entity IDs that can be requested in a single // EntityRequest. This limit prevents amplification attacks where a small request triggers excessive // retrieval and serialization work. Note: the default requester engine (engine/common/requester) only // requests up to 32 entity IDs per batch (see BatchThreshold), so this limit provides ample headroom // for legitimate requests. DefaultMaxEntityIDs = 100 // DefaultMaxResponseByteSize is the default maximum cumulative byte size of encoded entities in a response. // This is set conservatively below the network's DefaultMaxUnicastMsgSize (10MB) to account for // message overhead (headers, encoding wrappers, etc.). The provider will stop adding entities to the // response once this budget is exceeded, preventing unbounded serialization work. DefaultMaxResponseByteSize = 8 * 1024 * 1024 // 8MB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
Engine is a generic provider engine, handling the fulfillment of entity requests on the flow network. It is the `reply` part of the request-reply pattern provided by the pair of generic exchange engines.
func New ¶
func New( log zerolog.Logger, metrics module.EngineMetrics, net network.EngineRegistry, me module.Local, state protocol.State, requestQueue engine.MessageStore, requestWorkers uint, channel channels.Channel, selector flow.IdentityFilter[flow.Identity], retrieve RetrieveFunc, opts ...Option) (*Engine, error)
New creates a new provider engine, operating on the provided network channel, and accepting requests for entities from a node within the set obtained by applying the provided selector filter. It uses the injected retrieve function to manage the fullfilment of these requests.
type Option ¶ added in v0.49.0
type Option func(*Engine)
Option is a functional option for configuring the provider Engine.
func WithMaxEntityIDs ¶ added in v0.49.0
WithMaxEntityIDs sets the maximum number of entity IDs that can be requested in a single request. Requests with more IDs will be truncated to this limit.
func WithMaxResponseByteSize ¶ added in v0.49.0
WithMaxResponseByteSize sets the maximum cumulative byte size of encoded entities in a response. The provider will stop adding entities once this budget is exceeded.
type RetrieveFunc ¶
type RetrieveFunc func(flow.Identifier) (flow.Entity, error)
RetrieveFunc is a function provided to the provider engine upon construction. It is used by the engine when receiving requests in order to retrieve the related entities. It is important that the retrieve function return a `storage.ErrNotFound` error if the entity does not exist locally; otherwise, the logic will error and not send responses when failing to retrieve entities.