filmov
tv
Transactions in context values in Golang, is it OK? r/golang
Показать описание
Welcome to the inaugural video about r/golang! Here, I discuss exciting, challenging, relevant, or anything interesting on that subreddit by providing a deep-dive discussion.
This video covers a post that asks:
"Is it an anti-pattern to pass the sql transaction as ctx values through the lifecycle of the request? I am trying to implement a transaction that uses different repositories."
The blunt answer is "Yes", it is an anti-pattern but that does not solve the hypothetical problem, what is, if any, an idiomatic way to reuse repositories and still use transactions?
In this video I cover a way to enable reusability to support repositories with transactions.
== Relevant links
== All Go/Golang Playlists
== Socials
00:00 - Start
00:14 - Is it an anti pattern in golang to use transactions in context values?
00:35 - Repositories, transactions and context
00:57 - What is the repository pattern? What is context? What are transactions?
02:44 - Demo start (Part 1)
03:04 - Transaction Script using a transaction function
03:23 - User repository implementation
03:40 - Role repository implementation
04:25 - UserRole repository implementation
05:17 - Commands using repositories
07:05 - End of Part 1!
07:44 - Queries pattern to reuse logic executing SQL statements
08:15 - Create UserQueries used by User repository
09:09 - Create RoleQueries used by Role repository
10:59 - Create UserRoleQueries used by UserRole repository
11:19 - Summary of steps needed for reusing repositories with transactions
11:53 - Implement UserCloner type to reuse repositories with transactions
14:18 - Demo of UserCloner with command
15:16 - Conclusion
=== Who am I?
Hello 👋🏼! My name is Mario, and I am a Hands-on Software Architect and Lead Backend Engineer with decades of professional experience building all kinds of software, such as on-premise Automation Systems, Linux Accessibility Desktop Applications, Cloud Governance and Compliance Systems, and Distributed Cloud-based Advertising Systems.
The content I produce includes what I've learned while working for small startups and large companies and the processes I've followed for successfully delivering complex enterprise systems from start to end.
Subscribe if you like Software Development, Software Architecture, and Systems Design and of course, Go!
Keep it up. Don't give up!
#golang #transactions #databases
=== Follow us along on Instagram for our family adventures
=== Our affiliate links below
DISCLAIMER: Some of the links shared in the description are affiliate links. As a member of these affiliate programs, I earn a small commission from your purchases at no additional cost. I appreciate your support! 💖
This video covers a post that asks:
"Is it an anti-pattern to pass the sql transaction as ctx values through the lifecycle of the request? I am trying to implement a transaction that uses different repositories."
The blunt answer is "Yes", it is an anti-pattern but that does not solve the hypothetical problem, what is, if any, an idiomatic way to reuse repositories and still use transactions?
In this video I cover a way to enable reusability to support repositories with transactions.
== Relevant links
== All Go/Golang Playlists
== Socials
00:00 - Start
00:14 - Is it an anti pattern in golang to use transactions in context values?
00:35 - Repositories, transactions and context
00:57 - What is the repository pattern? What is context? What are transactions?
02:44 - Demo start (Part 1)
03:04 - Transaction Script using a transaction function
03:23 - User repository implementation
03:40 - Role repository implementation
04:25 - UserRole repository implementation
05:17 - Commands using repositories
07:05 - End of Part 1!
07:44 - Queries pattern to reuse logic executing SQL statements
08:15 - Create UserQueries used by User repository
09:09 - Create RoleQueries used by Role repository
10:59 - Create UserRoleQueries used by UserRole repository
11:19 - Summary of steps needed for reusing repositories with transactions
11:53 - Implement UserCloner type to reuse repositories with transactions
14:18 - Demo of UserCloner with command
15:16 - Conclusion
=== Who am I?
Hello 👋🏼! My name is Mario, and I am a Hands-on Software Architect and Lead Backend Engineer with decades of professional experience building all kinds of software, such as on-premise Automation Systems, Linux Accessibility Desktop Applications, Cloud Governance and Compliance Systems, and Distributed Cloud-based Advertising Systems.
The content I produce includes what I've learned while working for small startups and large companies and the processes I've followed for successfully delivering complex enterprise systems from start to end.
Subscribe if you like Software Development, Software Architecture, and Systems Design and of course, Go!
Keep it up. Don't give up!
#golang #transactions #databases
=== Follow us along on Instagram for our family adventures
=== Our affiliate links below
DISCLAIMER: Some of the links shared in the description are affiliate links. As a member of these affiliate programs, I earn a small commission from your purchases at no additional cost. I appreciate your support! 💖
Комментарии