config

package
v0.63.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentFracVersion = BinaryDataV1

Variables

View Source
var (
	NumCPU      int
	TotalMemory uint64
)
View Source
var (
	IndexWorkers  int
	FetchWorkers  int
	ReaderWorkers int

	CaseSensitive = false
	SkipFsync     = false

	MaxFetchSizeBytes = 4 * units.MiB

	MaxRequestedDocuments = 100_000 // maximum number of documents that can be requested in one fetch request
)

Functions

This section is empty.

Types

type BinaryDataVersion

type BinaryDataVersion uint16
const (
	// BinaryDataV0 - initial version
	BinaryDataV0 BinaryDataVersion = iota
	// BinaryDataV1 - support RIDs encoded without varint
	BinaryDataV1
	// BinaryDataV2 - MIDs stored in nanoseconds
	BinaryDataV2
)

type Bytes

type Bytes units.Base2Bytes

func (*Bytes) UnmarshalString

func (b *Bytes) UnmarshalString(s string) error

type Config

type Config struct {
	Address struct {
		// HTTP listen address.
		HTTP string `config:"http" default:":9002"`
		// GRPC listen address.
		GRPC string `config:"grpc" default:":9004"`
		// Debug listen address.
		Debug string `config:"debug" default:":9200"`
	} `config:"address"`

	Storage struct {
		// DataDir is a path to a directory where fractions will be stored.
		DataDir string `config:"data_dir"`
		// FracSize specifies the maximum size of an active fraction before it gets sealed.
		FracSize Bytes `config:"frac_size" default:"128MiB"`
		// TotalSize specifies upper bound of how much disk space can be occupied
		// by sealed fractions before they get deleted (or offloaded).
		TotalSize Bytes `config:"total_size" default:"1GiB"`
	} `config:"storage"`

	Cluster struct {
		// WriteStores contains cold store instances which will be written to.
		WriteStores []string `config:"write_stores"`
		// ReadStores contains cold store instances wich will be queried from.
		ReadStores []string `config:"read_stores"`

		// HotStores contains store instances which will be written to and queried from.
		HotStores []string `config:"hot_stores"`
		// HotReadStores contains store instances which will be queried from.
		// This field is optional but if specified will take precedence over [Proxy.Cluster.HotStores].
		HotReadStores []string `config:"hot_read_stores"`

		// Replicas specifies number of instances that belong to one shard.
		Replicas int `config:"replicas" default:"1"`
		// HotReplicas specifies number if hot instances that belong to one shard.
		// If specified will take precedence over [Replicas] for hot stores.
		HotReplicas     int  `config:"hot_replicas"`
		ShuffleReplicas bool `config:"shuffle_replicas"`

		// MirrorAddress specifies host to which search queries will be mirrored.
		// It can be useful if you have development cluster and you want to have same search pattern
		// as you have on production cluster.
		MirrorAddress string `config:"mirror_address"`
	} `config:"cluster"`

	SlowLogs struct {
		// BulkThreshold specifies duration to determine slow bulks.
		// When bulk request exceeds this threshold it will be logged.
		BulkThreshold time.Duration `config:"bulk_threshold" default:"0ms"`
		// SearchThreshold specifies duration to determine slow searches.
		// When search request exceeds this threshold it will be logged.
		SearchThreshold time.Duration `config:"search_threshold" default:"3s"`
		// FetchThreshold specifies duration to determine slow fetches.
		// When fetch request exceeds this threshold it will be logged.
		FetchThreshold time.Duration `config:"fetch_threshold" default:"3s"`
	} `config:"slow_logs"`

	Limits struct {
		// QueryRate specifies maximum amount of requests per second.
		QueryRate float64 `config:"query_rate" default:"2"`

		// SearchRequests specifies maximum amount of simultaneous requests per second.
		SearchRequests int `config:"search_requests" default:"32"`
		// BulkRequests specifies maximum amount of simultaneous requests per second.
		BulkRequests int `config:"bulk_requests" default:"32"`
		// InflightBulks specifies maximum amount of simultaneous requests per second.
		InflightBulks int `config:"inflight_bulks" default:"32"`

		// FractionHits specifies maximum amount of fractions that can be processed
		// within single search request.
		FractionHits int `config:"fraction_hits" default:"6000"`
		// SearchDocs specifies maximum amount of documents that can be returned
		// within single search request.
		SearchDocs int `config:"search_docs" default:"100000"`
		// DocSize specifies maximum possible size for single document.
		// Document larger than this threshold will be skipped.
		DocSize Bytes `config:"doc_size" default:"128KiB"`

		Aggregation struct {
			// FieldTokens specifies maximum amount of unique field tokens
			// that can be processed in single aggregation requests.
			// Setting this field to 0 disables limit.
			FieldTokens int `config:"field_tokens" default:"1000000"`
			// GroupTokens specifies maximum amount of unique group tokens
			// that can be processed in single aggregation requests.
			// Setting this field to 0 disables limit.
			GroupTokens int `config:"group_tokens" default:"2000"`
			// FractionTokens specifies maximum amount of unique tokens
			// that are contained in single fraction which was picked up by aggregation request.
			// Setting this field to 0 disables limit.
			FractionTokens int `config:"fraction_tokens" default:"100000"`
		} `config:"aggregation"`
	} `config:"limits"`

	CircuitBreaker struct {
		Bulk struct {
			// Checkout [CircuitBreaker] for more information.
			// [CircuitBreaker]: https://github.com/ozontech/seq-db/blob/main/network/circuitbreaker/README.md
			ShardTimeout time.Duration `config:"shard_timeout" default:"10s"`
			// Checkout [CircuitBreaker] for more information.
			// [CircuitBreaker]: https://github.com/ozontech/seq-db/blob/main/network/circuitbreaker/README.md
			ErrPercentage int `config:"err_percentage" default:"50"`
			// Checkout [CircuitBreaker] for more information.
			// [CircuitBreaker]: https://github.com/ozontech/seq-db/blob/main/network/circuitbreaker/README.md
			BucketWidth time.Duration `config:"bucket_width" default:"1s"`
			// Checkout [CircuitBreaker] for more information.
			// [CircuitBreaker]: https://github.com/ozontech/seq-db/blob/main/network/circuitbreaker/README.md
			BucketsCount int `config:"buckets_count" default:"10"`
			// Checkout [CircuitBreaker] for more information.
			// [CircuitBreaker]: https://github.com/ozontech/seq-db/blob/main/network/circuitbreaker/README.md
			SleepWindow time.Duration `config:"sleep_window" default:"5s"`
			// Checkout [CircuitBreaker] for more information.
			// [CircuitBreaker]: https://github.com/ozontech/seq-db/blob/main/network/circuitbreaker/README.md
			VolumeThreshold int `config:"volume_threshold" default:"5"`
		} `config:"bulk"`
	} `config:"circuit_breaker"`

	Resources struct {
		// ReaderWorkers specifies number of workers for readers pool.
		// By default this setting is equal to [runtime.GOMAXPROCS].
		ReaderWorkers int `config:"reader_workers"`
		// SearchWorkers specifies number of workers for searchers pool.
		// By default this setting is equal to [runtime.GOMAXPROCS].
		SearchWorkers int `config:"search_workers"`
		// ReplayWorkers specifies number of workers.
		// By default this setting is equal to 2.
		ReplayWorkers int `config:"replay_workers" default:"2"`
		// CacheSize specifies maxium size of cache.
		// By default this setting is equal to 30% of available RAM.
		CacheSize         Bytes `config:"cache_size"`
		SortDocsCacheSize Bytes `config:"sort_docs_cache_size"`
		SkipFsync         bool  `config:"skip_fsync"`
	} `config:"resources"`

	Compression struct {
		DocsZstdCompressionLevel     int `config:"docs_zstd_compression_level" default:"1"`
		MetasZstdCompressionLevel    int `config:"metas_zstd_compression_level" default:"1"`
		SealedZstdCompressionLevel   int `config:"sealed_zstd_compression_level" default:"3"`
		DocBlockZstdCompressionLevel int `config:"doc_block_zstd_compression_level" default:"3"`
	} `config:"compression"`

	Indexing struct {
		MaxTokenSize         int  `config:"max_token_size" default:"72"`
		CaseSensitive        bool `config:"case_sensitive"`
		PartialFieldIndexing bool `config:"partial_field_indexing"`
		// PastAllowedTimeDrift specifies how much time can elapse since the message’s timestamp.
		// If more time than PastAllowedTimeDrift has passed since the message’s timestamp, the message's timestamp gets overwritten.
		PastAllowedTimeDrift time.Duration `config:"past_allowed_time_drift" default:"24h"`
		// FutureAllowedTimeDrift specifies the maximum allowable offset for a message’s timestamp into the future.
		// If a message’s timestamp is further in the future than FutureAllowedTimeDrift, it is overwritten.
		FutureAllowedTimeDrift time.Duration `config:"future_allowed_time_drift" default:"5m"`
	} `config:"indexing"`

	Mapping struct {
		// Path to mapping file or 'auto' to index all fields as keywords.
		Path string `config:"path"`
		// EnableUpdates will periodically check mapping file and reload configuration if there is an update.
		EnableUpdates bool `config:"enable_updates"`
		// UpdatePeriod manages how often mapping file will be checked for updates.
		UpdatePeriod time.Duration `config:"update_period" default:"30s"`
	} `config:"mapping"`

	DocsSorting struct {
		// Enabled enables/disables documents sorting.
		Enabled bool `config:"enabled"`
		// DocBlockSize sets document block size.
		// Large size consumes more RAM but improves compression ratio.
		DocBlockSize Bytes `config:"doc_block_size" default:"128KiB"`
	} `config:"docs_sorting"`

	Offloading struct {
		Enabled bool `config:"enabled"`
		// Retention sets TTL for [frac.Remote] fractions.
		// By default no retention is configured and all [frac.Remote] fractions are kept forever.
		Retention time.Duration `config:"retention"`

		// Endpoint configures S3 endpoint for S3 client.
		Endpoint string `config:"endpoint" default:"https://s3.us-east-1.amazonaws.com/"`
		// Bucket configures the name of S3 bucket where [frac.Remote] fractions will be stored.
		Bucket string `config:"bucket"`
		Region string `config:"region" default:"us-east-1"`

		// AccessKey configures S3 Access Key for S3 client.
		// You can learn more about access keys [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).
		AccessKey string `config:"access_key"`
		// SecretKey configures S3 Secret Key for S3 client.
		// You can learn more about secret keys [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html).
		SecretKey string `config:"secret_key"`
		// RetryCount sets [RetryMaxAttempts] for S3 client which is applied for all API calls.
		// Be aware that fraction is suicided when offloading attempts exceeds [RetryCount].
		RetryCount int `config:"retry_count" default:"5"`
	} `config:"offloading"`

	AsyncSearch struct {
		// DataDir specifies directory that contains data for asynchronous searches.
		// By default will be subdirectory in [Config.Storage.DataDir].
		DataDir                string `config:"data_dir"`
		Concurrency            int    `config:"concurrency"`
		MaxTotalSize           Bytes  `config:"max_total_size" default:"1GiB"`
		MaxSizePerRequest      Bytes  `config:"max_size_per_request" default:"100MiB"`
		MaxDocumentsPerRequest int64  `config:"max_documents_per_request" default:"100000"`
	} `config:"async_search"`

	API struct {
		// EsVersion is the default version that will be returned in the `/` handler.
		ESVersion string `config:"es_version" default:"8.9.0"`
	} `config:"api"`

	Tracing struct {
		SamplingRate float64 `config:"sampling_rate" default:"0.01"`
	} `config:"tracing"`

	// Additional filtering options
	Filtering struct {
		// If a search query time range overlaps with the [from; to] range
		// the search query will be `AND`-ed with an additional predicate with the provided query expression
		Query string    `config:"query"`
		From  time.Time `config:"from"`
		To    time.Time `config:"to"`
	} `config:"filtering"`
}

func Parse

func Parse(path string) (Config, error)

func (*Config) Validate added in v0.61.2

func (c *Config) Validate(mode string) error

type StoreProtocolVersion added in v0.63.0

type StoreProtocolVersion int
const (
	// StoreProtocolVersion1 MID is in milliseconds
	StoreProtocolVersion1 StoreProtocolVersion = 1
	// StoreProtocolVersion2 MID is in nanoseconds
	StoreProtocolVersion2 StoreProtocolVersion = 2
)

func ParseStoreProtocolVersion added in v0.63.0

func ParseStoreProtocolVersion(s string) StoreProtocolVersion

ParseStoreProtocolVersion parses a protocol version string and returns the corresponding StoreProtocolVersion.

func (StoreProtocolVersion) String added in v0.63.0

func (p StoreProtocolVersion) String() string

Jump to

Keyboard shortcuts

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