github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/requester.go (about)

     1  package module
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  )
     6  
     7  type Requester interface {
     8  	// EntityByID will request an entity through the request engine backing
     9  	// the interface. The additional selector will be applied to the subset
    10  	// of valid providers for the entity and allows finer-grained control
    11  	// over which providers to request a given entity from. Use `filter.Any`
    12  	// if no additional restrictions are required. Data integrity of response
    13  	// will be checked upon arrival. This function should be used for requesting
    14  	// entites by their IDs.
    15  	EntityByID(entityID flow.Identifier, selector flow.IdentityFilter[flow.Identity])
    16  
    17  	// Query will request data through the request engine backing the interface.
    18  	// The additional selector will be applied to the subset
    19  	// of valid providers for the data and allows finer-grained control
    20  	// over which providers to request data from. Doesn't perform integrity check
    21  	// can be used to get entities without knowing their ID.
    22  	Query(key flow.Identifier, selector flow.IdentityFilter[flow.Identity])
    23  
    24  	// Force will force the dispatcher to send all possible batches immediately.
    25  	// It can be used in cases where responsiveness is of utmost importance, at
    26  	// the cost of additional network messages.
    27  	Force()
    28  }
    29  
    30  type NoopRequester struct{}
    31  
    32  func (n NoopRequester) EntityByID(entityID flow.Identifier, selector flow.IdentityFilter[flow.Identity]) {
    33  }
    34  
    35  func (n NoopRequester) Query(key flow.Identifier, selector flow.IdentityFilter[flow.Identity]) {}
    36  
    37  func (n NoopRequester) Force() {}
    38  
    39  func (n NoopRequester) WithHandle(func(flow.Identifier, flow.Entity)) Requester {
    40  	return n
    41  }