2023-12-27 13:53:19 +00:00
|
|
|
package protocol
|
|
|
|
|
|
|
|
type StoreNodeRequestConfig struct {
|
|
|
|
WaitForResponse bool
|
|
|
|
StopWhenDataFound bool
|
2024-09-19 20:16:53 +00:00
|
|
|
InitialPageSize uint64
|
|
|
|
FurtherPageSize uint64
|
2023-12-27 13:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-19 20:16:53 +00:00
|
|
|
func WithInitialPageSize(initialPageSize uint64) StoreNodeRequestOption {
|
2023-12-27 13:53:19 +00:00
|
|
|
return func(c *StoreNodeRequestConfig) {
|
|
|
|
c.InitialPageSize = initialPageSize
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-19 20:16:53 +00:00
|
|
|
func WithFurtherPageSize(furtherPageSize uint64) StoreNodeRequestOption {
|
2023-12-27 13:53:19 +00:00
|
|
|
return func(c *StoreNodeRequestConfig) {
|
|
|
|
c.FurtherPageSize = furtherPageSize
|
|
|
|
}
|
|
|
|
}
|