We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi! Please provide en complex example about using treansactional in services. Existing example in readme is very abstract... ( Thanks!
The text was updated successfully, but these errors were encountered:
Is this correct?
func main() { // ... // connect to the database db, err := dbx.MustOpen("mysql", cfg.DSN) if err != nil { fmt.Println(err) os.Exit(-1) } dbc := dbcontext.New(db) txnFn := dbc.Transactional repo := pkg1.NewRepo(dbc) service := pkg1.NewService(repo, txnFN) } }
service package
type service struct { repo Repository txnFn dbcontext.TransactionFunc } ... func(s service) SomeServiceMethod(ctx context.Context) error { err := serviceMethod(ctx, s.repo, s.txnFn) if err != nil { return err } } func serviceMethod(ctx context.Context, repo Repository, transactional dbcontext.TransactionFunc) error { return transactional(ctx, func(ctx context.Context) error { repo.method1(...) repo.method2(...) return nil }) }
Sorry, something went wrong.
No branches or pull requests
Hi! Please provide en complex example about using treansactional in services.
Existing example in readme is very abstract... (
Thanks!
The text was updated successfully, but these errors were encountered: