otgorm

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 7 Imported by: 0

README

opentracing-gorm

Go Report Card license

This project is a opentracing wrapper for gorm.

Getting Started

// pseudo code
package main
import (
	"net/http"
	_ "github.com/go-sql-driver/mysql"
	"github.com/jinzhu/gorm"
	otgorm "github.com/gjbae1212/opentracing-gorm"
)

func main() {
	// TODO: Set global opentracing tracer
	db, _ := gorm.Open("mysql", "user:password@/dbname")
	wdb, _ := otgorm.WrapDB(db)
	http.HandleFunc("/", func(rw http.ResponseWriter, r *http.Request) {
		gormDB := wdb.WithContext(r.Context())
		_ = gormDB.Table("users").Select("id").Row()
	})
	http.ListenAndServe(":8080", nil)
}

License

This project is licensed under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	WithContext(ctx context.Context) *gorm.DB
}

DB is a wrapper for *gorm.DB.

func WrapDB

func WrapDB(db *gorm.DB) (DB, error)

WrapDB returns a wrapping DB which is added callback functions for opentracing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL