-
Notifications
You must be signed in to change notification settings - Fork 915
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
base: master
Are you sure you want to change the base?
Conversation
@@ -53,6 +54,18 @@ func (ioo *InsertOneOptionsBuilder) SetComment(comment interface{}) *InsertOneOp | |||
return ioo | |||
} | |||
|
|||
// 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) error
What 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
})
}
@@ -163,3 +164,15 @@ func (ao *AggregateOptionsBuilder) SetCustom(c bson.M) *AggregateOptionsBuilder | |||
|
|||
return ao | |||
} | |||
|
|||
// 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.
GODRIVER-3522
Summary
Add support for the
rawData
option for time-series bucket access - PR0Add support for the following operations:
Background & Motivation