godbpool

package module
v0.0.0-...-35ea8dd Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 0 Imported by: 0

README

go-db-pool

CI Coverage Status Go Report Card

English | 简体中文

The concurrency fearless of Databases connection pool for Golang.

Support & TODO

Database/ORM Status Official Site Client Repo
gorm
https://gorm.io gorm repo
xorm https://xorm.io xorm repo
MongoDB https://www.mongodb.com mongo-go-driver
etcd https://etcd.io etcd v3 client
TiKV https://tikv.org TiKV client
Apache Cassandra https://cassandra.apache.org gocql

Examples

  • gorm pool
    package main
    
    import (
    	"context"  
    	"github.com/Basis-Health/godbpool"
    	"github.com/Basis-Health/godbpool/gormpool"
    	"log"  
    	"time"
    )
    
    func main() {
    	// config options
    	opts := gormpool.Options{
    		Type:            godbpool.MySQL,
    		Args:            "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True",
    		KeepConn:        2,
    		Capacity:        5,
    		MaxWaitDuration: 2000 * time.Millisecond,
    	}
    
    	// create a pool  
    	p, err := gormpool.NewPool(context.Background(), opts)
    	if err != nil {
    		log.Println(err)
    		return
    	}
    
      // Get a conn
      conn, err := p.Get()
      if err != nil {
          log.Println(err)
      }
    
      // ... do some CURD
    
      // put conn back to pool 
      p.Put(conn)
    
      // check the pool status
      p.Status()
    
      // close pool
      p.Close()
    }
    

Documentation

Overview

Package godbpool : The concurrency fearless of Databases connection pool for Golang.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLType

type SQLType uint8

SQLType means Support SQL database type

const (
	MySQL SQLType = iota
	PostgreSQL
	SQLite3
	SQLServer
)

Support SQL databases

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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