-
Notifications
You must be signed in to change notification settings - Fork 920
GODRIVER-3522 Add support for the rawData option for time-series bucket access - PR0 #2121
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
GODRIVER-3522 Add support for the rawData option for time-series bucket access - PR0 #2121
Conversation
mongo/options/insertoptions.go
Outdated
|
|
||
| // SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries | ||
| // collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. | ||
| func (ioo *InsertOneOptionsBuilder) SetRawData(rawData bool) *InsertOneOptionsBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the scope:
Customers do not need to be able to set this in their applications. The interface will be marked “for internal use only”.
It sounds like we should add this as a deprecated option to InsertOneOptions and add a SetInternalInsertOneOptions function to the xoptions package, rather than exposing an options-level setter. It sounds like nobody will use this but internal teams, we can pivot in the future if necessary.
opts := options.InsertOne()
_ = xoptions.SetInternalInsertOneOptions(opts, "rawData", true)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the rawData option should be internal only. However, I doubt if it should be a client level option because it makes users to set up multiple clients to handle different scenario. IMO, for operation options following the Lister interface with a correlated "optionsBuilder" type, we can have a setter, for example:
// Deprecated: This function is for internal use only. It may be changed or removed in any release.
func (ao *AggregateOptionsBuilder) SetInternalOption(key string, option any) errorWhat are your thoughts?
cc: @matthewdale
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see an internal-only options pattern was added a few months ago: xoptions.SetInternalClientOptions. Can we extend that pattern for this use case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing pattern for SetInternalClientOptions is meant for ClientOptions. I think that adding rawData directly as a client option will cause inconvenience in most use cases, such as when setting an option for a specific operation.
Another option would be like xoptions.SetInternalAggregateOptions(opts *AggregateOptionsBuilder, key string, option any) error. We add a setter method for each OptionsBuilder in the xoptions package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qingyang-hu This sounds correct:
We add a setter method for each OptionsBuilder in the xoptions package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there are two good options based on the existing pattern of SetInternalClientOptions. I prefer the first one because it can be extended to support future internal options without any additional API changes. Does that sound reasonable?
Custom key/value pairs with xoptions setter
Add a Custom optionsutil.Options field to every CRUD method options struct (like ClientOptions.Custom). Add a function to xoptions to set custom k/v pairs in Custom.
E.g.
package options
type FindOptions struct {
// ...
Custom optionsutil.Options
}package xoptions
func SetFindOneCustom(f *options.FindOneOptionsBuilder, key string, option any) {
f.Opts = append(f.Opts, func(opts *FindOneOptions) error {
opts.Custom = optionsutil.WithValue(opts.Custom, key, option)
return nil
})
}RawData bool option with xoptions setter
Add a RawData *bool field to every CRUD method options struct. Add a function to xoptions to set RawData for each supported option type.
E.g.
package options
type FindOptions struct {
// ...
RawData *bool
}package xoptions
func SetFindOneRawData(f *options.FindOneOptionsBuilder, b bool) {
f.Opts = append(f.Opts, func(opts *FindOneOptions) error {
opts.RawData = &b
return nil
})
}
mongo/options/aggregateoptions.go
Outdated
| } | ||
|
|
||
| // SetRawData sets the value for the RawData field. If true, it allows the CRUD operations to access timeseries | ||
| // collections on the bucket-level. This option is only valid for MongoDB versions >= 9.0. The default value is false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a note that enabling it on pre-9.0 server versions has no effect. This applies for all SetRawData docs.
Note: This comment is irrelevant if we convert RawData into an internal-only option.
4b6b175 to
6724da3
Compare
prestonvasquez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a few suggestions
| err = xoptions.SetInternalCountOptions(opts, key, val.Boolean()) | ||
| if err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] w could reduce LoC here:
return nil, xoptions.SetInternalCountOptions(opts, key, val.Boolean())
x/mongo/driver/xoptions/options.go
Outdated
| // Deprecated: This function is for internal use only. It may be changed or removed in any release. | ||
| func SetInternalInsertOneOptions(a *options.InsertOneOptionsBuilder, key string, option any) error { | ||
| typeErrFunc := func(t string) error { | ||
| return fmt.Errorf("unexpected type for %s: %T is not %s", key, option, t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] suggest putting the key in quotes:
return fmt.Errorf("unexpected type for %q: %T is not %s", key, option, t)
x/mongo/driver/xoptions/options.go
Outdated
|
|
||
| // SetInternalInsertManyOptions sets internal options for InsertManyOptions. | ||
| // | ||
| // Deprecated: This function is for internal use only. It may be changed or removed in any release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need to add this deprecation notice to x package API.
mongo/options/aggregateoptions.go
Outdated
|
|
||
| // Deprecated: This option is for internal use only and should not be set. It may be changed or removed in any | ||
| // release. | ||
| CustomOptions optionsutil.Options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest renaming the new fields to Internal because it more clearly describes the purpose and matches the naming of the xoptions functions.
60277de to
53f0226
Compare
matthewdale
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
5e7fa80
into
mongodb:feature/godriver-3522-rawdata
…ntCount, delete, distinct, and insert (#2121)
GODRIVER-3522
Summary
Add support for the
rawDataoption for time-series bucket access - PR0Add support for the following operations:
Background & Motivation