Documentation ¶
Index ¶
Constants ¶
View Source
const ( StrategyFieldName = "buffer.strategy" MemoryBufferStrategy = "memory" FileBufferStrategy = "file" CombinationBufferStrategy = "combination" StrategyDefault = CombinationBufferStrategy )
Variables ¶
View Source
var Component = &app.Component{ Constructor: func(container container.Container) error { return container.Provides( file.NewConfig, memory.NewConfig, NewConfig, NewWithConfigurator, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config, fileConfig *file.Config, memoryConfig *memory.Config) { flagSet.StringVar(&config.Strategy, StrategyFieldName, StrategyDefault, fmt.Sprintf( "storage strategy. Available strategies: "+ "%s - saves data only in the application's memory; "+ "%s - saves data only to a file; "+ "%s - saves data in the application's memory, when the memory is full, saves the data to a file.", MemoryBufferStrategy, FileBufferStrategy, CombinationBufferStrategy, )) flagSet.StringVar(&fileConfig.Directory, file.DirectoryFieldName, file.DirectoryDefault, "directory for storing data files") flagSet.StringVar(&fileConfig.NamePattern, file.NamePatternFieldName, file.NamePatternDefault, fmt.Sprintf( "file naming pattern to rotate them. Available preset values: : [%s]", strings.Join([]string{ namer.YearPattern, namer.MonthPattern, namer.DayPattern, namer.HourPattern, namer.MinutePattern, namer.SecondPattern, namer.UnixTimePattern, namer.UnixTimeNanoPattern, }, ","), )) flagSet.StringVar(&fileConfig.RotationStrategy, file.RotationStrategyFieldName, file.RotationStrategyDefault, fmt.Sprintf( "file rotation strategy. Available strategies: "+ "%s - file rotation once a day; "+ "%s - file rotation once per hour; "+ "%s - rotates the file when it reaches a certain size.", file.DayRotationStrategy, file.HourRotationStrategy, file.SizeRotationStrategy, )) flagSet.StringVar(&fileConfig.RotationSizeHumanReadable, file.RotationSizeHumanReadableFieldName, file.RotationSizeHumanReadableDefault, fmt.Sprintf( "file size to rotate if rotation strategy is selected - %s", file.SizeRotationStrategy, )) flagSet.StringVar(&fileConfig.Compressor, file.CompressorFieldName, file.CompressorDefault, fmt.Sprintf( "data compression algorithm. Available algorithms: "+ "%s - no compression; "+ "%s - the algorithm is selected automatically, for unix-like systems tar.gz is selected, for windows - zip; "+ "%s - compression of the finished file chunk using the tar and gz algorithms; "+ "%s - compression of the finished file chunk by the zip algorithm; "+ "%s - data compression before writing to file, algorithm lz4.", file.CompressorNone, file.CompressorTrue, file.CompressorTarGZ, file.CompressorZIP, file.CompressorLZ4, )) flagSet.BoolVar( &fileConfig.AutoDelete, file.AutoDeleteFieldName, file.AutoDeleteDefault, "if true, adds a middleware that removes a file fragment after it has been read completely", ) flagSet.StringVar(&memoryConfig.Compressor, memory.CompressorFieldName, memory.CompressorDefault, fmt.Sprintf( "an algorithm for compressing data stored in the application's memory. Available algorithms: "+ "%s - no compression; "+ "%s - data compression by lz4 algorithm.", memory.CompressorNone, memory.CompressorLZ4, )) }) }, Serve: func(c container.Container) error { buffer, err := container.Get[Buffer](c) if err != nil { return err } closer, err := container.Get[closer.Closer](c) if err != nil { return err } ctx, cancelFunc := context.WithCancel(closer.GetContext()) defer cancelFunc() <-ctx.Done() return buffer.Close() }, }
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer io.ReadWriteCloser
func NewBuffer ¶
func NewBuffer(config *Config, memory io.ReadWriteCloser, file io.ReadWriteCloser, memoryStater memory.Stater, informer logger.Informer) Buffer
func NewWithConfigurator ¶
func NewWithConfigurator( config *Config, configurator configurator.Configurator, container container.Container, ) (Buffer, error)
type Config ¶
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator) *Config
Click to show internal directories.
Click to hide internal directories.