Skip to content

Conversation

Just-maple
Copy link

@Just-maple Just-maple commented May 12, 2023

  1. export WrappedParentXXX like Struct

So that users can use

func (Interceptor)ConnExecContext(ctx context.Context, conn driver.ExecerContext, s string, values []driver.NamedValue) (ret driver.Result, err error) {
      // sqlmw wrapped
      wpConn,ok := conn.(WrappedParentConn)
      if ok{
           // user wrapped connection
           if myconn,ok := wpConn.Conn.(MyConn);ok{
                  connectInfo := myconn.Info()
           }
      }
      // use my connect info to do  log / trace / metrics / telemetry ... 
      ...
}
  1. Add Stmt WrappedParent Context in Stmt Execute and Query
func (Interceptor)StmtQueryContext(ctx context.Context, queryer driver.StmtQueryContext, s string, values []driver.NamedValue) (nctx context.Context, rows driver.Rows, err error) { {
      // sqlmw wrapped
      wpStmt,ok := conn.(WrappedParentStmt)
      if ok{
           parentCtx := wpStmt.Context()
      }
      // use parent context info to do  log / trace / metrics / telemetry ... 
      ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant