dbs

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0, Apache-2.0 Imports: 22 Imported by: 0

README

dbs

 _______ .______       _______.
|       \|   _  \     /       |
|  .--.  |  |_)  |   |   (----`
|  |  |  |   _  <     \   \
|  '--'  |  |_)  |.----)   |
|_______/|______/ |_______/

Consist of

  1. db admin service definition
    • purge
    • stats
    • exec/query for delete, update, insert, select
  2. db admin service implementation
  3. db framework
    • DB
    • AutoMigrate
    • AutoUpgrade

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OpenDB = openDB
)

Functions

func AutoMigrate

func AutoMigrate(values ...interface{})

func AutoUpgrade

func AutoUpgrade(name string, grade func(*gorm.DB) error)

func Commands

func Commands(getContext func() context.Context, getClient func() DBAdminClient) (commands []*cobra.Command)

func Config

func Config(v *viper.Viper)

func DB

func DB() *gorm.DB

func NewOrders

func NewOrders(s string, m ...[2]string) (orders []string)

NewOrders new orders s: sort string defined in api handbook collections sorting m: mappings

func Register

func Register(server *grpc.Server)

Register register db admin service in grpc server

func RegisterDBAdminServer

func RegisterDBAdminServer(s *grpc.Server, srv DBAdminServer)

func SetDB

func SetDB(db *gorm.DB)

func Sortby

func Sortby(db *gorm.DB, s string, m ...[2]string) *gorm.DB

Sortby Sort by `s` defined at api handbook collections sorting

func StartListen

func StartListen()

func TableNames

func TableNames() (names []string)

Types

type DBAdminClient

type DBAdminClient interface {
	Stats(ctx context.Context, in *StatsRequest, opts ...grpc.CallOption) (*StatsReply, error)
	Tables(ctx context.Context, in *TablesRequest, opts ...grpc.CallOption) (*TablesReply, error)
	Exec(ctx context.Context, in *ExecRequest, opts ...grpc.CallOption) (*ExecReply, error)
	Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryReply, error)
}

DBAdminClient is the client API for DBAdmin service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewDBAdminClient

func NewDBAdminClient(cc *grpc.ClientConn) DBAdminClient

type DBAdminServer

DBAdminServer is the server API for DBAdmin service.

type ExecReply

type ExecReply struct {
	Affected             int64    `protobuf:"varint,1,opt,name=affected,proto3" json:"affected,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ExecReply) Descriptor

func (*ExecReply) Descriptor() ([]byte, []int)

func (*ExecReply) GetAffected

func (m *ExecReply) GetAffected() int64

func (*ExecReply) ProtoMessage

func (*ExecReply) ProtoMessage()

func (*ExecReply) Reset

func (m *ExecReply) Reset()

func (*ExecReply) String

func (m *ExecReply) String() string

func (*ExecReply) XXX_DiscardUnknown

func (m *ExecReply) XXX_DiscardUnknown()

func (*ExecReply) XXX_Marshal

func (m *ExecReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ExecReply) XXX_Merge

func (m *ExecReply) XXX_Merge(src proto.Message)

func (*ExecReply) XXX_Size

func (m *ExecReply) XXX_Size() int

func (*ExecReply) XXX_Unmarshal

func (m *ExecReply) XXX_Unmarshal(b []byte) error

type ExecRequest

type ExecRequest struct {
	Sql                  string   `protobuf:"bytes,1,opt,name=sql,proto3" json:"sql,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ExecRequest) Descriptor

func (*ExecRequest) Descriptor() ([]byte, []int)

func (*ExecRequest) GetSql

func (m *ExecRequest) GetSql() string

func (*ExecRequest) ProtoMessage

func (*ExecRequest) ProtoMessage()

func (*ExecRequest) Reset

func (m *ExecRequest) Reset()

func (*ExecRequest) String

func (m *ExecRequest) String() string

func (*ExecRequest) XXX_DiscardUnknown

func (m *ExecRequest) XXX_DiscardUnknown()

func (*ExecRequest) XXX_Marshal

func (m *ExecRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ExecRequest) XXX_Merge

func (m *ExecRequest) XXX_Merge(src proto.Message)

func (*ExecRequest) XXX_Size

func (m *ExecRequest) XXX_Size() int

func (*ExecRequest) XXX_Unmarshal

func (m *ExecRequest) XXX_Unmarshal(b []byte) error

type QueryReply

type QueryReply struct {
	Result               []*Result `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"`
	XXX_NoUnkeyedLiteral struct{}  `json:"-"`
	XXX_unrecognized     []byte    `json:"-"`
	XXX_sizecache        int32     `json:"-"`
}

func (*QueryReply) Descriptor

func (*QueryReply) Descriptor() ([]byte, []int)

func (*QueryReply) GetResult

func (m *QueryReply) GetResult() []*Result

func (*QueryReply) ProtoMessage

func (*QueryReply) ProtoMessage()

func (*QueryReply) Reset

func (m *QueryReply) Reset()

func (*QueryReply) String

func (m *QueryReply) String() string

func (*QueryReply) XXX_DiscardUnknown

func (m *QueryReply) XXX_DiscardUnknown()

func (*QueryReply) XXX_Marshal

func (m *QueryReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryReply) XXX_Merge

func (m *QueryReply) XXX_Merge(src proto.Message)

func (*QueryReply) XXX_Size

func (m *QueryReply) XXX_Size() int

func (*QueryReply) XXX_Unmarshal

func (m *QueryReply) XXX_Unmarshal(b []byte) error

type QueryRequest

type QueryRequest struct {
	Sql                  string   `protobuf:"bytes,1,opt,name=sql,proto3" json:"sql,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*QueryRequest) Descriptor

func (*QueryRequest) Descriptor() ([]byte, []int)

func (*QueryRequest) GetSql

func (m *QueryRequest) GetSql() string

func (*QueryRequest) ProtoMessage

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) Reset

func (m *QueryRequest) Reset()

func (*QueryRequest) String

func (m *QueryRequest) String() string

func (*QueryRequest) XXX_DiscardUnknown

func (m *QueryRequest) XXX_DiscardUnknown()

func (*QueryRequest) XXX_Marshal

func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryRequest) XXX_Merge

func (m *QueryRequest) XXX_Merge(src proto.Message)

func (*QueryRequest) XXX_Size

func (m *QueryRequest) XXX_Size() int

func (*QueryRequest) XXX_Unmarshal

func (m *QueryRequest) XXX_Unmarshal(b []byte) error

type Result

type Result struct {
	Values               []string `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Result) Descriptor

func (*Result) Descriptor() ([]byte, []int)

func (*Result) GetValues

func (m *Result) GetValues() []string

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) Reset

