func main()

in cmd/tabulator/main.go [104:175]


func main() {
	opt := gatherOptions()
	if err := opt.validate(); err != nil {
		logrus.Fatalf("Invalid flags: %v", err)
	}
	if !opt.confirm {
		logrus.Warning("--confirm=false (DRY-RUN): will not write to gcs")
	}
	switch {
	case opt.trace:
		logrus.SetLevel(logrus.TraceLevel)
	case opt.debug:
		logrus.SetLevel(logrus.DebugLevel)
	}

	if opt.jsonLogs {
		logrus.SetFormatter(&logrus.JSONFormatter{})
	}
	logrus.SetReportCaller(true)

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	storageClient, err := gcs.ClientWithCreds(ctx, opt.creds)
	if err != nil {
		logrus.WithError(err).Fatal("Failed to create storage client")
	}
	defer storageClient.Close()

	client := gcs.NewClient(storageClient)

	logrus.WithFields(logrus.Fields{
		"read":  opt.readConcurrency,
		"write": opt.writeConcurrency,
	}).Info("Configured concurrency")

	fixers := make([]tabulator.Fixer, 0, 2)

	fixer, err := gcsFixer(ctx, opt.pubsub, opt.config, opt.gridPathPrefix, opt.creds)
	if err != nil {
		logrus.WithError(err).WithField("subscription", opt.pubsub).Fatal("Failed to configure pubsub")
	}
	if fixer != nil {
		fixers = append(fixers, fixer)
	}
	if path := opt.persistQueue; path.String() != "" {
		const freq = time.Minute
		ticker := time.NewTicker(freq)
		log := logrus.WithField("frequency", freq)
		fixers = append(fixers, tabulator.FixPersistent(log, client, path, ticker.C))
	}

	mets := tabulator.CreateMetrics(prometheus.NewFactory())

	opts := &tabulator.UpdateOptions{
		ConfigPath:          opt.config,
		ReadConcurrency:     opt.readConcurrency,
		WriteConcurrency:    opt.writeConcurrency,
		GridPathPrefix:      opt.gridPathPrefix,
		TabsPathPrefix:      opt.tabStatePathPrefix,
		AllowedGroups:       opt.groups.Strings(),
		Confirm:             opt.confirm,
		CalculateStats:      opt.calculateStats,
		UseTabAlertSettings: opt.useTabAlertSettings,
		ExtendState:         opt.extendState,
		Freq:                opt.wait,
	}

	if err := tabulator.Update(ctx, client, mets, opts, fixers...); err != nil {
		logrus.WithError(err).Error("Could not tabulate")
	}
}