dbconfig

package
v0.1.0-alpha.17 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

dbconfig

The dbconfig package maintains the greptimedb configurations schema of different components.

The Go structs should be better to be generated by a tool automatically, but for now, it is just hand-writing.

Documentation

Index

Constants

View Source
const (
	AccessKeyIDSecretKey     = "access-key-id"
	SecretAccessKeySecretKey = "secret-access-key"
)

Variables

This section is empty.

Functions

func FromCluster

func FromCluster(cluster *v1alpha1.GreptimeDBCluster, componentKind v1alpha1.ComponentKind) ([]byte, error)

FromCluster creates config data from the cluster CRD.

func Marshal

func Marshal(config Config) ([]byte, error)

Marshal marshals the input config to toml.

func Merge

func Merge(extraConfigData []byte, baseConfig Config) error

Merge merges the extra config to the input object.

Types

type Config

type Config interface {
	// Kind returns the component kind of the config.
	Kind() v1alpha1.ComponentKind

	// ConfigureByCluster configures the config by the given cluster.
	ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster) error
}

Config is the interface for the config of greptimedb.

func FromFile

func FromFile(filename string, kind v1alpha1.ComponentKind) (Config, error)

FromFile creates config from the file.

func FromRawData

func FromRawData(raw []byte, kind v1alpha1.ComponentKind) (Config, error)

FromRawData creates config from the raw input.

func NewFromComponentKind

func NewFromComponentKind(kind v1alpha1.ComponentKind) (Config, error)

NewFromComponentKind creates config from the component kind.

type DatanodeConfig

type DatanodeConfig struct {
	// Node running mode.
	Mode string `toml:"mode,omitempty"`

	// Whether to use in-memory catalog.
	EnableMemoryCatalog *bool `toml:"enable_memory_catalog,omitempty"`

	// The datanode identifier, should be unique.
	NodeID *uint64 `toml:"node_id,omitempty"`

	// gRPC server address.
	RPCAddr string `toml:"rpc_addr,omitempty"`

	// Hostname of this node.
	RPCHostName string `toml:"rpc_hostname,omitempty"`

	// The number of gRPC server worker threads.
	RPCRuntimeSize int32 `toml:"rpc_runtime_size,omitempty"`

	MetaClientOptions struct {
		// Metasrv address list.
		MetaSrvAddrs []string `toml:"metasrv_addrs,omitempty"`

		// Operation timeout in milliseconds.
		TimeoutMillis int32 `toml:"timeout_millis,omitempty"`

		// Connect server timeout in milliseconds.
		ConnectTimeoutMillis int32 `toml:"connect_timeout_millis,omitempty"`

		// `TCP_NODELAY` option for accepted connections.
		TCPNoDelay *bool `toml:"tcp_nodelay,omitempty"`
	} `toml:"meta_client_options,omitempty"`

	Wal struct {
		Dir            string `toml:"dir,omitempty"`
		FileSize       string `toml:"file_size,omitempty"`
		PurgeThreshold string `toml:"purge_threshold,omitempty"`
		PurgeInterval  string `toml:"purge_interval,omitempty"`
		ReadBatchSize  int32  `toml:"read_batch_size,omitempty"`
		SyncWrite      *bool  `toml:"sync_write,omitempty"`
	} `toml:"wal,omitempty"`

	Storage struct {
		// Storage options.
		Type            string `toml:"type,omitempty"`
		DataHome        string `toml:"data_home,omitempty"`
		Bucket          string `toml:"bucket,omitempty"`
		Root            string `toml:"root,omitempty"`
		AccessKeyID     string `toml:"access_key_id,omitempty"`
		SecretAccessKey string `toml:"secret_access_key,omitempty"`
		AccessKeySecret string `toml:"access_key_secret,omitempty"`
		Endpoint        string `toml:"endpoint,omitempty"`
		Region          string `toml:"region,omitempty"`
		CachePath       string `toml:"cache_path,omitempty"`
		CacheCapacity   string `toml:"cache_capacity,omitempty"`

		// Storage manifest options.
		Manifest struct {
			// Region checkpoint actions margin.
			CheckpointMargin int32 `toml:"checkpoint_margin,omitempty"`

			// Region manifest logs and checkpoints gc execution duration.
			GCDuration string `toml:"gc_duration,omitempty"`

			// Whether to try creating a manifest checkpoint on region opening.
			CheckpointOnStartup *bool `toml:"checkpoint_on_startup,omitempty"`
		} `toml:"manifest,omitempty"`

		// Storage flush options.
		Flush struct {
			// Max inflight flush tasks.
			MaxFlushTasks int32 `toml:"max_flush_tasks,omitempty"`

			// Default write buffer size for a region.
			RegionWriteBufferSize string `toml:"region_write_buffer_size,omitempty"`

			// Interval to check whether a region needs flush.
			PickerScheduleInterval string `toml:"picker_schedule_interval,omitempty"`

			// Interval to auto flush a region if it has not flushed yet.
			AutoFlushInterval string `toml:"auto_flush_interval,omitempty"`

			// Global write buffer size for all regions.
			GlobalWriteBufferSize string `toml:"global_write_buffer_size,omitempty"`
		} `toml:"flush,omitempty"`
	} `toml:"storage,omitempty"`

	Procedure struct {
		MaxRetryTimes int32  `toml:"max_retry_times,omitempty"`
		RetryDelay    string `toml:"retry_delay,omitempty"`
	} `toml:"procedure,omitempty"`

	Logging struct {
		Dir   string `toml:"dir,omitempty"`
		Level string `toml:"level,omitempty"`
	} `toml:"logging,omitempty"`
}

