shared

package
v0.0.0-...-0be08e2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package shared provides methods that are common to different types of worker

Index

Constants

View Source
const ErrInFailedTransaction = "pq: Could not complete operation in a failed transaction"
View Source
const LAST_INSERT_ID_BIND_OUT_NAME = ":p5000"

Variables

This section is empty.

Functions

func DebugString

func DebugString(data []byte) string

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

func WriteAll

func WriteAll(w io.Writer, ns *netstring.Netstring) error

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 QueryScopeType struct {
	NsCmd   string
	SqlHash string
}

type WorkerScopeType

type WorkerScopeType struct {
	Child_shutdown_flag bool
}

Jump to

Keyboard shortcuts

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