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

Remove default options from ResolveStorageOptions #180

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ type StorageOptions struct {
}

// ResolveStorageOptions turns a variadic array of storage options into a StorageOptions instance.
func ResolveStorageOptions(defaults *StorageOptions, opts ...func(*StorageOptions)) *StorageOptions {
if defaults == nil {
defaults = &StorageOptions{
BatchMaxSize: DefaultBatchMaxSize,
}
func ResolveStorageOptions(opts ...func(*StorageOptions)) *StorageOptions {
defaults := &StorageOptions{
BatchMaxSize: DefaultBatchMaxSize,
}
for _, opt := range opts {
opt(defaults)
Expand Down
2 changes: 1 addition & 1 deletion storage/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type Config struct {

// New creates a new instance of the GCP based Storage.
func New(ctx context.Context, cfg Config, opts ...func(*tessera.StorageOptions)) (*Storage, error) {
opt := tessera.ResolveStorageOptions(nil, opts...)
opt := tessera.ResolveStorageOptions(opts...)
if opt.PushbackMaxOutstanding == 0 {
opt.PushbackMaxOutstanding = DefaultPushbackMaxOutstanding
}
Expand Down
5 changes: 1 addition & 4 deletions storage/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ type Storage struct {
// New creates a new instance of the MySQL-based Storage.
// Note that `tessera.WithCheckpointSignerVerifier()` is mandatory in the `opts` argument.
func New(ctx context.Context, db *sql.DB, opts ...func(*tessera.StorageOptions)) (*Storage, error) {
opt := tessera.ResolveStorageOptions(&tessera.StorageOptions{
BatchMaxAge: defaultQueueMaxAge,
BatchMaxSize: defaultBatchMaxSize,
}, opts...)
opt := tessera.ResolveStorageOptions(opts...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behaviour of mysql to switch to a batch size of 1 instead of 256?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, but that brings it into line with the others, and I've just changed the "line" to 256 within 250ms.

We can revisit in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaultBatchMaxSize and defaultQueueMaxAge consts in this file can be removed.

s := &Storage{
db: db,
newCheckpoint: opt.NewCP,
Expand Down
2 changes: 1 addition & 1 deletion storage/posix/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func New(ctx context.Context, path string, curTree func() (uint64, []byte, error
if err != nil {
panic(err)
}
opt := tessera.ResolveStorageOptions(nil, opts...)
opt := tessera.ResolveStorageOptions(opts...)

r := &Storage{
path: path,
Expand Down
Loading