chaokunyang commented on code in PR #2607:
URL: https://github.com/apache/fory/pull/2607#discussion_r2347984846
##########
go/fory/fory.go:
##########
@@ -24,13 +24,53 @@ import (
"sync"
)
+// ForyOption represents a configuration option for Fory instances
+type ForyOption func(*Fory)
+
+// WithCompatible sets the compatible mode for the Fory instance
+func WithCompatible(compatible bool) ForyOption {
+ return func(f *Fory) {
+ f.compatible = compatible
+ }
+}
+
+// WithReferenceTracking sets the reference tracking mode for the Fory instance
+func WithReferenceTracking(referenceTracking bool) ForyOption {
+ return func(f *Fory) {
+ f.referenceTracking = referenceTracking
+ }
+}
+
+// WithScopedMetaShare sets the scoped meta share mode for the Fory instance
+func WithScopedMetaShare(enabled bool) ForyOption {
+ return func(f *Fory) {
+ if f.metaContext == nil {
+ f.metaContext = NewMetaContext(enabled)
+ } else {
+ f.metaContext.SetScopedMetaShareEnabled(enabled)
+ }
+ }
+}
+
func NewFory(referenceTracking bool) *Fory {
+ return NewForyWithOptions(WithReferenceTracking(referenceTracking))
+}
+
+// NewForyWithOptions creates a Fory instance with configurable options
+func NewForyWithOptions(options ...ForyOption) *Fory {
fory := &Fory{
- refResolver: newRefResolver(referenceTracking),
- referenceTracking: referenceTracking,
+ refResolver: nil,
+ referenceTracking: false,
Review Comment:
Rename all `reference` to `ref`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]