func initializeApplicationVariables()

in src/go/cmd/edasim/jobsubmitter/main.go [49:120]


func initializeApplicationVariables(ctx context.Context) (*azure.EventHubSender, *edasim.JobSubmitter) {
	var enableDebugging = flag.Bool("enableDebugging", false, "enable debug logging")
	var uniqueName = flag.String("uniqueName", "", "the unique name to avoid queue collisions")
	var mountPathsCSV = flag.String("mountPathsCSV", "", "one mount paths separated by commas")
	var threadCount = flag.Int("threadCount", edasim.DefaultJobSubmitterThreadCount, "the number of concurrent users submitting jobs")

	flag.Parse()

	if *enableDebugging {
		log.EnableDebugging()
	}

	if envVarsAvailable := verifyEnvVars(); !envVarsAvailable {
		usage()
		os.Exit(1)
	}

	storageAccount := cli.GetEnv(azure.AZURE_STORAGE_ACCOUNT)
	storageKey := cli.GetEnv(azure.AZURE_STORAGE_ACCOUNT_KEY)
	eventHubSenderName := cli.GetEnv(azure.AZURE_EVENTHUB_SENDERKEYNAME)
	eventHubSenderKey := cli.GetEnv(azure.AZURE_EVENTHUB_SENDERKEY)
	eventHubNamespaceName := cli.GetEnv(azure.AZURE_EVENTHUB_NAMESPACENAME)

	if len(*uniqueName) == 0 {
		fmt.Fprintf(os.Stderr, "ERROR: uniqueName is not specified\n")
		usage()
		os.Exit(1)
	}

	if len(*mountPathsCSV) == 0 {
		fmt.Fprintf(os.Stderr, "ERROR: mountPathsCSV is not specified\n")
		usage()
		os.Exit(1)
	}

	mountPaths := strings.Split(*mountPathsCSV, ",")

	for _, path := range mountPaths {
		if _, err := os.Stat(path); os.IsNotExist(err) {
			fmt.Fprintf(os.Stderr, "ERROR: mountPath '%s' does not exist\n", path)
			usage()
			os.Exit(1)
		} else if err != nil {
			fmt.Fprintf(os.Stderr, "ERROR: error encountered with path '%s': %v\n", path, err)
			usage()
			os.Exit(1)
		}
	}

	azure.FatalValidateQueueName(*uniqueName)

	if *threadCount < 0 {
		fmt.Fprintf(os.Stderr, "ERROR: there must be at least 1 thread to submit jobs")
		usage()
		os.Exit(1)
	}

	eventHub := edasim.InitializeReaderWriters(
		ctx,
		eventHubSenderName,
		eventHubSenderKey,
		eventHubNamespaceName,
		edasim.GetEventHubName(*uniqueName))

	return eventHub, edasim.InitializeJobSubmitter(
		ctx,
		storageAccount,
		storageKey,
		*uniqueName,
		mountPaths,
		*threadCount)
}