github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/trace/table.go (about)

     1  package trace
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  )
     7  
     8  // tool gtrace used from ./internal/cmd/gtrace
     9  
    10  //go:generate gtrace
    11  
    12  type (
    13  	// Table specified trace of table client activity.
    14  	// gtrace:gen
    15  	Table struct {
    16  		// Client events
    17  		OnInit          func(TableInitStartInfo) func(TableInitDoneInfo)
    18  		OnClose         func(TableCloseStartInfo) func(TableCloseDoneInfo)
    19  		OnDo            func(TableDoStartInfo) func(info TableDoIntermediateInfo) func(TableDoDoneInfo)
    20  		OnDoTx          func(TableDoTxStartInfo) func(info TableDoTxIntermediateInfo) func(TableDoTxDoneInfo)
    21  		OnCreateSession func(
    22  			TableCreateSessionStartInfo,
    23  		) func(
    24  			info TableCreateSessionIntermediateInfo,
    25  		) func(
    26  			TableCreateSessionDoneInfo,
    27  		)
    28  		// Session events
    29  		OnSessionNew       func(TableSessionNewStartInfo) func(TableSessionNewDoneInfo)
    30  		OnSessionDelete    func(TableSessionDeleteStartInfo) func(TableSessionDeleteDoneInfo)
    31  		OnSessionKeepAlive func(TableKeepAliveStartInfo) func(TableKeepAliveDoneInfo)
    32  		// Query events
    33  		OnSessionBulkUpsert   func(TableBulkUpsertStartInfo) func(TableBulkUpsertDoneInfo)
    34  		OnSessionQueryPrepare func(TablePrepareDataQueryStartInfo) func(TablePrepareDataQueryDoneInfo)
    35  		OnSessionQueryExecute func(TableExecuteDataQueryStartInfo) func(TableExecuteDataQueryDoneInfo)
    36  		OnSessionQueryExplain func(TableExplainQueryStartInfo) func(TableExplainQueryDoneInfo)
    37  		// Stream events
    38  		OnSessionQueryStreamExecute func(
    39  			TableSessionQueryStreamExecuteStartInfo,
    40  		) func(
    41  			TableSessionQueryStreamExecuteIntermediateInfo,
    42  		) func(
    43  			TableSessionQueryStreamExecuteDoneInfo,
    44  		)
    45  		OnSessionQueryStreamRead func(
    46  			TableSessionQueryStreamReadStartInfo,
    47  		) func(
    48  			TableSessionQueryStreamReadIntermediateInfo,
    49  		) func(
    50  			TableSessionQueryStreamReadDoneInfo,
    51  		)
    52  		// Transaction events
    53  		OnSessionTransactionBegin func(TableSessionTransactionBeginStartInfo) func(
    54  			TableSessionTransactionBeginDoneInfo,
    55  		)
    56  		OnSessionTransactionExecute func(TableTransactionExecuteStartInfo) func(
    57  			TableTransactionExecuteDoneInfo,
    58  		)
    59  		OnSessionTransactionExecuteStatement func(TableTransactionExecuteStatementStartInfo) func(
    60  			TableTransactionExecuteStatementDoneInfo,
    61  		)
    62  		OnSessionTransactionCommit func(TableSessionTransactionCommitStartInfo) func(
    63  			TableSessionTransactionCommitDoneInfo,
    64  		)
    65  		OnSessionTransactionRollback func(TableSessionTransactionRollbackStartInfo) func(
    66  			TableSessionTransactionRollbackDoneInfo,
    67  		)
    68  		// Pool state event
    69  		OnPoolStateChange func(TablePoolStateChangeInfo)
    70  
    71  		// Pool session lifecycle events
    72  		OnPoolSessionAdd    func(info TablePoolSessionAddInfo)
    73  		OnPoolSessionRemove func(info TablePoolSessionRemoveInfo)
    74  
    75  		// OnPoolSessionNew is user-defined callback for listening events about creating sessions with
    76  		// internal session pool calls
    77  		//
    78  		// Deprecated: use OnPoolSessionAdd callback
    79  		OnPoolSessionNew func(TablePoolSessionNewStartInfo) func(TablePoolSessionNewDoneInfo)
    80  
    81  		// OnPoolSessionClose is user-defined callback for listening sessionClose calls
    82  		//
    83  		// Deprecated: use OnPoolSessionRemove callback
    84  		OnPoolSessionClose func(TablePoolSessionCloseStartInfo) func(TablePoolSessionCloseDoneInfo)
    85  		// Pool common API events
    86  		OnPoolPut  func(TablePoolPutStartInfo) func(TablePoolPutDoneInfo)
    87  		OnPoolGet  func(TablePoolGetStartInfo) func(TablePoolGetDoneInfo)
    88  		OnPoolWait func(TablePoolWaitStartInfo) func(TablePoolWaitDoneInfo)
    89  	}
    90  )
    91  
    92  type (
    93  	tableQueryParameters interface {
    94  		String() string
    95  	}
    96  	tableDataQuery interface {
    97  		String() string
    98  		ID() string
    99  		YQL() string
   100  	}
   101  	tableSessionInfo interface {
   102  		ID() string
   103  		NodeID() uint32
   104  		Status() string
   105  		LastUsage() time.Time
   106  	}
   107  	tableTransactionInfo interface {
   108  		ID() string
   109  	}
   110  	tableResultErr interface {
   111  		Err() error
   112  	}
   113  	tableResult interface {
   114  		tableResultErr
   115  		ResultSetCount() int
   116  	}
   117  	TableSessionNewStartInfo struct {
   118  		// Context make available context in trace callback function.
   119  		// Pointer to context provide replacement of context in trace callback function.
   120  		// Warning: concurrent access to pointer on client side must be excluded.
   121  		// Safe replacement of context are provided only inside callback function
   122  		Context *context.Context
   123  		Call    call
   124  	}
   125  	TableSessionNewDoneInfo struct {
   126  		Session tableSessionInfo
   127  		Error   error
   128  	}
   129  	TableKeepAliveStartInfo struct {
   130  		// Context make available context in trace callback function.
   131  		// Pointer to context provide replacement of context in trace callback function.
   132  		// Warning: concurrent access to pointer on client side must be excluded.
   133  		// Safe replacement of context are provided only inside callback function
   134  		Context *context.Context
   135  		Call    call
   136  		Session tableSessionInfo
   137  	}
   138  	TableKeepAliveDoneInfo struct {
   139  		Error error
   140  	}
   141  	TableBulkUpsertStartInfo struct {
   142  		// Context make available context in trace callback function.
   143  		// Pointer to context provide replacement of context in trace callback function.
   144  		// Warning: concurrent access to pointer on client side must be excluded.
   145  		// Safe replacement of context are provided only inside callback function
   146  		Context *context.Context
   147  		Call    call
   148  		Session tableSessionInfo
   149  	}
   150  	TableBulkUpsertDoneInfo struct {
   151  		Error error
   152  	}
   153  	TableSessionDeleteStartInfo struct {
   154  		// Context make available context in trace callback function.
   155  		// Pointer to context provide replacement of context in trace callback function.
   156  		// Warning: concurrent access to pointer on client side must be excluded.
   157  		// Safe replacement of context are provided only inside callback function
   158  		Context *context.Context
   159  		Call    call
   160  		Session tableSessionInfo
   161  	}
   162  	TableSessionDeleteDoneInfo struct {
   163  		Error error
   164  	}
   165  	TablePrepareDataQueryStartInfo struct {
   166  		// Context make available context in trace callback function.
   167  		// Pointer to context provide replacement of context in trace callback function.
   168  		// Warning: concurrent access to pointer on client side must be excluded.
   169  		// Safe replacement of context are provided only inside callback function
   170  		Context *context.Context
   171  		Call    call
   172  		Session tableSessionInfo
   173  		Query   string
   174  	}
   175  	TablePrepareDataQueryDoneInfo struct {
   176  		Result tableDataQuery
   177  		Error  error
   178  	}
   179  	TableExecuteDataQueryStartInfo struct {
   180  		// Context make available context in trace callback function.
   181  		// Pointer to context provide replacement of context in trace callback function.
   182  		// Warning: concurrent access to pointer on client side must be excluded.
   183  		// Safe replacement of context are provided only inside callback function
   184  		Context     *context.Context
   185  		Call        call
   186  		Session     tableSessionInfo
   187  		Query       tableDataQuery
   188  		Parameters  tableQueryParameters
   189  		KeepInCache bool
   190  	}
   191  	TableTransactionExecuteStartInfo struct {
   192  		// Context make available context in trace callback function.
   193  		// Pointer to context provide replacement of context in trace callback function.
   194  		// Warning: concurrent access to pointer on client side must be excluded.
   195  		// Safe replacement of context are provided only inside callback function
   196  		Context    *context.Context
   197  		Call       call
   198  		Session    tableSessionInfo
   199  		Tx         tableTransactionInfo
   200  		Query      tableDataQuery
   201  		Parameters tableQueryParameters
   202  	}
   203  	TableTransactionExecuteStatementStartInfo struct {
   204  		// Context make available context in trace callback function.
   205  		// Pointer to context provide replacement of context in trace callback function.
   206  		// Warning: concurrent access to pointer on client side must be excluded.
   207  		// Safe replacement of context are provided only inside callback function
   208  		Context        *context.Context
   209  		Call           call
   210  		Session        tableSessionInfo
   211  		Tx             tableTransactionInfo
   212  		StatementQuery tableDataQuery
   213  		Parameters     tableQueryParameters
   214  	}
   215  	TableExplainQueryStartInfo struct {
   216  		// Context make available context in trace callback function.
   217  		// Pointer to context provide replacement of context in trace callback function.
   218  		// Warning: concurrent access to pointer on client side must be excluded.
   219  		// Safe replacement of context are provided only inside callback function
   220  		Context *context.Context
   221  		Call    call
   222  		Session tableSessionInfo
   223  		Query   string
   224  	}
   225  	TableExplainQueryDoneInfo struct {
   226  		AST   string
   227  		Plan  string
   228  		Error error
   229  	}
   230  	TableExecuteDataQueryDoneInfo struct {
   231  		Tx       tableTransactionInfo
   232  		Prepared bool
   233  		Result   tableResult
   234  		Error    error
   235  	}
   236  	TableTransactionExecuteDoneInfo struct {
   237  		Result tableResult
   238  		Error  error
   239  	}
   240  	TableTransactionExecuteStatementDoneInfo struct {
   241  		Result tableResult
   242  		Error  error
   243  	}
   244  	TableSessionQueryStreamReadStartInfo struct {
   245  		// Context make available context in trace callback function.
   246  		// Pointer to context provide replacement of context in trace callback function.
   247  		// Warning: concurrent access to pointer on client side must be excluded.
   248  		// Safe replacement of context are provided only inside callback function
   249  		Context *context.Context
   250  		Call    call
   251  		Session tableSessionInfo
   252  	}
   253  	TableSessionQueryStreamReadIntermediateInfo struct {
   254  		Error error
   255  	}
   256  	TableSessionQueryStreamReadDoneInfo struct {
   257  		Error error
   258  	}
   259  	TableSessionQueryStreamExecuteStartInfo struct {
   260  		// Context make available context in trace callback function.
   261  		// Pointer to context provide replacement of context in trace callback function.
   262  		// Warning: concurrent access to pointer on client side must be excluded.
   263  		// Safe replacement of context are provided only inside callback function
   264  		Context    *context.Context
   265  		Call       call
   266  		Session    tableSessionInfo
   267  		Query      tableDataQuery
   268  		Parameters tableQueryParameters
   269  	}
   270  	TableSessionQueryStreamExecuteIntermediateInfo struct {
   271  		Error error
   272  	}
   273  	TableSessionQueryStreamExecuteDoneInfo struct {
   274  		Error error
   275  	}
   276  	TableSessionTransactionBeginStartInfo struct {
   277  		// Context make available context in trace callback function.
   278  		// Pointer to context provide replacement of context in trace callback function.
   279  		// Warning: concurrent access to pointer on client side must be excluded.
   280  		// Safe replacement of context are provided only inside callback function
   281  		Context *context.Context
   282  		Call    call
   283  		Session tableSessionInfo
   284  	}
   285  	TableSessionTransactionBeginDoneInfo struct {
   286  		Tx    tableTransactionInfo
   287  		Error error
   288  	}
   289  	TableSessionTransactionCommitStartInfo struct {
   290  		// Context make available context in trace callback function.
   291  		// Pointer to context provide replacement of context in trace callback function.
   292  		// Warning: concurrent access to pointer on client side must be excluded.
   293  		// Safe replacement of context are provided only inside callback function
   294  		Context *context.Context
   295  		Call    call
   296  		Session tableSessionInfo
   297  		Tx      tableTransactionInfo
   298  	}
   299  	TableSessionTransactionCommitDoneInfo struct {
   300  		Error error
   301  	}
   302  	TableSessionTransactionRollbackStartInfo struct {
   303  		// Context make available context in trace callback function.
   304  		// Pointer to context provide replacement of context in trace callback function.
   305  		// Warning: concurrent access to pointer on client side must be excluded.
   306  		// Safe replacement of context are provided only inside callback function
   307  		Context *context.Context
   308  		Call    call
   309  		Session tableSessionInfo
   310  		Tx      tableTransactionInfo
   311  	}
   312  	TableSessionTransactionRollbackDoneInfo struct {
   313  		Error error
   314  	}
   315  	TableInitStartInfo struct {
   316  		// Context make available context in trace callback function.
   317  		// Pointer to context provide replacement of context in trace callback function.
   318  		// Warning: concurrent access to pointer on client side must be excluded.
   319  		// Safe replacement of context are provided only inside callback function
   320  		Context *context.Context
   321  		Call    call
   322  	}
   323  	TableInitDoneInfo struct {
   324  		Limit int
   325  		Error error
   326  	}
   327  	TablePoolStateChangeInfo struct {
   328  		Size  int
   329  		Event string
   330  	}
   331  	TablePoolSessionNewStartInfo struct {
   332  		// Context make available context in trace callback function.
   333  		// Pointer to context provide replacement of context in trace callback function.
   334  		// Warning: concurrent access to pointer on client side must be excluded.
   335  		// Safe replacement of context are provided only inside callback function
   336  		Context *context.Context
   337  		Call    call
   338  	}
   339  	TablePoolSessionNewDoneInfo struct {
   340  		Session tableSessionInfo
   341  		Error   error
   342  	}
   343  	TablePoolGetStartInfo struct {
   344  		// Context make available context in trace callback function.
   345  		// Pointer to context provide replacement of context in trace callback function.
   346  		// Warning: concurrent access to pointer on client side must be excluded.
   347  		// Safe replacement of context are provided only inside callback function
   348  		Context *context.Context
   349  		Call    call
   350  	}
   351  	TablePoolGetDoneInfo struct {
   352  		Session  tableSessionInfo
   353  		Attempts int
   354  		Error    error
   355  	}
   356  	TablePoolWaitStartInfo struct {
   357  		// Context make available context in trace callback function.
   358  		// Pointer to context provide replacement of context in trace callback function.
   359  		// Warning: concurrent access to pointer on client side must be excluded.
   360  		// Safe replacement of context are provided only inside callback function
   361  		Context *context.Context
   362  		Call    call
   363  	}
   364  	// TablePoolWaitDoneInfo means a wait iteration inside Get call is done
   365  	// Warning: Session and Error may be nil at the same time. This means
   366  	// that a wait iteration donned without any significant tableResultErr
   367  	TablePoolWaitDoneInfo struct {
   368  		Session tableSessionInfo
   369  		Error   error
   370  	}
   371  	TablePoolPutStartInfo struct {
   372  		// Context make available context in trace callback function.
   373  		// Pointer to context provide replacement of context in trace callback function.
   374  		// Warning: concurrent access to pointer on client side must be excluded.
   375  		// Safe replacement of context are provided only inside callback function
   376  		Context *context.Context
   377  		Call    call
   378  		Session tableSessionInfo
   379  	}
   380  	TablePoolPutDoneInfo struct {
   381  		Error error
   382  	}
   383  	TablePoolSessionCloseStartInfo struct {
   384  		// Context make available context in trace callback function.
   385  		// Pointer to context provide replacement of context in trace callback function.
   386  		// Warning: concurrent access to pointer on client side must be excluded.
   387  		// Safe replacement of context are provided only inside callback function
   388  		Context *context.Context
   389  		Call    call
   390  		Session tableSessionInfo
   391  	}
   392  	TablePoolSessionCloseDoneInfo struct{}
   393  	TablePoolSessionAddInfo       struct {
   394  		Session tableSessionInfo
   395  	}
   396  	TablePoolSessionRemoveInfo struct {
   397  		Session tableSessionInfo
   398  	}
   399  	TableCloseStartInfo struct {
   400  		// Context make available context in trace callback function.
   401  		// Pointer to context provide replacement of context in trace callback function.
   402  		// Warning: concurrent access to pointer on client side must be excluded.
   403  		// Safe replacement of context are provided only inside callback function
   404  		Context *context.Context
   405  		Call    call
   406  	}
   407  	TableCloseDoneInfo struct {
   408  		Error error
   409  	}
   410  	TableDoStartInfo struct {
   411  		// Context make available context in trace callback function.
   412  		// Pointer to context provide replacement of context in trace callback function.
   413  		// Warning: concurrent access to pointer on client side must be excluded.
   414  		// Safe replacement of context are provided only inside callback function
   415  		Context *context.Context
   416  		Call    call
   417  
   418  		// Deprecated: use Label field instead
   419  		ID string
   420  
   421  		Label      string
   422  		Idempotent bool
   423  		NestedCall bool // flag when Retry called inside head Retry
   424  	}
   425  	TableDoIntermediateInfo struct {
   426  		Error error
   427  	}
   428  	TableDoDoneInfo struct {
   429  		Attempts int
   430  		Error    error
   431  	}
   432  	TableDoTxStartInfo struct {
   433  		// Context make available context in trace callback function.
   434  		// Pointer to context provide replacement of context in trace callback function.
   435  		// Warning: concurrent access to pointer on client side must be excluded.
   436  		// Safe replacement of context are provided only inside callback function
   437  		Context *context.Context
   438  		Call    call
   439  
   440  		// Deprecated: use Label field instead
   441  		ID string
   442  
   443  		Label      string
   444  		Idempotent bool
   445  		NestedCall bool // flag when Retry called inside head Retry
   446  	}
   447  	TableDoTxIntermediateInfo struct {
   448  		Error error
   449  	}
   450  	TableDoTxDoneInfo struct {
   451  		Attempts int
   452  		Error    error
   453  	}
   454  	TableCreateSessionStartInfo struct {
   455  		// Context make available context in trace callback function.
   456  		// Pointer to context provide replacement of context in trace callback function.
   457  		// Warning: concurrent access to pointer on client side must be excluded.
   458  		// Safe replacement of context are provided only inside callback function
   459  		Context *context.Context
   460  		Call    call
   461  	}
   462  	TableCreateSessionIntermediateInfo struct {
   463  		Error error
   464  	}
   465  	TableCreateSessionDoneInfo struct {
   466  		Session  tableSessionInfo
   467  		Attempts int
   468  		Error    error
   469  	}
   470  )