{"id":20138453,"url":"https://github.com/thiagobarradas/periodic-batching","last_synced_at":"2025-04-09T18:08:48.447Z","repository":{"id":94891778,"uuid":"335819723","full_name":"ThiagoBarradas/periodic-batching","owner":"ThiagoBarradas","description":"Library with generic periodic batching for dotnet applications.","archived":false,"fork":false,"pushed_at":"2021-02-14T20:57:20.000Z","size":27,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T08:46:16.233Z","etag":null,"topics":["batch","batch-job","batch-processing","batch-script","batching","dotnet","dotnet-core","dotnet-framework","dotnet-standard","dotnet5","dotnetcore3","periodic-batching"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/PeriodicBatching","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/ThiagoBarradas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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":"2021-02-04T02:50:45.000Z","updated_at":"2024-01-11T09:10:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"ffddfa6c-2f19-40f8-92bb-da6309b5a6c5","html_url":"https://github.com/ThiagoBarradas/periodic-batching","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fperiodic-batching","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fperiodic-batching/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fperiodic-batching/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThiagoBarradas%2Fperiodic-batching/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThiagoBarradas","download_url":"https://codeload.github.com/ThiagoBarradas/periodic-batching/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085133,"owners_count":21045135,"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","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":["batch","batch-job","batch-processing","batch-script","batching","dotnet","dotnet-core","dotnet-framework","dotnet-standard","dotnet5","dotnetcore3","periodic-batching"],"created_at":"2024-11-13T21:38:14.901Z","updated_at":"2025-04-09T18:08:48.441Z","avatar_url":"https://github.com/ThiagoBarradas.png","language":"C#","readme":"[![Build Status](https://barradas.visualstudio.com/Contributions/_apis/build/status/NugetPackage/Periodic%20Batching?branchName=develop)](https://barradas.visualstudio.com/Contributions/_build/latest?definitionId=26\u0026branchName=develop)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ThiagoBarradas_periodic-batching\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=ThiagoBarradas_periodic-batching)\n\u003c!-- [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ThiagoBarradas_periodic-batching\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=ThiagoBarradas_periodic-batching) --\u003e\n[![NuGet Downloads](https://img.shields.io/nuget/dt/PeriodicBatching.svg)](https://www.nuget.org/packages/PeriodicBatching/)\n[![NuGet Version](https://img.shields.io/nuget/v/PeriodicBatching.svg)](https://www.nuget.org/packages/PeriodicBatching/)\n\n# Periodic Batching\n\nExecute a batching function with a controlled size every some specified time interval. Very useful for background processes to send events to some broker or something like it.\n\n# Sample\n\n```c#\n\n// some class \npublic class MyEvent\n{\n    public string SomeProperty { get; set; }\n}\n\n// method that will be called every X seconds/minutes/etc\npublic static async Task ExecuteMethod(List\u003cMyEvent\u003e events)\n{\n    // do something\n}\n\n// configuring periodic batching\nvar config = new PeriodicBatchingConfiguration\u003cMyEvent\u003e\n{\n    BatchSizeLimit = 5,                               // list size for when BatchingFunc method is called. default 50.\n    FailuresBeforeDroppingBatch = 3,                  // after X consecutive failures, current batch will be dropped. Use -1 to cancel this behavior. default 5.\n    FailuresBeforeDroppingQueue = 10,                 // after X consecutive failures, all queue items will be dropped. Use -1 to cancel this behavior. deafult 10.\n    BatchingFunc = ExecuteMethod,                     // (required) delegate called to process batch\n    SingleFailureCallback = SingleFailure,            // (optional) delegate called when a single failure happens - exception, failures count and queue count are passed as parameter.\n    DropBatchCallback = DropBatch,                    // (optional) delegate called when a batch is dropped - current batch items are passed as parameter.\n    DropQueueCallback = DropQueue,                    // (optional) delegate called when a queue is dropped - all queue items are passed as parameter.\n    Period = TimeSpan.FromSeconds(5),                 // interval to execute main method - BatchingFunc. default 10s.\n    MinimumBackoffPeriod = TimeSpan.FromSeconds(3),   // interval used for next inteval when a failure happens. for each error, interval is increased exponentially based on this value. default 3s.\n    MaximumBackoffInterval = TimeSpan.FromMinutes(5), // max interval. this parameter will limit the exponential interval. default 5m.\n};\n\nIPeriodicBatching\u003cMyEvent\u003e periodicBatching = new PeriodicBatching\u003cMyEvent\u003e(config);\n\n// or \n\nIPeriodicBatching\u003cMyEvent\u003e periodicBatchingOtherWay = new PeriodicBatching\u003cMyEvent\u003e();\nperiodicBatchingOtherWay.Setup(config);\n\n// sample of other delegates\n\npublic static async Task SingleFailure(Exception e, int failures, int queueCount))\n{\n    // do something\n}\n\npublic static async Task DropBatch(List\u003cSomeEvent\u003e events)\n{\n    // do something\n}\n\npublic static async Task DropQueue(List\u003cSomeEvent\u003e events)\n{\n    // do something\n}\n\n```\n\n## Install via NuGet\n\n```\nPM\u003e Install-Package PeriodicBatching\n```\n\n## How can I contribute?\n\nPlease, refer to [CONTRIBUTING](.github/CONTRIBUTING.md)\n\n## Found something strange or need a new feature?\n\nOpen a new Issue following our issue template [ISSUE_TEMPLATE](.github/ISSUE_TEMPLATE.md)\n\n## Did you like it? Please, make a donate :)\n\nif you liked this project, please make a contribution and help to keep this and other initiatives, send me some Satochis.\n\nBTC Wallet: `1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX`\n\n![1G535x1rYdMo9CNdTGK3eG6XJddBHdaqfX](https://i.imgur.com/mN7ueoE.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagobarradas%2Fperiodic-batching","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagobarradas%2Fperiodic-batching","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagobarradas%2Fperiodic-batching/lists"}