sqliteserver

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 10 Imported by: 0

README

sqliteserver

Implement MySQL server protocol to expose sqlite database to all MySQL clients.

Users can use any MySQL client to connect to server and consume the database service just like working with MySQL server.

Usage

Initialize server

svr, err := sqliteserver.NewServer(sqliteserver.ServerConfig{
    Network:  "tcp",
    Address:  fmt.Sprintf("localhost:%d", viper.GetInt("server.port")),
    UserName: viper.GetString("database.user"),
    Password: viper.GetString("database.password"),
})

Start server

svr.Start()

Close server

svr.Close()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(pool DBPool) server.Handler

func SetLogger

func SetLogger(l Logger)

Types

type DBPool

type DBPool interface {
	UseDB(dbName string) (*sql.DB, error)
	Release(dbName string)
}

type Logger

type Logger interface {
	// Debug logs a message at DebugLevel. The message includes any fields passed
	// at the log site, as well as any fields accumulated on the logger.
	Debug(msg string, fields ...zap.Field)

	// Info logs a message at InfoLevel. The message includes any fields passed
	// at the log site, as well as any fields accumulated on the logger.
	Info(msg string, fields ...zap.Field)

	// Warn logs a message at WarnLevel. The message includes any fields passed
	// at the log site, as well as any fields accumulated on the logger.
	Warn(msg string, fields ...zap.Field)

	// Error logs a message at ErrorLevel. The message includes any fields passed
	// at the log site, as well as any fields accumulated on the logger.
	Error(msg string, fields ...zap.Field)
	// DPanic logs a message at DPanicLevel. The message includes any fields
	// passed at the log site, as well as any fields accumulated on the logger.
	//
	// If the logger is in development mode, it then panics (DPanic means
	// "development panic"). This is useful for catching errors that are
	// recoverable, but shouldn't ever happen.
	DPanic(msg string, fields ...zap.Field)

	// Panic logs a message at PanicLevel. The message includes any fields passed
	// at the log site, as well as any fields accumulated on the logger.
	//
	// The logger then panics, even if logging at PanicLevel is disabled.
	Panic(msg string, fields ...zap.Field)
	// Fatal logs a message at FatalLevel. The message includes any fields passed
	// at the log site, as well as any fields accumulated on the logger.
	//
	// The logger then calls os.Exit(1), even if logging at FatalLevel is
	// disabled.
	Fatal(msg string, fields ...zap.Field)
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg ServerConfig) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Start

func (s *Server) Start() error

type ServerConfig

type ServerConfig struct {
	Network      string
	Address      string
	UserName     string
	Password     string
	DatabasePath string
}

Jump to

Keyboard shortcuts

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