diff --git a/README.md b/README.md index 8fc4224..d820da6 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,11 @@ Normally a web application is using following pattern to modify data in the data 1. **Load resource** from database. **Resource** is some portion of data such as set of records from relational database, document from Document-oriented database or value from KV store (in Domain-Driven Design terms it is called an [aggregate](https://martinfowler.com/bliki/DDD_Aggregate.html)). -Lock the entire resource pessimistically or optimistically (by reading version number). +Lock the entire resource [optimistically](https://www.martinfowler.com/eaaCatalog/optimisticOfflineLock.html) +by reading version number. 2. **Apply change** to data in plain Go -3. **Save resource** to database. Release the pessimistic lock. Or run -atomic update with version check (optimistic lock). +3. **Save resource** to database. Release the lock by running +atomic update with version check. But such architecture does not scale well if the number of requests for a single resource is very high @@ -68,7 +69,7 @@ err := processor.Run(ctx, resourceKey, func(r *YourResource) { }) ``` -For real-life example see [example web application](https://github.com/elgopher/batch-example). +**For real-life example see [example web application](https://github.com/elgopher/batch-example).** ## Installation diff --git a/go.mod b/go.mod index 4a3085f..04e445f 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,10 @@ module github.com/elgopher/batch go 1.18 +require github.com/stretchr/testify v1.7.0 + require ( github.com/davecgh/go-spew v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/objx v0.1.0 // indirect - github.com/stretchr/testify v1.7.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/go.sum b/go.sum index 7b4dc41..acb88a4 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=