{"id":25842758,"url":"https://github.com/nir3x/multisender","last_synced_at":"2025-10-07T21:01:50.453Z","repository":{"id":220109151,"uuid":"750765116","full_name":"NIR3X/multisender","owner":"NIR3X","description":"MultiSender - Go Module for Simultaneous Writing to Multiple io.Writer Instances","archived":false,"fork":false,"pushed_at":"2024-02-16T04:13:50.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T15:47:55.240Z","etag":null,"topics":["concurrency","file-cache","file-watcher","go","golang","io-writer","multisender","parallel-writing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NIR3X.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":"2024-01-31T09:22:05.000Z","updated_at":"2024-01-31T09:58:59.000Z","dependencies_parsed_at":"2024-06-21T14:25:16.344Z","dependency_job_id":"b0dca7fb-069e-42e7-aaa8-4ce401ab8eee","html_url":"https://github.com/NIR3X/multisender","commit_stats":null,"previous_names":["nir3x/multisender"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fmultisender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fmultisender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fmultisender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NIR3X%2Fmultisender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NIR3X","download_url":"https://codeload.github.com/NIR3X/multisender/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241329448,"owners_count":19944982,"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":["concurrency","file-cache","file-watcher","go","golang","io-writer","multisender","parallel-writing"],"created_at":"2025-03-01T06:31:36.358Z","updated_at":"2025-10-07T21:01:45.408Z","avatar_url":"https://github.com/NIR3X.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MultiSender - Go Module for Simultaneous Writing to Multiple io.Writer Instances\n\n**MultiSender** is a Go module that enables simultaneous writing to multiple `io.Writer` instances. It provides a `MultiSenderWriter` type and a `MultiSender` type to facilitate efficient and parallelized writing.\n\n## Installation\n\nTo use this module in your Go project, you can run:\n\n```bash\ngo get github.com/NIR3X/multisender\n```\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"io\"\n\t\"net/http\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/NIR3X/filecache\"\n\t\"github.com/NIR3X/filewatcher\"\n\t\"github.com/NIR3X/logger\"\n)\n\nconst (\n\tfileCacheMaxSize          = 2 * 1024 * 1024\n\tfileWatcherUpdateInterval = 1 * time.Second\n\trootDir                   = \"www\"\n)\n\nfunc main() {\n\tfileCache := filecache.NewFileCache(fileCacheMaxSize)\n\tmultiSender := NewMultiSender(fileCache)\n\tfileWatcher := filewatcher.NewFileWatcher(fileWatcherUpdateInterval, func(path string, isDir bool) { // created\n\t\tif isDir {\n\t\t\treturn\n\t\t}\n\t\terr := fileCache.Update(path)\n\t\tif err != nil {\n\t\t\tlogger.Eprintln(err)\n\t\t}\n\t}, func(path string, isDir bool) { // removed\n\t\tif isDir {\n\t\t\treturn\n\t\t}\n\t\tfileCache.Delete(path)\n\t}, func(path string, isDir bool) { // modified\n\t\tif isDir {\n\t\t\treturn\n\t\t}\n\t\terr := fileCache.Update(path)\n\t\tif err != nil {\n\t\t\tlogger.Eprintln(err)\n\t\t}\n\t})\n\tdefer fileWatcher.Close()\n\terr := fileWatcher.Watch(rootDir)\n\tif err != nil {\n\t\tlogger.Eprintln(err)\n\t\treturn\n\t}\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tpath := r.URL.Path\n\t\tif path == \"/\" {\n\t\t\tpath = \"/index.html\"\n\t\t}\n\t\tpath = filepath.Join(rootDir, path)\n\t\treader, ident := fileCache.GetCached(path)\n\t\tswitch ident {\n\t\tcase filecache.Cached:\n\t\t\t_, err = io.Copy(w, reader)\n\t\t\tif err != nil {\n\t\t\t\tlogger.Eprintln(err)\n\t\t\t}\n\t\tcase filecache.Piped:\n\t\t\tmultiSenderWriter := multiSender.Add(path, w)\n\t\t\tmultiSenderWriter.Wait()\n\t\t}\n\t})\n\tlogger.Println(\"Listening on port 8000...\")\n\terr = http.ListenAndServe(\":8000\", nil)\n\tif err != nil {\n\t\tlogger.Eprintln(err)\n\t\treturn\n\t}\n}\n```\n\n## License\n\n[![GNU AGPLv3 Image](https://www.gnu.org/graphics/agplv3-155x51.png)](https://www.gnu.org/licenses/agpl-3.0.html)\n\nThis program is Free Software: You can use, study share and improve it at your\nwill. Specifically you can redistribute and/or modify it under the terms of the\n[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html) as\npublished by the Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnir3x%2Fmultisender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnir3x%2Fmultisender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnir3x%2Fmultisender/lists"}