From 6b2b2089faefd9248824e65ba4f6329d5292d951 Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Tue, 3 Sep 2024 20:34:06 +0300 Subject: [PATCH] reverted changes of trace.Table --- trace/table.go | 39 ++++++++++++- trace/table_gtrace.go | 127 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 2 deletions(-) diff --git a/trace/table.go b/trace/table.go index 56e2c63d1..5589327b1 100644 --- a/trace/table.go +++ b/trace/table.go @@ -74,6 +74,19 @@ type ( OnPoolWith func(TablePoolWithStartInfo) func(TablePoolWithDoneInfo) // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals OnPoolStateChange func(TablePoolStateChangeInfo) + + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated + OnPoolSessionAdd func(info TablePoolSessionAddInfo) + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated + OnPoolSessionRemove func(info TablePoolSessionRemoveInfo) + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated + OnPoolWait func(TablePoolWaitStartInfo) func(TablePoolWaitDoneInfo) } ) @@ -368,6 +381,24 @@ type ( Attempts int Error error } + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated + TablePoolWaitStartInfo struct { + // Context make available context in trace callback function. + // Pointer to context provide replacement of context in trace callback function. + // Warning: concurrent access to pointer on client side must be excluded. + // Safe replacement of context are provided only inside callback function + Context *context.Context + Call call + } + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated + TablePoolWaitDoneInfo struct { + Session sessionInfo + Error error + } // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals TablePoolWithStartInfo struct { // Context make available context in trace callback function. @@ -408,11 +439,15 @@ type ( } // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals TablePoolSessionCloseDoneInfo struct{} - // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated TablePoolSessionAddInfo struct { Session sessionInfo } - // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals + // Deprecated + // Will be removed after March 2025. + // Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated TablePoolSessionRemoveInfo struct { Session sessionInfo } diff --git a/trace/table_gtrace.go b/trace/table_gtrace.go index 79350b540..c548157b1 100644 --- a/trace/table_gtrace.go +++ b/trace/table_gtrace.go @@ -822,6 +822,79 @@ func (t *Table) Compose(x *Table, opts ...TableComposeOption) *Table { } } } + { + h1 := t.OnPoolSessionAdd + h2 := x.OnPoolSessionAdd + ret.OnPoolSessionAdd = func(info TablePoolSessionAddInfo) { + if options.panicCallback != nil { + defer func() { + if e := recover(); e != nil { + options.panicCallback(e) + } + }() + } + if h1 != nil { + h1(info) + } + if h2 != nil { + h2(info) + } + } + } + { + h1 := t.OnPoolSessionRemove + h2 := x.OnPoolSessionRemove + ret.OnPoolSessionRemove = func(info TablePoolSessionRemoveInfo) { + if options.panicCallback != nil { + defer func() { + if e := recover(); e != nil { + options.panicCallback(e) + } + }() + } + if h1 != nil { + h1(info) + } + if h2 != nil { + h2(info) + } + } + } + { + h1 := t.OnPoolWait + h2 := x.OnPoolWait + ret.OnPoolWait = func(t TablePoolWaitStartInfo) func(TablePoolWaitDoneInfo) { + if options.panicCallback != nil { + defer func() { + if e := recover(); e != nil { + options.panicCallback(e) + } + }() + } + var r, r1 func(TablePoolWaitDoneInfo) + if h1 != nil { + r = h1(t) + } + if h2 != nil { + r1 = h2(t) + } + return func(t TablePoolWaitDoneInfo) { + if options.panicCallback != nil { + defer func() { + if e := recover(); e != nil { + options.panicCallback(e) + } + }() + } + if r != nil { + r(t) + } + if r1 != nil { + r1(t) + } + } + } + } return &ret } func (t *Table) onInit(t1 TableInitStartInfo) func(TableInitDoneInfo) { @@ -1161,6 +1234,35 @@ func (t *Table) onPoolStateChange(t1 TablePoolStateChangeInfo) { } fn(t1) } +func (t *Table) onPoolSessionAdd(info TablePoolSessionAddInfo) { + fn := t.OnPoolSessionAdd + if fn == nil { + return + } + fn(info) +} +func (t *Table) onPoolSessionRemove(info TablePoolSessionRemoveInfo) { + fn := t.OnPoolSessionRemove + if fn == nil { + return + } + fn(info) +} +func (t *Table) onPoolWait(t1 TablePoolWaitStartInfo) func(TablePoolWaitDoneInfo) { + fn := t.OnPoolWait + if fn == nil { + return func(TablePoolWaitDoneInfo) { + return + } + } + res := fn(t1) + if res == nil { + return func(TablePoolWaitDoneInfo) { + return + } + } + return res +} // Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals func TableOnInit(t *Table, c *context.Context, call call) func(limit int) { var p TableInitStartInfo @@ -1488,3 +1590,28 @@ func TableOnPoolStateChange(t *Table, limit int, index int, idle int, wait int, p.Size = size t.onPoolStateChange(p) } +// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals +func TableOnPoolSessionAdd(t *Table, session sessionInfo) { + var p TablePoolSessionAddInfo + p.Session = session + t.onPoolSessionAdd(p) +} +// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals +func TableOnPoolSessionRemove(t *Table, session sessionInfo) { + var p TablePoolSessionRemoveInfo + p.Session = session + t.onPoolSessionRemove(p) +} +// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals +func TableOnPoolWait(t *Table, c *context.Context, call call) func(session sessionInfo, _ error) { + var p TablePoolWaitStartInfo + p.Context = c + p.Call = call + res := t.onPoolWait(p) + return func(session sessionInfo, e error) { + var p TablePoolWaitDoneInfo + p.Session = session + p.Error = e + res(p) + } +}