relay

package
v0.0.0-...-c61326f Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: PostgreSQL Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Message from client
	BufferedMessageRegular = BufferedMessageType(0)
	// Message produced by spqr
	BufferedMessageInternal = BufferedMessageType(1)
)

Variables

View Source
var ErrSkipQuery = fmt.Errorf("wait for a next query")

Functions

func AdvancedPoolModeNeeded

func AdvancedPoolModeNeeded(rst RelayStateMgr) bool

func ProcQueryAdvanced

func ProcQueryAdvanced(rst RelayStateMgr, query string, state parser.ParseState, comment string, binderQ func() error, doCaching bool) error

ProcQueryAdvanced processes query, with router relay state There are several types of query that we want to process in non-passthrough way. For example, after BEGIN we wait until first client query witch can be router to some shard. So, we need to process SETs, BEGINs, ROLLBACKs etc ourselves. QueryStateExecutor provides set of function for either simple of extended protoc interactions query param is either plain query from simple proto or bind query from x proto

func ProcQueryAdvancedTx

func ProcQueryAdvancedTx(rst RelayStateMgr, query string, binderQ func() error, doCaching, completeRelay bool) error

func ReplyVirtualParamState

func ReplyVirtualParamState(cl client.Client, name string, val []byte)

Types

type BufferedMessage

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

func InternalBufferedMessage

func InternalBufferedMessage(q pgproto3.FrontendMessage) BufferedMessage

func RegularBufferedMessage

func RegularBufferedMessage(q pgproto3.FrontendMessage) BufferedMessage

type BufferedMessageType

type BufferedMessageType int

type ParseCacheEntry

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

type PortalDesc

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

type QueryDesc

type QueryDesc struct {
	Msg  pgproto3.FrontendMessage
	Stmt lyx.Node
	P    plan.Plan
}

type QueryStateExecutor

type QueryStateExecutor interface {
	txstatus.TxStatusMgr

	Client() client.RouterClient

	Deploy(server server.Server) error

	ExecBegin(rst RelayStateMgr, query string, st *parser.ParseStateTXBegin) error
	ExecCommit(rst RelayStateMgr, query string) error
	ExecRollback(rst RelayStateMgr, query string) error

	/* Copy execution */
	ProcCopyPrepare(ctx context.Context, mgr meta.EntityMgr, stmt *lyx.Copy) (*pgcopy.CopyState, error)
	ProcCopy(ctx context.Context, data *pgproto3.CopyData, cps *pgcopy.CopyState) ([]byte, error)
	ProcCopyComplete(query pgproto3.FrontendMessage) error

	ProcQuery(qd *QueryDesc, mgr meta.EntityMgr, waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)

	ExecSet(rst RelayStateMgr, query, name, value string) error
	ExecSetLocal(rst RelayStateMgr, query, name, value string) error
	ExecReset(rst RelayStateMgr, query, name string) error
	ExecResetMetadata(rst RelayStateMgr, query, setting string) error
}

Execute required command via some protoc-specific logic

func NewQueryStateExecutor

func NewQueryStateExecutor(cl client.RouterClient) QueryStateExecutor

type QueryStateExecutorImpl

type QueryStateExecutorImpl struct {
	txstatus.TxStatusMgr
	// contains filtered or unexported fields
}

func (*QueryStateExecutorImpl) Client

func (*QueryStateExecutorImpl) Deploy

func (s *QueryStateExecutorImpl) Deploy(server server.Server) error

Deploy implements QueryStateExecutor.

func (*QueryStateExecutorImpl) ExecBegin

func (*QueryStateExecutorImpl) ExecCommit

func (s *QueryStateExecutorImpl) ExecCommit(rst RelayStateMgr, query string) error

query in commit query. maybe commit or commit `name`

func (*QueryStateExecutorImpl) ExecReset

func (s *QueryStateExecutorImpl) ExecReset(rst RelayStateMgr, query, setting string) error

func (*QueryStateExecutorImpl) ExecResetMetadata

func (s *QueryStateExecutorImpl) ExecResetMetadata(rst RelayStateMgr, query string, setting string) error

func (*QueryStateExecutorImpl) ExecRollback

func (s *QueryStateExecutorImpl) ExecRollback(rst RelayStateMgr, query string) error

TODO: proper support for rollback to savepoint

func (*QueryStateExecutorImpl) ExecSet

