All Projects → slok → reload

slok / reload

Licence: Apache-2.0 license
Simple managed reload mechanism for Go

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to reload

nginx-conf
Nginx configuration
Stars: ✭ 18 (+0%)
Mutual labels:  configuration
cmd-runner
Execute commands on remote hosts asynchronously over ssh
Stars: ✭ 24 (+33.33%)
Mutual labels:  configuration
1config
A command line tool and a library to manage application secrets and configuration safely and effectively.
Stars: ✭ 24 (+33.33%)
Mutual labels:  configuration
Project
Infrastructure
Stars: ✭ 43 (+138.89%)
Mutual labels:  configuration
zcolors
🌈 Z Colors uses your $LS_COLORS to generate a coherent theme for Git and your Zsh prompt, command line and completions.
Stars: ✭ 38 (+111.11%)
Mutual labels:  configuration
emacs.d
Emacs configuration files
Stars: ✭ 15 (-16.67%)
Mutual labels:  configuration
network tech
Cisco config syntax and snippets for Sublime Text
Stars: ✭ 82 (+355.56%)
Mutual labels:  configuration
tomland
🏝 Bidirectional TOML serialization
Stars: ✭ 103 (+472.22%)
Mutual labels:  configuration
pyhaproxy
Python library to parse haproxy configurations
Stars: ✭ 50 (+177.78%)
Mutual labels:  configuration
jetrockets-standard
Standard RuboCop configuration for JetRockets with cookies
Stars: ✭ 14 (-22.22%)
Mutual labels:  configuration
onion
Layer based configuration for golang
Stars: ✭ 104 (+477.78%)
Mutual labels:  configuration
tomlj
A Java parser for Tom's Obvious, Minimal Language (TOML).
Stars: ✭ 72 (+300%)
Mutual labels:  configuration
node-nightwatch-accessibility
Nightwatch.js utility assertion for accessibility testing with aXe
Stars: ✭ 16 (-11.11%)
Mutual labels:  lib
case-classy
configuration with less hassle
Stars: ✭ 68 (+277.78%)
Mutual labels:  configuration
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+377.78%)
Mutual labels:  configuration
config
Config component, strictly typed
Stars: ✭ 14 (-22.22%)
Mutual labels:  configuration
node-api-problem
HTTP Problem Utility
Stars: ✭ 24 (+33.33%)
Mutual labels:  lib
wormhole
A minimalistic Ansible-like tool for configuring remote servers via ssh
Stars: ✭ 22 (+22.22%)
Mutual labels:  configuration
react-initial-bootstrap
an "almost complete" template for your new projects
Stars: ✭ 24 (+33.33%)
Mutual labels:  configuration
arelo
a simple auto reload (live reload) utility
Stars: ✭ 54 (+200%)
Mutual labels:  reload

reload

GoDoc CI Go Report Card Apache 2 licensed

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.

The 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.

When 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).

The 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.

Status

Is in alpha stage, being tested.

Getting started

func main() {
    // Setup reloaders.
    reloadSvc := reload.NewManager()

    reloadSvc.Add(0, reload.ReloaderFunc(func(ctx context.Context, id string) error {
        fmt.Printf("reloader 1: %s\n", id)
        return nil
    }))

    reloadSvc.Add(100, reload.ReloaderFunc(func(ctx context.Context, id string) error {
        fmt.Printf("reloader 2: %s\n", id)
        return nil
    }))


    // Setup notifiers.
    {
        t := time.NewTicker(5 * time.Second)
        defer t.Stop()
        reloadSvc.On(reload.NotifierFunc(func(ctx context.Context) (string, error) {
            select {
            case <-ctx.Done():
                return "", nil // End execution.
            case tickerT := <-t.C:
                return tickerT.String(), nil
            }
        }))
    }

    err := reloadSvc.Run(context.Background())
    if err != nil {
        log.Panic(err.Error())
    }
}

Examples

Check examples.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].