func()

in internal/kusto/file.go [39:79]


func (f FileIngestOptions) Run(cli cli.Provider) error {
	cli.Logger().Debug(
		"file ingestion settings",
		"source", f.SourceFile,
		"format", f.Format,
		"mappings", f.MappingsFile,
		"target.endpoint", f.KustoTarget.Endpoint,
		"target.database", f.KustoTarget.Database,
		"target.table", f.KustoTarget.Table,
		"auth.tenant", f.Auth.TenantID,
		"auth.clientID", f.Auth.ClientID,
	)

	fileOptions, err := f.FileOptions()
	if err != nil {
		return err
	}

	ingestor, err := f.ingestorBuildSettings.createIngestor(f.KustoTarget, f.Auth)
	if err != nil {
		return fmt.Errorf("create Kusto ingestor: %w", err)
	}
	defer func() { _ = ingestor.Close() }()

	ctx, cancel := cli.Context()
	defer cancel()

	cli.Logger().Info("file ingestion started")
	start := time.Now()
	_, err = ingestor.FromFile(
		ctx,
		f.SourceFile,
		fileOptions...,
	)
	if err != nil {
		return fmt.Errorf("ingest from file %q: %w", f.SourceFile, err)
	}
	cli.Logger().Info("file ingestion completed", "duration", time.Since(start))

	return nil
}