runtime

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterService cluster service
	ClusterService = "cluster-service"
	// ClusterService cluster service
	LockService = "lock-service"
	// InternalSQLExecutor attr name for internal sql executor
	InternalSQLExecutor = "internal-sql-executor"
	// AutoIncrmentService attr name for AutoIncrmentService
	AutoIncrmentService = "auto-incrment-service"
	// StatusServer is the global server of status of cluster.
	StatusServer = "status-server"

	// 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"

	// BackgroundCNSelector is the labels of the CN handing the background requests, including mo-logger, task-service.
	BackgroundCNSelector = "background-cn-selector"
)

The names of all global variables should be defined here.

Variables

This section is empty.

Functions

func SetupProcessLevelRuntime

func SetupProcessLevelRuntime(r Runtime)

SetupProcessLevelRuntime set a process-level runtime. If the service does not support a service-level runtime when running in launch mode, it will use the process-level runtime. The process-level runtime must setup in main.

Types

type LoggerName

type LoggerName int
const (
	Default LoggerName = iota
	SystemInit
)

type Option

type Option func(*runtime)

Option used to setup runtime

func WithClock

func WithClock(clock clock.Clock) Option

WithClock setup clock for a runtime, CN and TN must contain an instance of the Clock that is used to provide the timestamp service to the transaction.

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 Runtimes 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 DefaultRuntime

func DefaultRuntime() Runtime

DefaultRuntime used to test

func DefaultRuntimeWithLevel added in v0.8.0

func DefaultRuntimeWithLevel(level zapcore.Level) Runtime

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 ProcessLevelRuntime

func ProcessLevelRuntime() Runtime

ProcessLevelRuntime returns a process-lelve runtime

Jump to

Keyboard shortcuts

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