func (m *Result) Reset()

func (*Result) String

func (m *Result) String() string

func (*Result) XXX_DiscardUnknown

func (m *Result) XXX_DiscardUnknown()

func (*Result) XXX_Marshal

func (m *Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Result) XXX_Merge

func (m *Result) XXX_Merge(src proto.Message)

func (*Result) XXX_Size

func (m *Result) XXX_Size() int

func (*Result) XXX_Unmarshal

func (m *Result) XXX_Unmarshal(b []byte) error

type Stats

type Stats struct {
	MaxOpenConnections   int64    `protobuf:"varint,1,opt,name=max_open_connections,json=maxOpenConnections,proto3" json:"max_open_connections,omitempty"`
	OpenConnections      int64    `protobuf:"varint,2,opt,name=open_connections,json=openConnections,proto3" json:"open_connections,omitempty"`
	InUse                int64    `protobuf:"varint,3,opt,name=in_use,json=inUse,proto3" json:"in_use,omitempty"`
	Idle                 int64    `protobuf:"varint,4,opt,name=idle,proto3" json:"idle,omitempty"`
	WaitCount            int64    `protobuf:"varint,5,opt,name=wait_count,json=waitCount,proto3" json:"wait_count,omitempty"`
	WaitDuration         int64    `protobuf:"varint,6,opt,name=wait_duration,json=waitDuration,proto3" json:"wait_duration,omitempty"`
	MaxIdleClosed        int64    `protobuf:"varint,7,opt,name=max_idle_closed,json=maxIdleClosed,proto3" json:"max_idle_closed,omitempty"`
	MaxLifetimeClosed    int64    `protobuf:"varint,8,opt,name=max_lifetime_closed,json=maxLifetimeClosed,proto3" json:"max_lifetime_closed,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Stats) Descriptor

func (*Stats) Descriptor() ([]byte, []int)

func (*Stats) GetIdle

func (m *Stats) GetIdle() int64

func (*Stats) GetInUse

func (m *Stats) GetInUse() int64

func (*Stats) GetMaxIdleClosed

func (m *Stats) GetMaxIdleClosed() int64

func (*Stats) GetMaxLifetimeClosed

func (m *Stats) GetMaxLifetimeClosed() int64

func (*Stats) GetMaxOpenConnections

func (m *Stats) GetMaxOpenConnections() int64

func (*Stats) GetOpenConnections

func (m *Stats) GetOpenConnections() int64

func (*Stats) GetWaitCount

func (m *Stats) GetWaitCount() int64

func (*Stats) GetWaitDuration

func (m *Stats) GetWaitDuration() int64

func (*Stats) ProtoMessage

func (*Stats) ProtoMessage()

func (*Stats) Reset

func (m *Stats) Reset()

func (*Stats) String

func (m *Stats) String() string

func (*Stats) XXX_DiscardUnknown

func (m *Stats) XXX_DiscardUnknown()

func (*Stats) XXX_Marshal

func (m *Stats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Stats) XXX_Merge

func (m *Stats) XXX_Merge(src proto.Message)

func (*Stats) XXX_Size

func (m *Stats) XXX_Size() int

func (*Stats) XXX_Unmarshal

func (m *Stats) XXX_Unmarshal(b []byte) error

type StatsReply

type StatsReply struct {
	Stats                *Stats   `protobuf:"bytes,1,opt,name=stats,proto3" json:"stats,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StatsReply) Descriptor

func (*StatsReply) Descriptor() ([]byte, []int)

func (*StatsReply) GetStats

func (m *StatsReply) GetStats() *Stats

func (*StatsReply) ProtoMessage

func (*StatsReply) ProtoMessage()

func (*StatsReply) Reset

func (m *StatsReply) Reset()

func (*StatsReply) String

func (m *StatsReply) String() string

func (*StatsReply) XXX_DiscardUnknown

func (m *StatsReply) XXX_DiscardUnknown()

func (*StatsReply) XXX_Marshal

func (m *StatsReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StatsReply) XXX_Merge

func (m *StatsReply) XXX_Merge(src proto.Message)

func (*StatsReply) XXX_Size

func (m *StatsReply) XXX_Size() int

func (*StatsReply) XXX_Unmarshal

func (m *StatsReply) XXX_Unmarshal(b []byte) error

type StatsRequest

type StatsRequest struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*StatsRequest) Descriptor

