Skip to content

feat(context): export wrapped parent struct and add stmt context #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 ... 
      ...
}

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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.

None yet

1 participant