{"id":17960989,"url":"https://github.com/slok/reload","last_synced_at":"2025-03-25T03:31:27.432Z","repository":{"id":38334162,"uuid":"338760443","full_name":"slok/reload","owner":"slok","description":"Simple managed reload mechanism for Go","archived":false,"fork":false,"pushed_at":"2024-09-15T09:42:16.000Z","size":61,"stargazers_count":45,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-19T08:39:16.521Z","etag":null,"topics":["autoreload","configuration","go","golang","golang-library","lib","library","reload","reloader"],"latest_commit_sha":null,"homepage":"","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/slok.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-14T08:28:19.000Z","updated_at":"2024-12-05T19:36:07.000Z","dependencies_parsed_at":"2024-06-19T00:17:41.684Z","dependency_job_id":"9409bedf-b815-4ccb-ac12-257397e550be","html_url":"https://github.com/slok/reload","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Freload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Freload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Freload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slok%2Freload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slok","download_url":"https://codeload.github.com/slok/reload/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245394737,"owners_count":20608122,"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":["autoreload","configuration","go","golang","golang-library","lib","library","reload","reloader"],"created_at":"2024-10-29T11:07:56.881Z","updated_at":"2025-03-25T03:31:27.410Z","avatar_url":"https://github.com/slok.png","language":"Go","readme":"# reload\n\n[![GoDoc](https://godoc.org/github.com/slok/reload?status.svg)](https://godoc.org/github.com/slok/reload)\n[![CI](https://github.com/slok/reload/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/slok/reload/actions/workflows/ci.yaml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/slok/reload)](https://goreportcard.com/report/github.com/slok/reload)\n[![Apache 2 licensed](https://img.shields.io/badge/license-Apache2-blue.svg)](https://raw.githubusercontent.com/slok/reload/master/LICENSE)\n\n`reload` is a universal mechanism to reload components in a Go application. Inspired by [oklog/run] and its simplicity, `reload` is a small Go library that has a simple API where `Notifiers` will trigger the reload process on the `Reloaders`.\n\nThe mechanism is based on a reload manager that can have multiple notifiers. These notifiers will be executed and the manager will wait until one of those ends the execution. At that moment it will start the reload process. On the other hand, the reload manager can have multiple reloaders, that will be triggered when the reload process starts. This process will be running in this manner forever until the reload manager execution is stopped by an error or ending the context passed on run.\n\nWhen adding the reloaders to the manager, they are added with a priority integer, these reloaders will be grouped in batches of the same priority. When the reload process is started, the manager will execute each reloaders batch sequentially and in priority order (the reloaders inside the batch will be executed concurrently).\n\nThe manager as a security mechanism, is smart enough to ignore a reload trigger if there is already a reloading process being executed in that same moment.\n\n## Status\n\nIs in alpha stage, being tested.\n\n## Getting started\n\n```golang\nfunc main() {\n    // Setup reloaders.\n    reloadSvc := reload.NewManager()\n\n    reloadSvc.Add(0, reload.ReloaderFunc(func(ctx context.Context, id string) error {\n        fmt.Printf(\"reloader 1: %s\\n\", id)\n        return nil\n    }))\n\n    reloadSvc.Add(100, reload.ReloaderFunc(func(ctx context.Context, id string) error {\n        fmt.Printf(\"reloader 2: %s\\n\", id)\n        return nil\n    }))\n\n\n    // Setup notifiers.\n    {\n        t := time.NewTicker(5 * time.Second)\n        defer t.Stop()\n        reloadSvc.On(reload.NotifierFunc(func(ctx context.Context) (string, error) {\n            select {\n            case \u003c-ctx.Done():\n                return \"\", nil // End execution.\n            case tickerT := \u003c-t.C:\n                return tickerT.String(), nil\n            }\n        }))\n    }\n\n    err := reloadSvc.Run(context.Background())\n    if err != nil {\n        log.Panic(err.Error())\n    }\n}\n```\n\n## Examples\n\nCheck [examples](_examples/).\n\n[oklog/run]: https://github.com/oklog/run\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslok%2Freload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslok%2Freload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslok%2Freload/lists"}