rest

package
v0.0.0-...-8e4d058 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserKey     = "user"
	PasswordKey = "password"
)
View Source
const (
	WSConnect     = "conn"
	WSQuery       = "query"
	WSFetch       = "fetch"
	WSFetchBlock  = "fetch_block"
	WSFreeResult  = "free_result"
	ClientVersion = "version"
)
View Source
const LayoutMicroSecond = "2006-01-02 15:04:05.000000"
View Source
const LayoutMillSecond = "2006-01-02 15:04:05.000"
View Source
const LayoutNanoSecond = "2006-01-02 15:04:05.000000000"
View Source
const TaosSessionKey = "taos"

Variables

View Source
var (
	ExecHeader = []byte(`{"status":"succ","head":["affected_rows"],"column_meta":[["affected_rows",4,4]],"rows":1,"data":[[`)
	ExecEnd    = []byte(`]]}`)
	Query1     = []byte(`{"status":"succ","head":[`)
	Query2     = []byte(`],"column_meta":[`)
	Query3     = []byte(`],"data":[`)
	Query4     = []byte(`],"rows":`)
)

Functions

func CheckAuth

func CheckAuth(c *gin.Context)

func DecodeDes

func DecodeDes(auth string) (user, password string, err error)

func DoQuery

func DoQuery(c *gin.Context, db string, timeFunc ctools.FormatTimeFunc)

func EncodeDes

func EncodeDes(user, password string) (string, error)

func ErrorResponse

func ErrorResponse(c *gin.Context, code int)

func ErrorResponseWithMsg

func ErrorResponseWithMsg(c *gin.Context, code int, msg string)

Types

type Message

type Message struct {
	Status string `json:"status"`
	Code   int    `json:"code"`
	Desc   string `json:"desc"`
}

type Restful

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

func (*Restful) Close

func (ctl *Restful) Close()

func (*Restful) Init

func (ctl *Restful) Init(r gin.IRouter)

func (*Restful) InitWS

func (ctl *Restful) InitWS()

type Result

type Result struct {
	TaosResult  unsafe.Pointer
	FieldsCount int
	Header      *wrapper.RowsHeader
	Lengths     []int
	Size        int
	Block       unsafe.Pointer

	sync.Mutex
	// contains filtered or unexported fields
}

func (*Result) FreeResult

func (r *Result) FreeResult()

type TDEngineRestfulResp

type TDEngineRestfulResp struct {
	Status     string           `json:"status"`
	Head       []string         `json:"head"`
	ColumnMeta [][]interface{}  `json:"column_meta"`
	Data       [][]driver.Value `json:"data"`
	Rows       int              `json:"rows"`
}

type TDEngineRestfulRespDoc

type TDEngineRestfulRespDoc struct {
	Status     string          `json:"status,omitempty"`
	Head       []string        `json:"head,omitempty"`
	ColumnMeta [][]interface{} `json:"column_meta,omitempty"`
	Data       [][]interface{} `json:"data,omitempty"`
	Rows       int             `json:"rows,omitempty"`
	Code       int             `json:"code,omitempty"`
	Desc       string          `json:"desc,omitempty"`
}

type Taos

type Taos struct {
	Session *melody.Session
	Conn    *commonpool.Conn

	Results *list.List

	sync.Mutex
	// contains filtered or unexported fields
}

func NewTaos

func NewTaos() *Taos

func (*Taos) AddResult

func (t *Taos) AddResult(result *Result)

func (*Taos) Close

func (t *Taos) Close()

func (*Taos) FreeResult

func (t *Taos) FreeResult(element *list.Element)

func (*Taos) GetResult

func (t *Taos) GetResult(index uint64) *list.Element

type WSAction

type WSAction struct {
	Action string          `json:"action"`
	Args   json.RawMessage `json:"args"`
}

type WSConnectReq

type WSConnectReq struct {
	ReqID    uint64 `json:"req_id"`
	User     string `json:"user"`
	Password string `json:"password"`
	DB       string `json:"db"`
}

type WSConnectResp

type WSConnectResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
}

type WSErrorResp

type WSErrorResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	ReqID   uint64 `json:"req_id"`
}

type WSFetchBlockReq

type WSFetchBlockReq struct {
	ReqID uint64 `json:"req_id"`
	ID    uint64 `json:"id"`
}

type WSFetchReq

type WSFetchReq struct {
	ReqID uint64 `json:"req_id"`
	ID    uint64 `json:"id"`
}

type WSFetchResp

type WSFetchResp struct {
	Code      int    `json:"code"`
	Message   string `json:"message"`
	Action    string `json:"action"`
	ReqID     uint64 `json:"req_id"`
	ID        uint64 `json:"id"`
	Completed bool   `json:"completed"`
	Lengths   []int  `json:"lengths"`
	Rows      int    `json:"rows"`
}

type WSFreeResultReq

type WSFreeResultReq struct {
	ReqID uint64 `json:"req_id"`
	ID    uint64 `json:"id"`
}

type WSQueryReq

type WSQueryReq struct {
	ReqID uint64 `json:"req_id"`
	SQL   string `json:"sql"`
}

type WSQueryResult

type WSQueryResult struct {
	Code          int      `json:"code"`
	Message       string   `json:"message"`
	Action        string   `json:"action"`
	ReqID         uint64   `json:"req_id"`
	ID            uint64   `json:"id"`
	IsUpdate      bool     `json:"is_update"`
	AffectedRows  int      `json:"affected_rows"`
	FieldsCount   int      `json:"fields_count"`
	FieldsNames   []string `json:"fields_names"`
	FieldsTypes   []int    `json:"fields_types"`
	FieldsLengths []int    `json:"fields_lengths"`
	Precision     int      `json:"precision"`
}

type WSVersionResp

type WSVersionResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Action  string `json:"action"`
	Version string `json:"version"`
}

type Writer

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

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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