github.com/RevenueMonster/sqlike@v1.0.6/plugin/opentracing/option.go (about)

     1  package opentracing
     2  
     3  // WithAllTraceOptions :
     4  func WithAllTraceOptions() TraceOption {
     5  	return func(opt *TraceOptions) {
     6  		opt.Ping = true
     7  		opt.BeginTx = true
     8  		opt.TxCommit = true
     9  		opt.TxRollback = true
    10  		opt.Prepare = true
    11  		opt.Query = true
    12  		opt.Exec = true
    13  		opt.RowsAffected = true
    14  		opt.RowsClose = true
    15  		opt.RowsNext = true
    16  		opt.LastInsertID = true
    17  		opt.Args = true
    18  	}
    19  }
    20  
    21  // WithComponent :
    22  func WithComponent(comp string) TraceOption {
    23  	return func(opt *TraceOptions) {
    24  		opt.Component = comp
    25  	}
    26  }
    27  
    28  // WithDBInstance :
    29  func WithDBInstance(instance string) TraceOption {
    30  	return func(opt *TraceOptions) {
    31  		opt.DBInstance = instance
    32  	}
    33  }
    34  
    35  // WithDBType :
    36  func WithDBType(dbType string) TraceOption {
    37  	return func(opt *TraceOptions) {
    38  		opt.DBType = dbType
    39  	}
    40  }
    41  
    42  // WithDBUser :
    43  func WithDBUser(user string) TraceOption {
    44  	return func(opt *TraceOptions) {
    45  		opt.DBUser = user
    46  	}
    47  }
    48  
    49  // WithPrepare :
    50  func WithPrepare(flag bool) TraceOption {
    51  	return func(opt *TraceOptions) {
    52  		opt.Prepare = flag
    53  	}
    54  }
    55  
    56  // WithExec :
    57  func WithExec(flag bool) TraceOption {
    58  	return func(opt *TraceOptions) {
    59  		opt.Exec = flag
    60  	}
    61  }
    62  
    63  // WithQuery :
    64  func WithQuery(flag bool) TraceOption {
    65  	return func(opt *TraceOptions) {
    66  		opt.Query = flag
    67  	}
    68  }
    69  
    70  // WithArgs :
    71  func WithArgs(flag bool) TraceOption {
    72  	return func(opt *TraceOptions) {
    73  		opt.Args = flag
    74  	}
    75  }
    76  
    77  // WithRowsClose :
    78  func WithRowsClose(flag bool) TraceOption {
    79  	return func(opt *TraceOptions) {
    80  		opt.RowsClose = flag
    81  	}
    82  }