DatanodeConfig is the configuration for the datanode.

func (*DatanodeConfig) ConfigureByCluster

func (c *DatanodeConfig) ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster) error

ConfigureByCluster configures the datanode config by the given cluster.

func (*DatanodeConfig) Kind

Kind returns the component kind of the datanode.

type FrontendConfig

type FrontendConfig struct {
	// Node running mode.
	Mode string `toml:"mode,omitempty"`

	HTTPOptions struct {
		Addr    string `toml:"addr,omitempty"`
		Timeout string `toml:"timeout,omitempty"`
	} `toml:"http_options,omitempty"`

	GRPCOptions struct {
		Addr        string `toml:"addr,omitempty"`
		RuntimeSize int32  `toml:"runtime_size,omitempty"`
	} `toml:"grpc_options,omitempty"`

	// MySQL server options.
	MySQLOptions struct {
		Addr        string `toml:"addr,omitempty"`
		RuntimeSize int32  `toml:"runtime_size,omitempty"`

		// MySQL server TLS options.
		TLS struct {
			Mode     string `toml:"mode,omitempty"`
			CertPath string `toml:"cert_path,omitempty"`
			KeyPath  string `toml:"key_path,omitempty"`
		} `toml:"tls,omitempty"`
	} `toml:"mysql_options,omitempty"`

	// Postgres server options.
	PostgresOptions struct {
		Addr        string `toml:"addr,omitempty"`
		RuntimeSize int32  `toml:"runtime_size,omitempty"`

		// MySQL server TLS options.
		TLS struct {
			Mode     string `toml:"mode,omitempty"`
			CertPath string `toml:"cert_path,omitempty"`
			KeyPath  string `toml:"key_path,omitempty"`
		} `toml:"tls,omitempty"`
	} `toml:"postgres_options,omitempty"`

	OpenTSDBOptions struct {
		Addr        string `toml:"addr,omitempty"`
		RuntimeSize int32  `toml:"runtime_size,omitempty"`
	} `toml:"opentsdb_options,omitempty"`

	InfluxDBOptions struct {
		Enable *bool `toml:"enable,omitempty"`
	} `toml:"influxdb_options,omitempty"`

	PromStoreOptions struct {
		Enable *bool `toml:"enable,omitempty"`
	} `toml:"prom_store_options,omitempty"`

	PrometheusOptions struct {
		Addr string `toml:"addr,omitempty"`
	} `toml:"prometheus_options,omitempty"`

	MetaClientOptions struct {
		// Metasrv address list.
		MetaSrvAddrs []string `toml:"metasrv_addrs,omitempty"`

		// Operation timeout in milliseconds.
		TimeoutMillis int32 `toml:"timeout_millis,omitempty"`

		// Connect server timeout in milliseconds.
		ConnectTimeoutMillis int32 `toml:"connect_timeout_millis,omitempty"`

		// `TCP_NODELAY` option for accepted connections.
		TCPNoDelay *bool `toml:"tcp_nodelay,omitempty"`
	} `toml:"meta_client_options,omitempty"`

	Logging struct {
		Dir   string `toml:"dir,omitempty"`
		Level string `toml:"level,omitempty"`
	} `toml:"logging,omitempty"`
}

FrontendConfig is the configuration for the frontend.

func (*FrontendConfig) ConfigureByCluster

func (c *FrontendConfig) ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster) error

ConfigureByCluster configures the frontend configuration by the given cluster.

func (*FrontendConfig) Kind

Kind returns the component kind of the frontend.

type MetasrvConfig

type MetasrvConfig struct {
	// The bind address of metasrv.
	BindAddr string `toml:"bind_addr,omitempty"`

	// The communication server address for frontend and datanode to connect to metasrv.
	ServerAddr string `toml:"server_addr,omitempty"`

	// Etcd server address.
	StoreAddr string `toml:"store_addr,omitempty"`

	// Datanode lease in seconds.
	DatanodeLeaseSec int32 `toml:"datanode_lease_sec,omitempty"`

	// Datanode selector type, can be "LeaseBased" or "LoadBased".
	Selector string `toml:"selector,omitempty"`

	// Store data in memory.
	UseMemoryStore *bool `toml:"use_memory_store,omitempty"`

	// Enable region failover.
	EnableRegionFailover *bool `toml:"enable_region_failover"`

	Logging struct {
		Dir   string `toml:"dir,omitempty"`
		Level string `toml:"level,omitempty"`
	} `toml:"logging,omitempty"`
}

MetasrvConfig is the configuration for the metasrv.

func (*MetasrvConfig) ConfigureByCluster

func (c *MetasrvConfig) ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster) error

ConfigureByCluster configures the metasrv config by the given cluster.

func (*MetasrvConfig) Kind

Kind returns the component kind of the metasrv.

Jump to

Keyboard shortcuts

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