// openDBDriver is the callback provided during driver registration that opens
// an existing database for use.
188415
func openDBDriver(args ...interface{}) (walletdb.DB, error) {
	dbPath, err := parseArgs("Open", args...)
	if err != nil {
		return nil, err
	}

	return openDB(dbPath, false)
}
1296640
func NewGenericDriver(db *sql.DB, dialect Dialect) *GenericDriver {
	if db == nil {
		panic("darwin: sql.DB is nil")
	}

	if dialect == nil {
		panic("darwin: dialect is nil")
	}

	return &GenericDriver{DB: db, Dialect: dialect}
}
834569
func GetDriver(name string) Driver {
	driversMu.Lock()
	defer driversMu.Unlock()
	driver := drivers[name]
	return driver
}
984212
func Open(driverName, dataSourceName string) (*DB, error) {
	db, err := sql.Open(driverName, dataSourceName)
	if err != nil {
		return nil, err
	}
	return &DB{DB: db, driverName: driverName, Mapper: mapper()}, err
}
211455
func NewDriver(a ble.BLEConnector) *Driver {
	n := &Driver{
		name:       gobot.DefaultName("Minidrone"),
		connection: a,
		Pcmd: Pcmd{
			Flag:  0,
			Roll:  0,
			Pitch: 0,
			Yaw:   0,
			Gaz:   0,
			Psi:   0,
		},
		Eventer: gobot.NewEventer(),
	}

	n.AddEvent(Battery)
	n.AddEvent(FlightStatus)

	n.AddEvent(Takeoff)
	n.AddEvent(Flying)
	n.AddEvent(Hovering)
	n.AddEvent(Landing)
	n.AddEvent(Landed)
	n.AddEvent(Emergency)
	n.AddEvent(Rolling)

	return n
}
223324
func createDBDriver(args ...interface{}) (database.DB, error) {
	dbPath, network, err := parseArgs("Create", args...)
	if err != nil {
		return nil, err
	}

	return openDB(dbPath, network, true)
}
909226
func (d *boltDriverPool) OpenPool() (Conn, error) {
	// For each connection request we need to block in case the Close function is called. This gives us a guarantee
	// when closing the pool no new connections are made.
	d.refLock.Lock()
	defer d.refLock.Unlock()
	if !d.closed {
		conn := <-d.pool
		if connectionNilOrClosed(conn) {
			if err := conn.initialize(); err != nil {
				return nil, err
			}
			d.connRefs = append(d.connRefs, conn)
		}
		return conn, nil
	}
	return nil, errors.New("Driver pool has been closed")
}
1093422
func NewDriver(a BaseAdaptor, v ...time.Duration) *Driver {
	m := &Driver{
		name:       "Mavlink",
		connection: a,
		Eventer:    gobot.NewEventer(),
		interval:   10 * time.Millisecond,
	}

	if len(v) > 0 {
		m.interval = v[0]
	}

	m.AddEvent(PacketEvent)
	m.AddEvent(MessageEvent)
	m.AddEvent(ErrorIOEvent)
	m.AddEvent(ErrorMAVLinkEvent)

	return m
}
1369635
func NewDriverChecker(ctx Context, drivers map[string]struct{}) *DriverChecker {
	return &DriverChecker{
		ctx:     ctx,
		drivers: drivers,
	}
}
832450
func RegisterDriver(name string, driver Driver) {
	driversMu.Lock()
	defer driversMu.Unlock()
	if driver == nil {
		panic("driver: Register driver is nil")
	}
	if _, dup := drivers[name]; dup {
		panic("sql: Register called twice for driver " + name)
	}
	drivers[name] = driver
}
413624
func (c *Config) OpenConnector(logger log.Logger) (interface {
	connector.Connector
	connector.PasswordConnector
	connector.RefreshConnector
}, error) {
	return c.openConnector(logger)
}
1351089
func CheckDriver(driver string) Check {
	return func() error {
		cli, err := newClient()
		if err != nil {
			return fmt.Errorf("creating client: %v", err)
		}
		info, err := cli.Info()
		if err != nil {
			return fmt.Errorf("getting info: %v", err)
		}
		if info.Driver != driver {
			return fmt.Errorf("driver is '%s' not 'driver'", info.Driver, driver)
		}
		return nil
	}
}
267164
func NewRedis(dbType, dbpath string, debugSQL bool) (driver *RedisDriver, locked bool, err error) {
	driver = &RedisDriver{
		name: dbType,
	}
	log.Debugf("Opening DB (%s).", driver.Name())
	if err = driver.OpenDB(dbType, dbpath, debugSQL); err != nil {
		return
	}

	return
}
890898
func (n *Node) OpenDatabase(name string, cache, handles int, namespace string) (ethdb.Database, error) {
	if n.config.DataDir == "" {
		return rawdb.NewMemoryDatabase(), nil
	}
	return rawdb.NewLevelDBDatabase(n.config.ResolvePath(name), cache, handles, namespace)
}
98267
func (ctx *ServiceContext) OpenDatabase(name string, cache int, handles int, namespace string) (ethdb.Database, error) {
	if ctx.config.DataDir == "" {
		return rawdb.NewMemoryDatabase(), nil
	}
	db, err := rawdb.NewLevelDBDatabase(ctx.config.ResolvePath(name), cache, handles, namespace)
	if err != nil {
		return nil, err
	}
	return db, nil
}
51801
func openDB(dbPath string, create bool) (walletdb.DB, error) {
	if !create && !fileExists(dbPath) {
		return nil, walletdb.ErrDbDoesNotExist
	}

	boltDB, err := bbolt.Open(dbPath, 0600, nil)
	return (*db)(boltDB), convertErr(err)
}
234759
func MustDriver(ctx context.Context) types.StorageDriver {
	v, _ := Driver(ctx)
	return v.(types.StorageDriver)
}