Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Option Initialization Pattern #37

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

ghosx
Copy link
Contributor

@ghosx ghosx commented Jun 17, 2024

Default:

walFile, _ := wal.Open()

Custon:

walFile, err = wal.Open(
		wal.WithDirPath(dir),
		wal.WithSegmentFileExt(".SEG"),
		wal.WithSegmentSize(wal.GB),
	)

@roseduan
Copy link
Contributor

The following format is more easy to understand?

func (opt Options) WithSegmentFileExt(ext string) Options {
    opt.SegmentFileExt = ext
    return opt
}

@ghosx
Copy link
Contributor Author

ghosx commented Jun 18, 2024

The following format is more easy to understand?

func (opt Options) WithSegmentFileExt(ext string) Options {
    opt.SegmentFileExt = ext
    return opt
}

wal.Open() support Default Options,if use your way, must be explicitly passed in each time it is used

https://dev.to/fufu/functional-options-pattern-in-go-42lm

@roseduan roseduan merged commit 509b76a into rosedblabs:main Jun 21, 2024
2 checks passed
roseduan added a commit that referenced this pull request Jul 4, 2024
This reverts commit 509b76a.

This commit will also acquire a lot changes in rosedb and lotusdb,
revert it temporarily.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants