cmd

package
v7.0.0-...-d41eddb Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyConfig1 = errutil.NewFactory("empty config %q")
)

errors

View Source
var Module = &cobrather.Module{
	Use:   "gogstash",
	Short: "Logstash like, written in golang",
	Commands: []*cobrather.Module{
		cobrather.VersionModule,
	},
	Flags: []cobrather.Flag{
		flagDebug,
		flagInput,
		flagInputBasicAuthUsername,
		flagInputBasicAuthPassword,
		flagOutput,
		flagOutputBasicAuthUsername,
		flagOutputBasicAuthPassword,
		flagScroll,
		flagBulkActions,
		flagBulkSize,
		flagBulkFlushInterval,
		flagDelete,
		flagCompress,
		flagMaxRows,
	},
	RunE: func(ctx context.Context, cmd *cobra.Command, args []string) error {
		inputElasticURL := flagInput.String()
		if inputElasticURL == "" {
			return ErrEmptyConfig1.New(nil, flagInput.Name)
		}
		outputElasticURL := flagOutput.String()
		if outputElasticURL == "" {
			return ErrEmptyConfig1.New(nil, flagOutput.Name)
		}

		scroll := int(flagScroll.Int64())
		bulkActions := int(flagBulkActions.Int64())
		if bulkActions < 1 {
			bulkActions = scroll
		}

		return esdump.ElasticDump(esdump.Options{
			Debug:              flagDebug.Bool(),
			InputElasticURL:    inputElasticURL,
			InputBasicAuth:     esdump.AuthOptions{BasicUsername: flagInputBasicAuthUsername.String(), BasicPassword: flagInputBasicAuthPassword.String()},
			InputElasticSniff:  false,
			OutputElasticURL:   outputElasticURL,
			OutputBasicAuth:    esdump.AuthOptions{BasicUsername: flagOutputBasicAuthUsername.String(), BasicPassword: flagOutputBasicAuthPassword.String()},
			OutputElasticSniff: false,
			ScrollSize:         scroll,
			BulkActions:        bulkActions,
			BulkSize:           int(flagBulkSize.Int64()) << 20,
			BulkFlushInterval:  time.Duration(flagBulkFlushInterval.Int64()) * time.Second,
			Delete:             flagDelete.Bool(),
			Compress:           flagCompress.Bool(),
			MaxRows:            flagMaxRows.Int64(),
		})
	},
}

Module info

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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