Documentation
¶
Index ¶
- Constants
- Variables
- func AdvancedPoolModeNeeded(rst RelayStateMgr) bool
- func ProcQueryAdvanced(rst RelayStateMgr, query string, state parser.ParseState, comment string, ...) error
- func ProcQueryAdvancedTx(rst RelayStateMgr, query string, binderQ func() error, ...) error
- func ReplyVirtualParamState(cl client.Client, name string, val []byte)
- type BufferedMessage
- type BufferedMessageType
- type ParseCacheEntry
- type PortalDesc
- type QueryDesc
- type QueryStateExecutor
- type QueryStateExecutorImpl
- func (s *QueryStateExecutorImpl) Client() client.RouterClient
- func (s *QueryStateExecutorImpl) Deploy(server server.Server) error
- func (s *QueryStateExecutorImpl) ExecBegin(rst RelayStateMgr, query string, st *parser.ParseStateTXBegin) error
- func (s *QueryStateExecutorImpl) ExecCommit(rst RelayStateMgr, query string) error
- func (s *QueryStateExecutorImpl) ExecReset(rst RelayStateMgr, query, setting string) error
- func (s *QueryStateExecutorImpl) ExecResetMetadata(rst RelayStateMgr, query string, setting string) error
- func (s *QueryStateExecutorImpl) ExecRollback(rst RelayStateMgr, query string) error
- func (s *QueryStateExecutorImpl) ExecSet(rst RelayStateMgr, query string, name, value string) error
- func (s *QueryStateExecutorImpl) ExecSetLocal(rst RelayStateMgr, query, name, value string) error
- func (s *QueryStateExecutorImpl) ProcCopy(ctx context.Context, data *pgproto3.CopyData, cps *pgcopy.CopyState) ([]byte, error)
- func (s *QueryStateExecutorImpl) ProcCopyComplete(query pgproto3.FrontendMessage) error
- func (s *QueryStateExecutorImpl) ProcCopyPrepare(ctx context.Context, mgr meta.EntityMgr, stmt *lyx.Copy) (*pgcopy.CopyState, error)
- func (s *QueryStateExecutorImpl) ProcQuery(qd *QueryDesc, mgr meta.EntityMgr, waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)
- func (s *QueryStateExecutorImpl) SetTxStatus(status txstatus.TXStatus)
- func (s *QueryStateExecutorImpl) TxStatus() txstatus.TXStatus
- type RelayStateImpl
- func (rst *RelayStateImpl) ActiveShards() []kr.ShardKey
- func (rst *RelayStateImpl) ActiveShardsReset()
- func (rst *RelayStateImpl) AddExtendedProtocMessage(q pgproto3.FrontendMessage)
- func (rst *RelayStateImpl) AddQuery(q pgproto3.FrontendMessage)
- func (rst *RelayStateImpl) AddSilentQuery(q pgproto3.FrontendMessage)
- func (rst *RelayStateImpl) Client() client.RouterClient
- func (rst *RelayStateImpl) Close() error
- func (rst *RelayStateImpl) CompleteRelay(replyCl bool) error
- func (rst *RelayStateImpl) Connect() error
- func (rst *RelayStateImpl) CurrentRoutes() []kr.ShardKey
- func (rst *RelayStateImpl) DataPending() bool
- func (rst *RelayStateImpl) DeployPrepStmt(qname string) (*prepstatement.PreparedStatementDescriptor, pgproto3.BackendMessage, error)
- func (rst *RelayStateImpl) Flush()
- func (rst *RelayStateImpl) HoldRouting()
- func (rst *RelayStateImpl) Parse(query string, doCaching bool) (parser.ParseState, string, error)
- func (rst *RelayStateImpl) PoolMgr() poolmgr.PoolMgr
- func (rst *RelayStateImpl) PrepareRelayStep() error
- func (rst *RelayStateImpl) PrepareRelayStepOnAnyRoute() (func() error, error)
- func (rst *RelayStateImpl) PrepareRelayStepOnHintRoute(route *kr.ShardKey) error
- func (rst *RelayStateImpl) PrepareStatement(hash uint64, d *prepstatement.PreparedStatementDefinition) (*prepstatement.PreparedStatementDescriptor, pgproto3.BackendMessage, error)
- func (rst *RelayStateImpl) ProcessExtendedBuffer() error
- func (rst *RelayStateImpl) ProcessMessage(msg pgproto3.FrontendMessage, waitForResp, replyCl bool) error
- func (rst *RelayStateImpl) ProcessMessageBuf(waitForResp, replyCl bool) error
- func (rst *RelayStateImpl) QueryExecutor() QueryStateExecutor
- func (rst *RelayStateImpl) QueryRouter() qrouter.QueryRouter
- func (rst *RelayStateImpl) RelayFlush(waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)
- func (rst *RelayStateImpl) RelayStep(msg pgproto3.FrontendMessage, waitForResp bool, replyCl bool) ([]pgproto3.BackendMessage, error)
- func (rst *RelayStateImpl) Reroute() ([]*kr.ShardKey, error)
- func (rst *RelayStateImpl) RerouteToRandomRoute() error
- func (rst *RelayStateImpl) RerouteToTargetRoute(route *kr.ShardKey) error
- func (rst *RelayStateImpl) Reset() error
- func (rst *RelayStateImpl) SetTxStatus(status txstatus.TXStatus)
- func (rst *RelayStateImpl) StartTrace()
- func (rst *RelayStateImpl) SyncCount() int64
- func (rst *RelayStateImpl) TxStatus() txstatus.TXStatus
- func (rst *RelayStateImpl) UnRouteWithError(shkey []kr.ShardKey, errmsg error) error
- func (rst *RelayStateImpl) UnholdRouting()
- func (rst *RelayStateImpl) Unroute(shkey []kr.ShardKey) error
- type RelayStateMgr
Constants ¶
const ( // Message from client BufferedMessageRegular = BufferedMessageType(0) // Message produced by spqr BufferedMessageInternal = BufferedMessageType(1) )
Variables ¶
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
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 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 (s *QueryStateExecutorImpl) Client() client.RouterClient
func (*QueryStateExecutorImpl) Deploy ¶
func (s *QueryStateExecutorImpl) Deploy(server server.Server) error
Deploy implements QueryStateExecutor.
func (*QueryStateExecutorImpl) ExecBegin ¶
func (s *QueryStateExecutorImpl) ExecBegin(rst RelayStateMgr, query string, st *parser.ParseStateTXBegin) error
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 ¶
func (s *QueryStateExecutorImpl) TxStatus() txstatus.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) CurrentRoutes ¶
func (rst *RelayStateImpl) CurrentRoutes() []kr.ShardKey
TODO : unit tests
func (*RelayStateImpl) DataPending ¶
func (rst *RelayStateImpl) DataPending() bool
func (*RelayStateImpl) DeployPrepStmt ¶
func (rst *RelayStateImpl) DeployPrepStmt(qname string) (*prepstatement.PreparedStatementDescriptor, pgproto3.BackendMessage, error)
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 ¶
func (rst *RelayStateImpl) PrepareStatement(hash uint64, d *prepstatement.PreparedStatementDefinition) (*prepstatement.PreparedStatementDescriptor, pgproto3.BackendMessage, error)
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) 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.
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