github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/trace/query_gtrace.go (about) 1 // Code generated by gtrace. DO NOT EDIT. 2 3 package trace 4 5 import ( 6 "context" 7 ) 8 9 // queryComposeOptions is a holder of options 10 type queryComposeOptions struct { 11 panicCallback func(e interface{}) 12 } 13 14 // QueryOption specified Query compose option 15 type QueryComposeOption func(o *queryComposeOptions) 16 17 // WithQueryPanicCallback specified behavior on panic 18 func WithQueryPanicCallback(cb func(e interface{})) QueryComposeOption { 19 return func(o *queryComposeOptions) { 20 o.panicCallback = cb 21 } 22 } 23 24 // Compose returns a new Query which has functional fields composed both from t and x. 25 func (t *Query) Compose(x *Query, opts ...QueryComposeOption) *Query { 26 var ret Query 27 options := queryComposeOptions{} 28 for _, opt := range opts { 29 if opt != nil { 30 opt(&options) 31 } 32 } 33 { 34 h1 := t.OnDo 35 h2 := x.OnDo 36 ret.OnDo = func(q QueryDoStartInfo) func(QueryDoIntermediateInfo) func(QueryDoDoneInfo) { 37 if options.panicCallback != nil { 38 defer func() { 39 if e := recover(); e != nil { 40 options.panicCallback(e) 41 } 42 }() 43 } 44 var r, r1 func(QueryDoIntermediateInfo) func(QueryDoDoneInfo) 45 if h1 != nil { 46 r = h1(q) 47 } 48 if h2 != nil { 49 r1 = h2(q) 50 } 51 return func(info QueryDoIntermediateInfo) func(QueryDoDoneInfo) { 52 if options.panicCallback != nil { 53 defer func() { 54 if e := recover(); e != nil { 55 options.panicCallback(e) 56 } 57 }() 58 } 59 var r2, r3 func(QueryDoDoneInfo) 60 if r != nil { 61 r2 = r(info) 62 } 63 if r1 != nil { 64 r3 = r1(info) 65 } 66 return func(q QueryDoDoneInfo) { 67 if options.panicCallback != nil { 68 defer func() { 69 if e := recover(); e != nil { 70 options.panicCallback(e) 71 } 72 }() 73 } 74 if r2 != nil { 75 r2(q) 76 } 77 if r3 != nil { 78 r3(q) 79 } 80 } 81 } 82 } 83 } 84 { 85 h1 := t.OnDoTx 86 h2 := x.OnDoTx 87 ret.OnDoTx = func(q QueryDoTxStartInfo) func(QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) { 88 if options.panicCallback != nil { 89 defer func() { 90 if e := recover(); e != nil { 91 options.panicCallback(e) 92 } 93 }() 94 } 95 var r, r1 func(QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) 96 if h1 != nil { 97 r = h1(q) 98 } 99 if h2 != nil { 100 r1 = h2(q) 101 } 102 return func(info QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) { 103 if options.panicCallback != nil { 104 defer func() { 105 if e := recover(); e != nil { 106 options.panicCallback(e) 107 } 108 }() 109 } 110 var r2, r3 func(QueryDoTxDoneInfo) 111 if r != nil { 112 r2 = r(info) 113 } 114 if r1 != nil { 115 r3 = r1(info) 116 } 117 return func(q QueryDoTxDoneInfo) { 118 if options.panicCallback != nil { 119 defer func() { 120 if e := recover(); e != nil { 121 options.panicCallback(e) 122 } 123 }() 124 } 125 if r2 != nil { 126 r2(q) 127 } 128 if r3 != nil { 129 r3(q) 130 } 131 } 132 } 133 } 134 } 135 return &ret 136 } 137 func (t *Query) onDo(q QueryDoStartInfo) func(info QueryDoIntermediateInfo) func(QueryDoDoneInfo) { 138 fn := t.OnDo 139 if fn == nil { 140 return func(QueryDoIntermediateInfo) func(QueryDoDoneInfo) { 141 return func(QueryDoDoneInfo) { 142 return 143 } 144 } 145 } 146 res := fn(q) 147 if res == nil { 148 return func(QueryDoIntermediateInfo) func(QueryDoDoneInfo) { 149 return func(QueryDoDoneInfo) { 150 return 151 } 152 } 153 } 154 return func(info QueryDoIntermediateInfo) func(QueryDoDoneInfo) { 155 res := res(info) 156 if res == nil { 157 return func(QueryDoDoneInfo) { 158 return 159 } 160 } 161 return res 162 } 163 } 164 func (t *Query) onDoTx(q QueryDoTxStartInfo) func(info QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) { 165 fn := t.OnDoTx 166 if fn == nil { 167 return func(QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) { 168 return func(QueryDoTxDoneInfo) { 169 return 170 } 171 } 172 } 173 res := fn(q) 174 if res == nil { 175 return func(QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) { 176 return func(QueryDoTxDoneInfo) { 177 return 178 } 179 } 180 } 181 return func(info QueryDoTxIntermediateInfo) func(QueryDoTxDoneInfo) { 182 res := res(info) 183 if res == nil { 184 return func(QueryDoTxDoneInfo) { 185 return 186 } 187 } 188 return res 189 } 190 } 191 func QueryOnDo(t *Query, c *context.Context, call call, label string, idempotent bool, nestedCall bool) func(error) func(attempts int, _ error) { 192 var p QueryDoStartInfo 193 p.Context = c 194 p.Call = call 195 p.Label = label 196 p.Idempotent = idempotent 197 p.NestedCall = nestedCall 198 res := t.onDo(p) 199 return func(e error) func(int, error) { 200 var p QueryDoIntermediateInfo 201 p.Error = e 202 res := res(p) 203 return func(attempts int, e error) { 204 var p QueryDoDoneInfo 205 p.Attempts = attempts 206 p.Error = e 207 res(p) 208 } 209 } 210 } 211 func QueryOnDoTx(t *Query, c *context.Context, call call, label string, idempotent bool, nestedCall bool) func(error) func(attempts int, _ error) { 212 var p QueryDoTxStartInfo 213 p.Context = c 214 p.Call = call 215 p.Label = label 216 p.Idempotent = idempotent 217 p.NestedCall = nestedCall 218 res := t.onDoTx(p) 219 return func(e error) func(int, error) { 220 var p QueryDoTxIntermediateInfo 221 p.Error = e 222 res := res(p) 223 return func(attempts int, e error) { 224 var p QueryDoTxDoneInfo 225 p.Attempts = attempts 226 p.Error = e 227 res(p) 228 } 229 } 230 }