github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/mempool/stdmap/options.go (about) 1 package stdmap 2 3 import ( 4 "github.com/onflow/flow-go/module/mempool" 5 ) 6 7 // OptionFunc is a function that can be provided to the backend on creation in 8 // order to set a certain custom option. 9 type OptionFunc func(*Backend) 10 11 // WithLimit can be provided to the backend on creation in order to set a point 12 // where it's time to check for ejection conditions. The actual size may continue 13 // to rise by the threshold for batch ejection (currently 128) 14 func WithLimit(limit uint) OptionFunc { 15 return func(be *Backend) { 16 be.guaranteedCapacity = limit 17 } 18 } 19 20 // WithEject can be provided to the backend on creation in order to set a custom 21 // eject function to pick the entity to be evicted upon overflow, as well as 22 // hooking into it for additional cleanup work. 23 func WithEject(eject EjectFunc) OptionFunc { 24 return func(be *Backend) { 25 be.eject = eject 26 be.batchEject = nil 27 } 28 } 29 30 // WithBackData sets the underlying backdata of the backend. 31 // BackData represents the underlying data structure that is utilized by mempool.Backend, as the 32 // core structure of maintaining data on memory-pools. 33 func WithBackData(backdata mempool.BackData) OptionFunc { 34 return func(be *Backend) { 35 be.backData = backdata 36 } 37 }