54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
package protocol
|
|
|
|
type StoreNodeRequestConfig struct {
|
|
WaitForResponse bool
|
|
StopWhenDataFound bool
|
|
InitialPageSize uint64
|
|
FurtherPageSize uint64
|
|
}
|
|
|
|
type StoreNodeRequestOption func(*StoreNodeRequestConfig)
|
|
|
|
func defaultStoreNodeRequestConfig() StoreNodeRequestConfig {
|
|
return StoreNodeRequestConfig{
|
|
WaitForResponse: true,
|
|
StopWhenDataFound: true,
|
|
InitialPageSize: initialStoreNodeRequestPageSize,
|
|
FurtherPageSize: defaultStoreNodeRequestPageSize,
|
|
}
|
|
}
|
|
|
|
func buildStoreNodeRequestConfig(opts []StoreNodeRequestOption) StoreNodeRequestConfig {
|
|
cfg := defaultStoreNodeRequestConfig()
|
|
|
|
for _, opt := range opts {
|
|
opt(&cfg)
|
|
}
|
|
|
|
return cfg
|
|
}
|
|
|
|
func WithWaitForResponseOption(waitForResponse bool) StoreNodeRequestOption {
|
|
return func(c *StoreNodeRequestConfig) {
|
|
c.WaitForResponse = waitForResponse
|
|
}
|
|
}
|
|
|
|
func WithStopWhenDataFound(stopWhenDataFound bool) StoreNodeRequestOption {
|
|
return func(c *StoreNodeRequestConfig) {
|
|
c.StopWhenDataFound = stopWhenDataFound
|
|
}
|
|
}
|
|
|
|
func WithInitialPageSize(initialPageSize uint64) StoreNodeRequestOption {
|
|
return func(c *StoreNodeRequestConfig) {
|
|
c.InitialPageSize = initialPageSize
|
|
}
|
|
}
|
|
|
|
func WithFurtherPageSize(furtherPageSize uint64) StoreNodeRequestOption {
|
|
return func(c *StoreNodeRequestConfig) {
|
|
c.FurtherPageSize = furtherPageSize
|
|
}
|
|
}
|