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

Transactional support when updating multiple files #3029

Open
Alansyf opened this issue Dec 13, 2023 · 1 comment
Open

Transactional support when updating multiple files #3029

Alansyf opened this issue Dec 13, 2023 · 1 comment

Comments

@Alansyf
Copy link

Alansyf commented Dec 13, 2023

Hi
I understand the github api typically operates on individual requests.
But in most my case here in my application, I must make sure two files (even more) are updated in a transactional way, like in database.
Either both success or both failed.

I can implement something like revertFirstCommit to handle one by one, but this is too much efforts.
Wondering if can from lib natively provide similar as we have in database commit/rollback.

err := dao.WithTransaction(dao.GetDB(), func(tx dao.Transaction) error {
		//
		for _, c := range tableColumnsList {
			err := dao.UpdateTableColumn(ctx, tx, c)
			if err != nil {
				zap.L().Sugar().Error(err)
				return err
			}
		}
		err := dao.UpdateTable(ctx, tx, tableDto)
		if err != nil {
			zap.L().Sugar().Error(err)
			return err
		}
@gmlewis
Copy link
Collaborator

gmlewis commented Dec 13, 2023

This is the perfect opportunity for you to create a helper repo that is completely independent of this one, and once you get it working well, you can create a PR that points to it from our README.md just like we have done for the ghinstallation repo.

We decided long back that this repo will be dedicated to the core functionality of making the GitHub v3 API easy to use from the Go programming language, and that all other helpers should go in external repos. This is done for a number of reasons, and if you are inclined, you can search for the discussions we had years ago on this topic.

We'll leave this issue open for a while in case there is more discussion or in case you would like to use this issue to refer to from your PR where you update this repo's README.md.

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