MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestConcurrentEval

Function TestConcurrentEval

cel/program_async_test.go:36–504  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestConcurrentEval(t *testing.T) {
37 cases := []struct {
38 name string
39 expr string
40 vars any
41 opts []any
42 maxConc int
43 want any
44 wantLaunches int32
45 trackCost bool
46 trackState bool
47 wantErr string
48 wantCost uint64
49 leakCheck bool
50 }{
51 {
52 name: "sync_eval",
53 expr: `x + 1`,
54 vars: map[string]any{"x": 10},
55 opts: []any{cel.Variable("x", cel.IntType)},
56 want: 11,
57 },
58 {
59 name: "single_async",
60 expr: `async_func(42) + 1`,
61 opts: []any{
62 cel.Function("async_func",
63 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
64 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
65 time.Sleep(1 * time.Millisecond)
66 return args[0]
67 }),
68 ),
69 ),
70 },
71 want: 43,
72 },
73 {
74 name: "completion_buffer_size",
75 expr: `async_func(42) + 1`,
76 opts: []any{
77 cel.Function("async_func",
78 cel.Overload("async_func_int", []*cel.Type{cel.IntType}, cel.IntType,
79 cel.AsyncBinding(func(ctx context.Context, args ...ref.Val) ref.Val {
80 time.Sleep(1 * time.Millisecond)
81 return args[0]
82 }),
83 ),
84 ),
85 cel.AsyncCompletionBufferSize(16),
86 },
87 want: 43,
88 },
89 {
90 name: "outside_parallel_conc_1",
91 expr: `async_inc(10) + async_inc(20)`,
92 maxConc: 1,
93 want: 32,

Callers

nothing calls this directly

Calls 15

VariableFunction · 0.92
FunctionFunction · 0.92
OverloadFunction · 0.92
AsyncBindingFunction · 0.92
FakeRPCFunction · 0.92
ConcurrentDrainStrategyFunction · 0.92
DrainAllFunction · 0.92
DrainReadyFunction · 0.92
DrainNoneFunction · 0.92
EvalOptionsFunction · 0.92
ListsFunction · 0.92

Tested by

no test coverage detected