github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/trace/scripting_gtrace.go (about) 1 // Code generated by gtrace. DO NOT EDIT. 2 3 package trace 4 5 import ( 6 "context" 7 ) 8 9 // scriptingComposeOptions is a holder of options 10 type scriptingComposeOptions struct { 11 panicCallback func(e interface{}) 12 } 13 14 // ScriptingOption specified Scripting compose option 15 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 16 type ScriptingComposeOption func(o *scriptingComposeOptions) 17 18 // WithScriptingPanicCallback specified behavior on panic 19 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 20 func WithScriptingPanicCallback(cb func(e interface{})) ScriptingComposeOption { 21 return func(o *scriptingComposeOptions) { 22 o.panicCallback = cb 23 } 24 } 25 26 // Compose returns a new Scripting which has functional fields composed both from t and x. 27 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 28 func (t *Scripting) Compose(x *Scripting, opts ...ScriptingComposeOption) *Scripting { 29 if t == nil { 30 return x 31 } 32 var ret Scripting 33 options := scriptingComposeOptions{} 34 for _, opt := range opts { 35 if opt != nil { 36 opt(&options) 37 } 38 } 39 { 40 h1 := t.OnExecute 41 h2 := x.OnExecute 42 ret.OnExecute = func(s ScriptingExecuteStartInfo) func(ScriptingExecuteDoneInfo) { 43 if options.panicCallback != nil { 44 defer func() { 45 if e := recover(); e != nil { 46 options.panicCallback(e) 47 } 48 }() 49 } 50 var r, r1 func(ScriptingExecuteDoneInfo) 51 if h1 != nil { 52 r = h1(s) 53 } 54 if h2 != nil { 55 r1 = h2(s) 56 } 57 return func(s ScriptingExecuteDoneInfo) { 58 if options.panicCallback != nil { 59 defer func() { 60 if e := recover(); e != nil { 61 options.panicCallback(e) 62 } 63 }() 64 } 65 if r != nil { 66 r(s) 67 } 68 if r1 != nil { 69 r1(s) 70 } 71 } 72 } 73 } 74 { 75 h1 := t.OnStreamExecute 76 h2 := x.OnStreamExecute 77 ret.OnStreamExecute = func(s ScriptingStreamExecuteStartInfo) func(ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) { 78 if options.panicCallback != nil { 79 defer func() { 80 if e := recover(); e != nil { 81 options.panicCallback(e) 82 } 83 }() 84 } 85 var r, r1 func(ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) 86 if h1 != nil { 87 r = h1(s) 88 } 89 if h2 != nil { 90 r1 = h2(s) 91 } 92 return func(s ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) { 93 if options.panicCallback != nil { 94 defer func() { 95 if e := recover(); e != nil { 96 options.panicCallback(e) 97 } 98 }() 99 } 100 var r2, r3 func(ScriptingStreamExecuteDoneInfo) 101 if r != nil { 102 r2 = r(s) 103 } 104 if r1 != nil { 105 r3 = r1(s) 106 } 107 return func(s ScriptingStreamExecuteDoneInfo) { 108 if options.panicCallback != nil { 109 defer func() { 110 if e := recover(); e != nil { 111 options.panicCallback(e) 112 } 113 }() 114 } 115 if r2 != nil { 116 r2(s) 117 } 118 if r3 != nil { 119 r3(s) 120 } 121 } 122 } 123 } 124 } 125 { 126 h1 := t.OnExplain 127 h2 := x.OnExplain 128 ret.OnExplain = func(s ScriptingExplainStartInfo) func(ScriptingExplainDoneInfo) { 129 if options.panicCallback != nil { 130 defer func() { 131 if e := recover(); e != nil { 132 options.panicCallback(e) 133 } 134 }() 135 } 136 var r, r1 func(ScriptingExplainDoneInfo) 137 if h1 != nil { 138 r = h1(s) 139 } 140 if h2 != nil { 141 r1 = h2(s) 142 } 143 return func(s ScriptingExplainDoneInfo) { 144 if options.panicCallback != nil { 145 defer func() { 146 if e := recover(); e != nil { 147 options.panicCallback(e) 148 } 149 }() 150 } 151 if r != nil { 152 r(s) 153 } 154 if r1 != nil { 155 r1(s) 156 } 157 } 158 } 159 } 160 { 161 h1 := t.OnClose 162 h2 := x.OnClose 163 ret.OnClose = func(s ScriptingCloseStartInfo) func(ScriptingCloseDoneInfo) { 164 if options.panicCallback != nil { 165 defer func() { 166 if e := recover(); e != nil { 167 options.panicCallback(e) 168 } 169 }() 170 } 171 var r, r1 func(ScriptingCloseDoneInfo) 172 if h1 != nil { 173 r = h1(s) 174 } 175 if h2 != nil { 176 r1 = h2(s) 177 } 178 return func(s ScriptingCloseDoneInfo) { 179 if options.panicCallback != nil { 180 defer func() { 181 if e := recover(); e != nil { 182 options.panicCallback(e) 183 } 184 }() 185 } 186 if r != nil { 187 r(s) 188 } 189 if r1 != nil { 190 r1(s) 191 } 192 } 193 } 194 } 195 return &ret 196 } 197 func (t *Scripting) onExecute(s ScriptingExecuteStartInfo) func(ScriptingExecuteDoneInfo) { 198 fn := t.OnExecute 199 if fn == nil { 200 return func(ScriptingExecuteDoneInfo) { 201 return 202 } 203 } 204 res := fn(s) 205 if res == nil { 206 return func(ScriptingExecuteDoneInfo) { 207 return 208 } 209 } 210 return res 211 } 212 func (t *Scripting) onStreamExecute(s ScriptingStreamExecuteStartInfo) func(ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) { 213 fn := t.OnStreamExecute 214 if fn == nil { 215 return func(ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) { 216 return func(ScriptingStreamExecuteDoneInfo) { 217 return 218 } 219 } 220 } 221 res := fn(s) 222 if res == nil { 223 return func(ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) { 224 return func(ScriptingStreamExecuteDoneInfo) { 225 return 226 } 227 } 228 } 229 return func(s ScriptingStreamExecuteIntermediateInfo) func(ScriptingStreamExecuteDoneInfo) { 230 res := res(s) 231 if res == nil { 232 return func(ScriptingStreamExecuteDoneInfo) { 233 return 234 } 235 } 236 return res 237 } 238 } 239 func (t *Scripting) onExplain(s ScriptingExplainStartInfo) func(ScriptingExplainDoneInfo) { 240 fn := t.OnExplain 241 if fn == nil { 242 return func(ScriptingExplainDoneInfo) { 243 return 244 } 245 } 246 res := fn(s) 247 if res == nil { 248 return func(ScriptingExplainDoneInfo) { 249 return 250 } 251 } 252 return res 253 } 254 func (t *Scripting) onClose(s ScriptingCloseStartInfo) func(ScriptingCloseDoneInfo) { 255 fn := t.OnClose 256 if fn == nil { 257 return func(ScriptingCloseDoneInfo) { 258 return 259 } 260 } 261 res := fn(s) 262 if res == nil { 263 return func(ScriptingCloseDoneInfo) { 264 return 265 } 266 } 267 return res 268 } 269 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 270 func ScriptingOnExecute(t *Scripting, c *context.Context, call call, query string, parameters scriptingQueryParameters) func(result scriptingResult, _ error) { 271 var p ScriptingExecuteStartInfo 272 p.Context = c 273 p.Call = call 274 p.Query = query 275 p.Parameters = parameters 276 res := t.onExecute(p) 277 return func(result scriptingResult, e error) { 278 var p ScriptingExecuteDoneInfo 279 p.Result = result 280 p.Error = e 281 res(p) 282 } 283 } 284 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 285 func ScriptingOnStreamExecute(t *Scripting, c *context.Context, call call, query string, parameters scriptingQueryParameters) func(error) func(error) { 286 var p ScriptingStreamExecuteStartInfo 287 p.Context = c 288 p.Call = call 289 p.Query = query 290 p.Parameters = parameters 291 res := t.onStreamExecute(p) 292 return func(e error) func(error) { 293 var p ScriptingStreamExecuteIntermediateInfo 294 p.Error = e 295 res := res(p) 296 return func(e error) { 297 var p ScriptingStreamExecuteDoneInfo 298 p.Error = e 299 res(p) 300 } 301 } 302 } 303 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 304 func ScriptingOnExplain(t *Scripting, c *context.Context, call call, query string) func(plan string, _ error) { 305 var p ScriptingExplainStartInfo 306 p.Context = c 307 p.Call = call 308 p.Query = query 309 res := t.onExplain(p) 310 return func(plan string, e error) { 311 var p ScriptingExplainDoneInfo 312 p.Plan = plan 313 p.Error = e 314 res(p) 315 } 316 } 317 // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals 318 func ScriptingOnClose(t *Scripting, c *context.Context, call call) func(error) { 319 var p ScriptingCloseStartInfo 320 p.Context = c 321 p.Call = call 322 res := t.onClose(p) 323 return func(e error) { 324 var p ScriptingCloseDoneInfo 325 p.Error = e 326 res(p) 327 } 328 }