func (s *QueryStateExecutorImpl) ExecSet(rst RelayStateMgr, query string, name, value string) error

func (*QueryStateExecutorImpl) ExecSetLocal

func (s *QueryStateExecutorImpl) ExecSetLocal(rst RelayStateMgr, query, name, value string) error

func (*QueryStateExecutorImpl) ProcCopy

func (s *QueryStateExecutorImpl) ProcCopy(ctx context.Context, data *pgproto3.CopyData, cps *pgcopy.CopyState) ([]byte, error)

TODO : unit tests

func (*QueryStateExecutorImpl) ProcCopyComplete

func (s *QueryStateExecutorImpl) ProcCopyComplete(query pgproto3.FrontendMessage) error

TODO : unit tests

func (*QueryStateExecutorImpl) ProcCopyPrepare

func (s *QueryStateExecutorImpl) ProcCopyPrepare(ctx context.Context, mgr meta.EntityMgr, stmt *lyx.Copy) (*pgcopy.CopyState, error)

TODO: unit tests

func (*QueryStateExecutorImpl) ProcQuery

func (s *QueryStateExecutorImpl) ProcQuery(qd *QueryDesc, mgr meta.EntityMgr, waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)

TODO : unit tests

func (*QueryStateExecutorImpl) SetTxStatus

func (s *QueryStateExecutorImpl) SetTxStatus(status txstatus.TXStatus)

func (*QueryStateExecutorImpl) TxStatus

type RelayStateImpl

type RelayStateImpl struct {
	Qr qrouter.QueryRouter

	Cl client.RouterClient
	// contains filtered or unexported fields
}

func (*RelayStateImpl) ActiveShards

func (rst *RelayStateImpl) ActiveShards() []kr.ShardKey

func (*RelayStateImpl) ActiveShardsReset

func (rst *RelayStateImpl) ActiveShardsReset()

func (*RelayStateImpl) AddExtendedProtocMessage

func (rst *RelayStateImpl) AddExtendedProtocMessage(q pgproto3.FrontendMessage)

TODO : unit tests

func (*RelayStateImpl) AddQuery

func (rst *RelayStateImpl) AddQuery(q pgproto3.FrontendMessage)

TODO : unit tests

func (*RelayStateImpl) AddSilentQuery

func (rst *RelayStateImpl) AddSilentQuery(q pgproto3.FrontendMessage)

TODO : unit tests

func (*RelayStateImpl) Client

func (rst *RelayStateImpl) Client() client.RouterClient

func (*RelayStateImpl) Close

func (rst *RelayStateImpl) Close() error

func (*RelayStateImpl) CompleteRelay

func (rst *RelayStateImpl) CompleteRelay(replyCl bool) error

func (*RelayStateImpl) Connect

func (rst *RelayStateImpl) Connect() error

TODO : unit tests

func (*RelayStateImpl) CurrentRoutes

func (rst *RelayStateImpl) CurrentRoutes() []kr.ShardKey

TODO : unit tests

func (*RelayStateImpl) DataPending

func (rst *RelayStateImpl) DataPending() bool

func (*RelayStateImpl) DeployPrepStmt

TODO : unit tests

func (*RelayStateImpl) Flush

func (rst *RelayStateImpl) Flush()

TODO : unit tests

func (*RelayStateImpl) HoldRouting

func (rst *RelayStateImpl) HoldRouting()

HoldRouting implements RelayStateMgr.

func (*RelayStateImpl) Parse

func (rst *RelayStateImpl) Parse(query string, doCaching bool) (parser.ParseState, string, error)

TODO : unit tests

func (*RelayStateImpl) PoolMgr

func (rst *RelayStateImpl) PoolMgr() poolmgr.PoolMgr

func (*RelayStateImpl) PrepareRelayStep

func (rst *RelayStateImpl) PrepareRelayStep() error

TODO : unit tests

func (*RelayStateImpl) PrepareRelayStepOnAnyRoute

func (rst *RelayStateImpl) PrepareRelayStepOnAnyRoute() (func() error, error)

TODO : unit tests

func (*RelayStateImpl) PrepareRelayStepOnHintRoute

func (rst *RelayStateImpl) PrepareRelayStepOnHintRoute(route *kr.ShardKey) error

TODO : unit tests

func (*RelayStateImpl) PrepareStatement

TODO : unit tests

func (*RelayStateImpl) ProcessExtendedBuffer

