Open sjcsjc123 opened 1 year ago
I've implemented a demo in my forked repository, and I would like to ask if this is the correct way to modify? my forked repository implementation :
package config
type FlyDBOption func(*Options)
func WithDirPath(dirPath string) FlyDBOption {
return func(o *Options) {
o.DirPath = dirPath
}
}
func WithDataFileSize(dataFileSize int64) FlyDBOption {
return func(o *Options) {
o.DataFileSize = dataFileSize
}
}
func WithSyncWrite(syncWrite bool) FlyDBOption {
return func(o *Options) {
o.SyncWrite = syncWrite
}
}
func WithIndexType(indexType IndexerType) FlyDBOption {
return func(o *Options) {
o.IndexType = indexType
}
}
func WithFIOType(fioType FIOType) FlyDBOption {
return func(o *Options) {
o.FIOType = fioType
}
}
func NewOptions(opts ...FlyDBOption) *Options {
newOptions := DefaultOptions
for _, opt := range opts {
opt(&newOptions)
}
return &newOptions
}
example :
func main() {
db, err := flydb.NewFlyDB(config.WithDirPath("/tmp/flydb"))
if err != nil {
panic(err)
}
err = db.Put([]byte("name"), []byte("flydb-example"))
if err != nil {
panic(err)
}
val, err := db.Get([]byte("name"))
if err != nil {
panic(err)
}
fmt.Println("name value => ", string(val))
err = db.Delete([]byte("name"))
if err != nil {
panic(err)
}
}
I would like to know if adjustments are needed for NewColumn and engine.NewDB? However, modifying these two methods would require changing a lot of code. If NewFlyDB is to be changed, then the previous versions will not be compatible.
Do I need to submit a PR to provide my code?
Large amounts of code modifications will not be considered until FlyDB 2.0
is released
The configuration method in the figure is relatively common, and it is configured using the method of 'with' and 'parameter name'