Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flare 🚀

A simple, lightweight signaling mechanism in Go.

Go Report Card GoDoc


Introduction

Flare provides an alternative to the standard context package in Go for signaling goroutines, without carrying cancellation info or other values. It's a minimalistic tool designed to provide a straightforward mechanism to signal goroutines to stop their work.

Installation

go get github.com/twiny/flare

Usage

Basic Usage

package main

import (
 "github.com/twiny/flare"
)

func main() {
 n := flare.NewNotifier()

 // Spawn a goroutine
 go func() {
  select {
  case <-n.Hold():
   return
  default:
   // Do some work
  }
 }()

 // Signal the goroutine to stop
 n.Signal()
}

Integration with context.Context

func main() {
 n, cancel := flare.NewNotifierWithCancel(context.Background())
 // Canceling the context will also signal the flare Notifier.
 defer cancel()

 // Spawn a goroutine
 go func() {
  select {
  case <-n.Hold():
   return
  default:
   // Do some work
  }
 }()

 // Signal the goroutine to stop
 n.Signal()
}

Wiki

More documentation can be found in the wiki.

Bugs

Bugs or suggestions? Please visit the issue tracker.

About

A lightweight signaling mechanism for Go.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages