github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/replica_eval_context.go (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package kvserver 12 13 import ( 14 "context" 15 16 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/batcheval" 17 "github.com/cockroachdb/cockroach/pkg/kv/kvserver/spanset" 18 "github.com/cockroachdb/cockroach/pkg/util" 19 "github.com/cockroachdb/cockroach/pkg/util/log" 20 ) 21 22 // todoSpanSet is a placeholder value for callsites that need to pass a properly 23 // populated SpanSet (with according protection by the spanlatch manager) but fail 24 // to do so at the time of writing. 25 // 26 // See https://github.com/cockroachdb/cockroach/issues/19851. 27 // 28 // Do not introduce new uses of this. 29 var todoSpanSet = &spanset.SpanSet{} 30 31 // NewReplicaEvalContext returns a batcheval.EvalContext to use for command 32 // evaluation. The supplied SpanSet will be ignored except for race builds, in 33 // which case state access is asserted against it. A SpanSet must always be 34 // passed. 35 func NewReplicaEvalContext(r *Replica, ss *spanset.SpanSet) batcheval.EvalContext { 36 if ss == nil { 37 log.Fatalf(r.AnnotateCtx(context.Background()), "can't create a ReplicaEvalContext with assertions but no SpanSet") 38 } 39 if util.RaceEnabled { 40 return &SpanSetReplicaEvalContext{ 41 i: r, 42 ss: *ss, 43 } 44 } 45 return r 46 }