Documentation
¶
Index ¶
- Constants
- func CheckMethodVersion[Req interface{ ... }, T methodType](ctx context.Context, service string, versionMap map[T]int64, req Req) error
- func CheckMethodVersionWithRuntime[Req interface{ ... }, T methodType](ctx context.Context, rt Runtime, versionMap map[T]int64, req Req) error
- func GetLogger(sid string) *log.MOLogger
- func InTesting(sid string) bool
- func RunTest(sid string, fn func(rt Runtime))
- func SetupServiceBasedRuntime(service string, r Runtime)
- func SetupServiceRuntimeTestingContext(sid string)
- type LoggerName
- type Option
- type Runtime
- type TestingContext
- func (tc *TestingContext) GetAdjustLockResultFunc() func(txnID []byte, tableID uint64, res *lock.Result)
- func (tc *TestingContext) GetBeforeLockFunc() func(txnID []byte, tableID uint64)
- func (tc *TestingContext) SetAdjustLockResultFunc(fn func(txnID []byte, tableID uint64, res *lock.Result))
- func (tc *TestingContext) SetBeforeLockFunc(fn func(txnID []byte, tableID uint64))
Constants ¶
const ( // ClusterService cluster service ClusterService = "cluster-service" // ClusterService cluster service LockService = "lock-service" // InternalSQLExecutor attr name for internal sql executor InternalSQLExecutor = "internal-sql-executor" // AutoIncrementService attr name for AutoIncrementService AutoIncrementService = "auto-increment-service" // StatusServer is the global server of status of cluster. StatusServer = "status-server" // TxnTraceService txn trance service TxnTraceService = "txn-trace-service" // ShardService shard service ShardService = "shard-service" // ProcessCodecService process codec service ProcessCodecService = "process-codec-service" // PartitionService partition service PartitionService = "partition-service" // TxnOptions options used to create txn TxnOptions = "txn-options" // TxnMode runtime default txn mode TxnMode = "txn-mode" // TxnIsolation runtime default txn isolation TxnIsolation = "txn-isolation" // EnableCheckInvalidRCErrors enable check rc errors EnableCheckInvalidRCErrors = "enable-check-rc-invalid-error" // MOProtocolVersion is the protocol version of the MO services MOProtocolVersion = "protocol-version" // BackgroundCNSelector is the labels of the CN handing the background requests, including mo-logger, task-service. BackgroundCNSelector = "background-cn-selector" PipelineClient = "pipeline-client" // TestingContextKey is the key of context for testing TestingContextKey = "testing-context" CNMemoryThrottler = "cn-memory-throttler" )
The names of all global variables should be defined here.
Variables ¶
This section is empty.
Functions ¶
func CheckMethodVersion ¶ added in v1.1.0
func SetupServiceBasedRuntime ¶
SetupServiceBasedRuntime setup service based runtime.
func SetupServiceRuntimeTestingContext ¶
func SetupServiceRuntimeTestingContext( sid string, )
Types ¶
type Runtime ¶
type Runtime interface {
// ServiceType return service type
ServiceType() metadata.ServiceType
// ServiceUUID return service uuid
ServiceUUID() string
// Logger returns the top-level logger is set at the start of the MO and contains
// the service type and unique ID of the service; all subsequent loggers must be
// built on this logger.
Logger() *log.MOLogger
// SubLogger returns sub-loggers used for different purposes.
SubLogger(LoggerName) *log.MOLogger
// Clock returns the Clock instance of the current runtime environment
Clock() clock.Clock
// SetGlobalVariables set global variables which scope based in runtime.
SetGlobalVariables(name string, value any)
// GetGlobalVariables get global variables, return false if variables not found.
GetGlobalVariables(name string) (any, bool)
}
Runtime contains the runtime environment for a MO service. Each CN/DN/LOG service needs to receive a Runtime and will pass the Runtime to all components of the service. These Runtime may only be created in main or integration test framework.
Because most of our BVT tests and integration tests are run in a single mo-service process, which runs multiple CN, TN and LOG services, the Runtime cannot be set as a global variable, otherwise we would not be able to set a single Runtime for each service and each component.
In other words, there are no global variables inside mo-service, and the scope of global variables is in a Runtime.
Since each component holds a Runtime, all mo-service-level parameters should not appear in the parameter list of the component's initialization function, but should be replaced by the Runtime's global variables.
Unfortunately, we can't fully support the isolation of the service-level runtime between services and they still share a process-level runtime, but at least there is an advantage in that all service-level components are placed in the runtime, so that the configuration and components can be easily retrieved from the runtime without having to pass them as parameters, so that when adding service-level components in the future, there is no need to modify the parameter list.
func DefaultRuntimeWithLevel ¶ added in v0.8.0
DefaultRuntime used to test
func NewRuntime ¶
func NewRuntime(service metadata.ServiceType, uuid string, logger *zap.Logger, opts ...Option) Runtime
NewRuntime create a mo runtime environment.
func ServiceRuntime ¶
ServiceRuntime returns a service based runtime
type TestingContext ¶
func MustGetTestingContext ¶
func MustGetTestingContext( sid string, ) *TestingContext
func (*TestingContext) GetAdjustLockResultFunc ¶
func (tc *TestingContext) GetAdjustLockResultFunc() func(txnID []byte, tableID uint64, res *lock.Result)
func (*TestingContext) GetBeforeLockFunc ¶
func (tc *TestingContext) GetBeforeLockFunc() func(txnID []byte, tableID uint64)
func (*TestingContext) SetAdjustLockResultFunc ¶
func (tc *TestingContext) SetAdjustLockResultFunc( fn func(txnID []byte, tableID uint64, res *lock.Result), )
func (*TestingContext) SetBeforeLockFunc ¶
func (tc *TestingContext) SetBeforeLockFunc( fn func(txnID []byte, tableID uint64), )