{"id":17882402,"url":"https://github.com/ealsur/concurrentdocdb","last_synced_at":"2025-08-01T13:34:52.903Z","repository":{"id":110731684,"uuid":"85322030","full_name":"ealsur/concurrentdocdb","owner":"ealsur","description":"Azure DocumentDB concurrenty-aware extensions","archived":false,"fork":false,"pushed_at":"2017-03-27T12:39:28.000Z","size":25,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-21T12:51:10.833Z","etag":null,"topics":["azure","azure-documentdb","concurrency","documentdb"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ealsur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-17T14:42:09.000Z","updated_at":"2023-08-29T11:01:51.000Z","dependencies_parsed_at":"2023-03-22T13:47:09.827Z","dependency_job_id":null,"html_url":"https://github.com/ealsur/concurrentdocdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ealsur/concurrentdocdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ealsur%2Fconcurrentdocdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ealsur%2Fconcurrentdocdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ealsur%2Fconcurrentdocdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ealsur%2Fconcurrentdocdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ealsur","download_url":"https://codeload.github.com/ealsur/concurrentdocdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ealsur%2Fconcurrentdocdb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268185473,"owners_count":24209385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","azure-documentdb","concurrency","documentdb"],"created_at":"2024-10-28T12:54:41.744Z","updated_at":"2025-08-01T13:34:52.887Z","avatar_url":"https://github.com/ealsur.png","language":"C#","readme":"# Azure DocumentDB concurrency-aware extensions\n\n## Introduction\n\nDocumentDB provides [Optimistic Concurrency Control support](https://docs.microsoft.com/azure/documentdb/documentdb-faq) with the [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) attribute and the [AccessCondition](https://msdn.microsoft.com/library/en-us/Dn799196.aspx) options.\n\nHandling these scenarios is not a cookie-cutter problem, it requires a number of moving parts and try/catch cases to nail it.\n\nTaking a snippet of the [official sample repo](https://github.com/Azure/azure-documentdb-dotnet/blob/master/samples/code-samples/DocumentManagement/Program.cs#L397):\n\n    try\n    {\n    \tvar ac = new AccessCondition { Condition = readDoc.ETag, Type = AccessConditionType.IfMatch };\n    \treadDoc.SetPropertyValue(\"foo\", \"the updated value of foo\");\n    \tupdatedDoc = await client.ReplaceDocumentAsync(readDoc, new RequestOptions { AccessCondition = ac });\n    }\n    catch (DocumentClientException dce)\n    {\n    \t//   now notice the failure when attempting the update \n    \t//   this is because the ETag on the server no longer matches the ETag of doc (b/c it was changed in step 2)\n    \tif (dce.StatusCode == HttpStatusCode.PreconditionFailed)\n    \t{\n\t\t    Console.WriteLine(\"As expected, we have a pre-condition failure exception\\n\");\n\t    }\n    }\n\nThese extensions are an attempt to make it less error-prone and easier to implement.\n\nWith the included extensions, the former example changes to:\n\n    updateDoc = await client.ReplaceConcurrentDocumentAsync(readDoc).OnConcurrencyException((exception)=\u003e\n    {\n    \t//The original exception is in exception.InnerException\n    \tConsole.WriteLine($\"As expected, we have a pre-condition failure exception: {exception.Message}\");\n    });\n \n The key factors are the [ReplaceConcurrentDocumentAsync](https://github.com/ealsur/concurrentdocdb/blob/master/src/DocumentDb.Concurrency/DocumentClientExtensions.cs) extension and the [OnConcurrencyException](https://github.com/ealsur/concurrentdocdb/blob/master/src/DocumentDb.Concurrency/ConcurrencyExceptionTaskExtension.cs) extension that gives you the opportunity to define a handler that will only execute on a Concurrency error.\n \n These extensions help reduce moving parts and visually aid in understanding the program flow.\n \n ## Get it\n\nYou can obtain these extensions as a [Nuget Package](https://www.nuget.org/packages/DocumentDB.Concurrency). \n\n    Install-Package DocumentDB.Concurrency\n\nOr reference it and use it according to the [License](./LICENSE).\n \n ## Issues\n\nPlease feel free to [report any issues](https://github.com/ealsur/concurrentdocdb/issues) you might encounter. I am always looking for feedback!\n\n## Supported Frameworks\n\n* .Net 4.5 Full Framework\n* [.Net Standard Library](https://docs.microsoft.com/en-us/dotnet/articles/standard/library) 1.6\n\n \n  \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fealsur%2Fconcurrentdocdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fealsur%2Fconcurrentdocdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fealsur%2Fconcurrentdocdb/lists"}