EvalStateObserver provides an observer which records the value associated with the given expression id. EvalState must be provided to the observer.
(opts ...evalStateOption)
| 92 | // EvalStateObserver provides an observer which records the value associated with the given expression id. |
| 93 | // EvalState must be provided to the observer. |
| 94 | func EvalStateObserver(opts ...evalStateOption) PlannerOption { |
| 95 | et := &evalStateFactory{factory: NewEvalState} |
| 96 | for _, o := range opts { |
| 97 | et = o(et) |
| 98 | } |
| 99 | return func(p *planner) (*planner, error) { |
| 100 | if et.factory == nil { |
| 101 | return nil, errors.New("eval state factory not configured") |
| 102 | } |
| 103 | p.observers = append(p.observers, et) |
| 104 | p.decorators = append(p.decorators, decObserveEval(et.Observe)) |
| 105 | return p, nil |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | // activationWrapper identifies an object carrying local variables which should not be exposed to the user |
| 110 | // Activations used for such purposes can be unwrapped to return the activation which omits local state. |