func (rst *RelayStateImpl) ProcessExtendedBuffer() error

TODO : unit tests

func (*RelayStateImpl) ProcessMessage

func (rst *RelayStateImpl) ProcessMessage(
	msg pgproto3.FrontendMessage,
	waitForResp, replyCl bool) error

TODO : unit tests

func (*RelayStateImpl) ProcessMessageBuf

func (rst *RelayStateImpl) ProcessMessageBuf(waitForResp, replyCl bool) error

TODO : unit tests

func (*RelayStateImpl) QueryExecutor

func (rst *RelayStateImpl) QueryExecutor() QueryStateExecutor

func (*RelayStateImpl) QueryRouter

func (rst *RelayStateImpl) QueryRouter() qrouter.QueryRouter

func (*RelayStateImpl) RelayFlush

func (rst *RelayStateImpl) RelayFlush(waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)

TODO : unit tests

func (*RelayStateImpl) RelayStep

func (rst *RelayStateImpl) RelayStep(msg pgproto3.FrontendMessage, waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)

TODO : unit tests

func (*RelayStateImpl) Reroute

func (rst *RelayStateImpl) Reroute() ([]*kr.ShardKey, error)

TODO : unit tests

func (*RelayStateImpl) RerouteToRandomRoute

func (rst *RelayStateImpl) RerouteToRandomRoute() error

TODO : unit tests

func (*RelayStateImpl) RerouteToTargetRoute

func (rst *RelayStateImpl) RerouteToTargetRoute(route *kr.ShardKey) error

TODO : unit tests

func (*RelayStateImpl) Reset

func (rst *RelayStateImpl) Reset() error

TODO : unit tests

func (*RelayStateImpl) SetTxStatus

func (rst *RelayStateImpl) SetTxStatus(status txstatus.TXStatus)

SetTxStatus implements poolmgr.ConnectionKeeper.

func (*RelayStateImpl) StartTrace

func (rst *RelayStateImpl) StartTrace()

func (*RelayStateImpl) SyncCount

func (rst *RelayStateImpl) SyncCount() int64

func (*RelayStateImpl) TxStatus

func (rst *RelayStateImpl) TxStatus() txstatus.TXStatus

TxStatus implements poolmgr.ConnectionKeeper.

func (*RelayStateImpl) UnRouteWithError

func (rst *RelayStateImpl) UnRouteWithError(shkey []kr.ShardKey, errmsg error) error

TODO : unit tests

func (*RelayStateImpl) UnholdRouting

func (rst *RelayStateImpl) UnholdRouting()

UnholdRouting implements RelayStateMgr.

func (*RelayStateImpl) Unroute

func (rst *RelayStateImpl) Unroute(shkey []kr.ShardKey) error

TODO : unit tests

type RelayStateMgr

type RelayStateMgr interface {
	poolmgr.ConnectionKeeper
	route.RouteMgr

	QueryExecutor() QueryStateExecutor
	QueryRouter() qrouter.QueryRouter
	PoolMgr() poolmgr.PoolMgr

	Reset() error
	Flush()

	Parse(query string, doCaching bool) (parser.ParseState, string, error)

	AddQuery(q pgproto3.FrontendMessage)
	AddSilentQuery(q pgproto3.FrontendMessage)

	RelayStep(msg pgproto3.FrontendMessage, waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)

	CompleteRelay(replyCl bool) error
	Close() error
	Client() client.RouterClient

	PrepareStatement(hash uint64, d *prepstatement.PreparedStatementDefinition) (*prepstatement.PreparedStatementDescriptor, pgproto3.BackendMessage, error)

	PrepareRelayStep() error
	PrepareRelayStepOnAnyRoute() (func() error, error)
	PrepareRelayStepOnHintRoute(route *kr.ShardKey) error

	HoldRouting()
	UnholdRouting()

	/* process extended proto */
	ProcessMessage(msg pgproto3.FrontendMessage, waitForResp, replyCl bool) error
	ProcessMessageBuf(waitForResp, replyCl bool) error

	AddExtendedProtocMessage(q pgproto3.FrontendMessage)
	ProcessExtendedBuffer() error
}

func NewRelayState

func NewRelayState(qr qrouter.QueryRouter, client client.RouterClient, manager poolmgr.PoolMgr) RelayStateMgr

Jump to

Keyboard shortcuts

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