mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
server: Implement WithMmapSize option for backend config
Accept a third argument for NewDefaultBackend for overrides to the BackendConfig. Add a new function, WithMmapSize, which modifies the backend config to provide a custom InitiamMmapSize. Backports commit: d69adf45f9e95661966204460f019b8164aaef12 / PR: #17277 Signed-off-by: Ivan Valdes <ivan@vald.es>
This commit is contained in:
parent
0f0af63eaa
commit
6abc349dc9
@ -151,6 +151,8 @@ type BackendConfig struct {
|
||||
Hooks Hooks
|
||||
}
|
||||
|
||||
type BackendConfigOption func(*BackendConfig)
|
||||
|
||||
func DefaultBackendConfig() BackendConfig {
|
||||
return BackendConfig{
|
||||
BatchInterval: defaultBatchInterval,
|
||||
@ -163,9 +165,19 @@ func New(bcfg BackendConfig) Backend {
|
||||
return newBackend(bcfg)
|
||||
}
|
||||
|
||||
func NewDefaultBackend(path string) Backend {
|
||||
func WithMmapSize(size uint64) BackendConfigOption {
|
||||
return func(bcfg *BackendConfig) {
|
||||
bcfg.MmapSize = size
|
||||
}
|
||||
}
|
||||
|
||||
func NewDefaultBackend(path string, opts ...BackendConfigOption) Backend {
|
||||
bcfg := DefaultBackendConfig()
|
||||
bcfg.Path = path
|
||||
for _, opt := range opts {
|
||||
opt(&bcfg)
|
||||
}
|
||||
|
||||
return newBackend(bcfg)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user