func (*StatsRequest) Descriptor() ([]byte, []int)

func (*StatsRequest) ProtoMessage

func (*StatsRequest) ProtoMessage()

func (*StatsRequest) Reset

func (m *StatsRequest) Reset()

func (*StatsRequest) String

func (m *StatsRequest) String() string

func (*StatsRequest) XXX_DiscardUnknown

func (m *StatsRequest) XXX_DiscardUnknown()

func (*StatsRequest) XXX_Marshal

func (m *StatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StatsRequest) XXX_Merge

func (m *StatsRequest) XXX_Merge(src proto.Message)

func (*StatsRequest) XXX_Size

func (m *StatsRequest) XXX_Size() int

func (*StatsRequest) XXX_Unmarshal

func (m *StatsRequest) XXX_Unmarshal(b []byte) error

type Table

type Table struct {
	Rows                 int64    `protobuf:"varint,2,opt,name=rows,proto3" json:"rows,omitempty"`
	Deleted              int64    `protobuf:"varint,3,opt,name=deleted,proto3" json:"deleted,omitempty"`
	Error                string   `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Table) Descriptor

func (*Table) Descriptor() ([]byte, []int)

func (*Table) GetDeleted

func (m *Table) GetDeleted() int64

func (*Table) GetError

func (m *Table) GetError() string

func (*Table) GetRows

func (m *Table) GetRows() int64

func (*Table) ProtoMessage

func (*Table) ProtoMessage()

func (*Table) Reset

func (m *Table) Reset()

func (*Table) String

func (m *Table) String() string

func (*Table) XXX_DiscardUnknown

func (m *Table) XXX_DiscardUnknown()

func (*Table) XXX_Marshal

func (m *Table) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Table) XXX_Merge

func (m *Table) XXX_Merge(src proto.Message)

func (*Table) XXX_Size

func (m *Table) XXX_Size() int

func (*Table) XXX_Unmarshal

func (m *Table) XXX_Unmarshal(b []byte) error

type TablesReply

type TablesReply struct {
	Tables               map[string]*Table `` /* 153-byte string literal not displayed */
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

func (*TablesReply) Descriptor

func (*TablesReply) Descriptor() ([]byte, []int)

func (*TablesReply) GetTables

func (m *TablesReply) GetTables() map[string]*Table

func (*TablesReply) ProtoMessage

func (*TablesReply) ProtoMessage()

func (*TablesReply) Reset

func (m *TablesReply) Reset()

func (*TablesReply) String

func (m *TablesReply) String() string

func (*TablesReply) XXX_DiscardUnknown

func (m *TablesReply) XXX_DiscardUnknown()

func (*TablesReply) XXX_Marshal

func (m *TablesReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TablesReply) XXX_Merge

func (m *TablesReply) XXX_Merge(src proto.Message)

func (*TablesReply) XXX_Size

func (m *TablesReply) XXX_Size() int

func (*TablesReply) XXX_Unmarshal

func (m *TablesReply) XXX_Unmarshal(b []byte) error

type TablesRequest

type TablesRequest struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TablesRequest) Descriptor

func (*TablesRequest) Descriptor() ([]byte, []int)

func (*TablesRequest) ProtoMessage

func (*TablesRequest) ProtoMessage()

func (*TablesRequest) Reset

func (m *TablesRequest) Reset()

func (*TablesRequest) String

func (m *TablesRequest) String() string

func (*TablesRequest) XXX_DiscardUnknown

func (m *TablesRequest) XXX_DiscardUnknown()

func (*TablesRequest) XXX_Marshal

func (m *TablesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TablesRequest) XXX_Merge

func (m *TablesRequest) XXX_Merge(src proto.Message)

func (*TablesRequest) XXX_Size

func (m *TablesRequest) XXX_Size() int

func (*TablesRequest) XXX_Unmarshal

func (m *TablesRequest) XXX_Unmarshal(b []byte) error

type UnimplementedDBAdminServer

type UnimplementedDBAdminServer struct {
}

UnimplementedDBAdminServer can be embedded to have forward compatible implementations.

func (*UnimplementedDBAdminServer) Exec

func (*UnimplementedDBAdminServer) Query

func (*UnimplementedDBAdminServer) Stats

func (*UnimplementedDBAdminServer) Tables

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL