Documentation
¶
Overview ¶
Package shared provides methods that are common to different types of worker
Index ¶
Constants ¶
const ErrInFailedTransaction = "pq: Could not complete operation in a failed transaction"
const LAST_INSERT_ID_BIND_OUT_NAME = ":p5000"
Variables ¶
This section is empty.
Functions ¶
func DebugString ¶
DebugString is used for debugging to truncate strings bigger than 200 bytes
func Start ¶
func Start(adapter CmdProcessorAdapter)
Start is the initial method, performing the initializations and starting runworker() to wait for requests
Types ¶
type BindValue ¶
type BindValue struct {
// contains filtered or unexported fields
}
BindValue is a placeholder for a bind value, with index tracking its position in the query.
type CmdProcessor ¶
type CmdProcessor struct { // // socket to mux // SocketOut *os.File // // socket receiving ctrl messages from mux // SocketCtrl *os.File WorkerScope WorkerScopeType // contains filtered or unexported fields }
CmdProcessor holds the data needed to process the client commmands
func NewCmdProcessor ¶
func NewCmdProcessor(adapter CmdProcessorAdapter, sockMux *os.File, sockMuxCtrl *os.File) *CmdProcessor
NewCmdProcessor creates the processor using th egiven adapter
func (*CmdProcessor) InitDB ¶
func (cp *CmdProcessor) InitDB() error
InitDB performs various initializations at start time
func (*CmdProcessor) ProcessCmd ¶
func (cp *CmdProcessor) ProcessCmd(ns *netstring.Netstring) error
ProcessCmd implements the client commands like prepare, bind, execute, etc
func (*CmdProcessor) SendDbHeartbeat ¶
func (cp *CmdProcessor) SendDbHeartbeat() bool
type CmdProcessorAdapter ¶
type CmdProcessorAdapter interface { MakeSqlParser() (common.SQLParser, error) GetColTypeMap() map[string]int Heartbeat(*sql.DB) bool InitDB() (*sql.DB, error) /* ProcessError's workerScope["child_shutdown_flag"] = "1 or anything" can help terminate after the request */ ProcessError(errToProcess error, workerScope *WorkerScopeType, queryScope *QueryScopeType) // ProcessResult is used for date related types to translate between the database format to the mux format ProcessResult(colType string, res string) string UseBindNames() bool UseBindQuestionMark() bool // true for mysql, false for postgres $1 $2 binds }
CmdProcessorAdapter is interface for differentiating the specific database implementations. For example there is an adapter for MySQL, another for Oracle
type QueryScopeType ¶
type WorkerScopeType ¶
type WorkerScopeType struct {
Child_shutdown_flag bool
}