Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilePersister with empty directory throws file not found error #241

Open
smartpcr opened this issue Nov 7, 2021 · 1 comment
Open

FilePersister with empty directory throws file not found error #241

smartpcr opened this issue Nov 7, 2021 · 1 comment

Comments

@smartpcr
Copy link

smartpcr commented Nov 7, 2021

hub initialized with connectionString and filePersister

        ctx := context.Background()
	fp, err := persist.NewFilePersister(persistDir)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

        hub, err := eventhub.NewHubFromConnectionString(connStr, eventhub.HubWithOffsetPersistence(output))
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
	defer hub.Close(ctx)

	runtimeInfo, err := hub.GetRuntimeInformation(ctx)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
	partitionIds := runtimeInfo.PartitionIDs
	consumerGroup := os.Getenv("EVENTHUB_CONSUMERGROUP")
	if consumerGroup == "" {
		consumerGroup = "$Default"
	}

	for _, partitionId := range partitionIds {
		_, err = hub.Receive(ctx, partitionId, output.HandleEvent, eventhub.ReceiveWithConsumerGroup(consumerGroup), eventhub.ReceiveWithPrefetchCount(20000))
		if err != nil {
			fmt.Println(err.Error())
			os.Exit(1)
		}
	}

Expected Behavior

should be able to create new file instead of throwing error

Actual Behavior

when file doesn't exist, it returns NewCheckpointFromStartOfStream(), err but err is not nil, and caused receive to fail here

Environment

  • OS: windows
  • Go version: 1.17
  • Version of Library: 3.3.16
@jackjameshoward
Copy link

@smartpcr Did you find a solution to this issue?
Or how did you go about creating the file if it doesn't exist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants