{"id":17520773,"url":"https://github.com/9ssi7/acc","last_synced_at":"2025-04-23T16:09:51.539Z","repository":{"id":213757267,"uuid":"734854049","full_name":"9ssi7/acc","owner":"9ssi7","description":"Go library for efficient data accumulation and processing.","archived":false,"fork":false,"pushed_at":"2024-10-16T21:35:22.000Z","size":18,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T16:09:44.968Z","etag":null,"topics":["data-aggregation","data-processing","go-library","scheduled-tasks"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/9ssi7/acc","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/9ssi7.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}},"created_at":"2023-12-22T20:18:05.000Z","updated_at":"2024-10-17T08:35:21.000Z","dependencies_parsed_at":"2023-12-22T21:33:18.861Z","dependency_job_id":"c6f057e1-3a72-4149-97d8-c49595317bd1","html_url":"https://github.com/9ssi7/acc","commit_stats":null,"previous_names":["9ssi7/acc"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/9ssi7%2Facc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/9ssi7%2Facc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/9ssi7%2Facc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/9ssi7%2Facc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/9ssi7","download_url":"https://codeload.github.com/9ssi7/acc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250468270,"owners_count":21435452,"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":["data-aggregation","data-processing","go-library","scheduled-tasks"],"created_at":"2024-10-20T11:24:33.919Z","updated_at":"2025-04-23T16:09:51.525Z","avatar_url":"https://github.com/9ssi7.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Accumulator: A Go-based Data Accumulation Mechanism\n\n## Overview\n\nAccumulator is a lightweight Go library designed to aggregate, manage, and process data items. Whether you're accumulating data from various sources, processing them at specific intervals, or simply managing a stream of data, this library provides the tools you need.\n\n## Features\n\n- **Flexible Storage**: Choose from built-in storage options like in-memory storage or integrate with your custom storage mechanism.\n- **Customizable Processing**: Define how data items are processed using your custom function.\n- **Configurable Interval**: Set the interval at which accumulated data is processed.\n- **Scheduled Processing**: Optionally start processing data at a specific time.\n\n## Installation\n\nTo install the package, simply run:\n\n```bash\ngo get github.com/9ssi7/acc\n```\n\n## Documentation\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/9ssi7/acc.svg)](https://pkg.go.dev/github.com/9ssi7/acc)\n\n## Flow Diagrams\n\n### Continuous Insert with DB Index Issues\n\n```mermaid\ngraph TD;\n    Start[Start] --\u003e Insert1[Insert Data 1];\n    Insert1 --\u003e Insert2[Insert Data 2];\n    Insert2 --\u003e Insert3[Insert Data 3];\n    Insert3 --\u003e Insert4[Insert Data 4];\n    Insert4 --\u003e Insert5[Insert Data 5];\n    Insert5 --\u003e IndexBroken[Index Broken];\n```\n\n### Using Accumulator for Batch Processing\n\n```mermaid\ngraph TD;\n    Start[Start] --\u003e Accumulate[Accumulate Data];\n    Accumulate --\u003e Process[Process Data];\n    Process --\u003e Wait[Wait 15 Minutes];\n    Wait --\u003e Accumulate;\n```\n\n\n## Usage\n\n### Basic Setup\n\nHere's a basic example demonstrating how to set up an accumulator:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/9ssi7/acc\"\n)\n\nfunc main() {\n\taccumulator := acc.New(acc.Config[int]{\n\t\tProcessor: processFunction,\n\t\t// ... other configurations\n\t})\n\t// Start using the accumulator\n}\n\nfunc processFunction(ctx context.Context, data []int) {\n\t// Your logic to process data\n\tfmt.Println(\"Processing data:\", data)\n}\n```\n\n### Advanced Configurations\n\n#### Using StartTime Configuration\n\nTo start the accumulator processing at a specific time, you can use the `StartTime` configuration. Below is an example demonstrating how to set a start time:\n\n```go\nfunc main() {\n\taccumulator := acc.New(acc.Config[int]{\n\t\tProcessor: processFunction,\n\t\tStartTime: time.Date(2024, time.December, 31, 23, 59, 0, 0, time.UTC), // Processing will start on New Year's Eve at 23:59\n\t\t// ... other configurations\n\t})\n\t// Start using the accumulator\n}\n```\n\n#### Using Interval Configuration\n\nTo configure the interval at which accumulated data is processed, you can set the `Interval` configuration. Below is an example demonstrating how to set an interval:\n\n```go\nfunc main() {\n\taccumulator := acc.New(acc.Config[int]{\n\t\tProcessor: processFunction,\n\t\tInterval:  30 * time.Second, // Data will be processed every 30 seconds\n\t\t// ... other configurations\n\t})\n\t// Start using the accumulator\n}\n```\n\n### Starting the Accumulator Asynchronously\n\nTo start the accumulator asynchronously using a goroutine, you can use the following approach:\n\n```go\nfunc main() {\n    accumulator := acc.New(acc.Config[int]{\n        Processor: processFunction,\n        Interval:  30 * time.Second, // Data will be processed every 30 seconds\n        // ... other configurations\n    })\n\n    // Start the accumulator in a goroutine\n    go func() {\n        if err := accumulator.Start(context.Background()); err != nil {\n            fmt.Println(\"Error starting accumulator:\", err)\n        }\n    }()\n\n    // You can continue with other operations or wait for user input to exit\n    // For example:\n    // fmt.Println(\"Press Ctrl+C to exit...\")\n    // select {}\n}\n```\n\nBy starting the accumulator in a goroutine, it will run in the background, allowing the main program flow to continue without interruption.\n\n## Contributing\n\nWe welcome contributions! Please see our [Contribution Guidelines](CONTRIBUTING.md) for details.\n\n## License\n\nThis project is licensed under the Apache License. See [LICENSE](LICENSE) for more details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F9ssi7%2Facc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F9ssi7%2Facc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F9ssi7%2Facc/lists"}