...

Source file src/github.com/launchdarkly/go-server-sdk-evaluation/v2/evaluator_options.go

Documentation: github.com/launchdarkly/go-server-sdk-evaluation/v2

     1  package evaluation
     2  
     3  import "github.com/launchdarkly/go-sdk-common/v3/ldlog"
     4  
     5  // EvaluatorOption is an optional parameter for NewEvaluator.
     6  type EvaluatorOption interface {
     7  	apply(e *evaluator)
     8  }
     9  
    10  type evaluatorOptionBigSegmentProvider struct{ bigSegmentProvider BigSegmentProvider }
    11  
    12  // EvaluatorOptionBigSegmentProvider is an option for NewEvaluator that specifies a
    13  // BigSegmentProvider for evaluating big segment membership. If the parameter is nil, it will
    14  // be treated the same as a BigSegmentProvider that always returns a "store not configured"
    15  // status.
    16  func EvaluatorOptionBigSegmentProvider(bigSegmentProvider BigSegmentProvider) EvaluatorOption {
    17  	return evaluatorOptionBigSegmentProvider{bigSegmentProvider: bigSegmentProvider}
    18  }
    19  
    20  func (o evaluatorOptionBigSegmentProvider) apply(e *evaluator) {
    21  	e.bigSegmentProvider = o.bigSegmentProvider
    22  }
    23  
    24  type evaluatorOptionEnableSecondaryKey struct{ enable bool }
    25  
    26  // EvaluatorOptionEnableSecondaryKey is an option for NewEvaluator that specifies whether
    27  // to enable the use of the ldcontext.Secondary meta-attribute in experiments that involve
    28  // rollouts or experiments. By default, this is not enabled in the current Go SDK and Rust
    29  // SDK, and the evaluation engines in other server-side SDKs do not recognize the secondary
    30  // key meta-attribute at all; but the Go and Rust evaluation engines need to be able to
    31  // recognize it when they are doing evaluations involving old-style user data.
    32  func EvaluatorOptionEnableSecondaryKey(enable bool) EvaluatorOption {
    33  	return evaluatorOptionEnableSecondaryKey{enable: enable}
    34  }
    35  
    36  func (o evaluatorOptionEnableSecondaryKey) apply(e *evaluator) {
    37  	e.enableSecondaryKey = o.enable
    38  }
    39  
    40  type evaluatorOptionErrorLogger struct{ errorLogger ldlog.BaseLogger }
    41  
    42  // EvaluatorOptionErrorLogger is an option for NewEvaluator that specifies a logger for
    43  // error reporting. The Evaluator will only log errors for conditions that should not be
    44  // possible and require investigation, such as a malformed flag or a code path that should
    45  // not have been reached. If the parameter is nil, no logging is done.
    46  func EvaluatorOptionErrorLogger(errorLogger ldlog.BaseLogger) EvaluatorOption {
    47  	return evaluatorOptionErrorLogger{errorLogger: errorLogger}
    48  }
    49  
    50  func (o evaluatorOptionErrorLogger) apply(e *evaluator) {
    51  	e.errorLogger = o.errorLogger
    52  }
    53  

View as plain text