graniticio / granitic

Web/micro-services and IoC framework for Golang developers
https://granitic.io/
Apache License 2.0
35 stars 12 forks source link

Allow same rdbms.Client to be reused for whole request #20

Open benhalstead opened 5 years ago

benhalstead commented 5 years ago

Currently validators that check a database will use a different instance of rdbms.Client as application code. This means that validation cannot occur within the same transaction as queries to insert/update data, potentially meaning that data could have changed between validation and insert.

Ensuring that the same instance of rdbms.Client is re-used throughout a request is a specific instance of a more common pattern of 'request scoped resources'.

This issue is:

  1. Identify and implement a common pattern for request scoped resources
  2. Add specific support for request scoped rdbms.Client objects