chore: use flush_every_ms and change datatype to time.Duration

This commit is contained in:
Richard Ramos 2023-08-23 11:08:36 -04:00
parent 8167006b94
commit a706089284
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760

View File

@ -3,6 +3,7 @@ package rln
import (
"bytes"
"encoding/binary"
"encoding/json"
"time"
)
@ -80,11 +81,28 @@ const (
)
type TreeConfig struct {
CacheCapacity int `json:"cache_capacity"`
Mode TreeMode `json:"mode"`
Compression bool `json:"compression"`
FlushInterval int `json:"flush_interval"`
Path string `json:"path"`
CacheCapacity int
Mode TreeMode
Compression bool
FlushInterval time.Duration
Path string
}
func (t TreeConfig) MarshalJSON() ([]byte, error) {
output := struct {
CacheCapacity int `json:"cache_capacity"`
Mode TreeMode `json:"mode"`
Compression bool `json:"compression"`
FlushInterval uint `json:"flush_every_ms"`
Path string `json:"path"`
}{
CacheCapacity: t.CacheCapacity,
Mode: t.Mode,
Compression: t.Compression,
FlushInterval: uint(t.FlushInterval) / uint(time.Millisecond),
Path: t.Path,
}
return json.Marshal(output)
}
type config struct {