Files
ocis/services/search/pkg/engine/bleve/option.go
Juan Pablo Villafáñez 758bda94ba refactor: use a closeFn in the GetIndex instead of checking value
The closeFn implicitly checks the value as the implementation decides
what to do (either do nothing or close the index). Calling the closeFn
is safe and we don't need conditions.
2025-05-29 09:56:11 +02:00

28 lines
788 B
Go

package bleve
// GetIndexOption is a function that sets some option for the GetIndex method.
type GetIndexOption func(o *GetIndexOptions)
// GetIndexOptions contains the options for the GetIndex method.
type GetIndexOptions struct {
ReadOnly bool
}
// ReadOnly is an option to opens the index in read-only mode.
// This option should allow running multiple read-only operations in parallel.
// The behavior of write operations is not defined when this option is used.
func ReadOnly(b bool) GetIndexOption {
return func(o *GetIndexOptions) {
o.ReadOnly = b
}
}
// newGetIndexOptions creates a new GetIndexOptions with the given options.
func newGetIndexOptions(opts ...GetIndexOption) GetIndexOptions {
o := GetIndexOptions{}
for _, opt := range opts {
opt(&o)
}
return o
}