inotify

package module
v0.0.0-...-29fa70d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2019 License: BSD-3-Clause Imports: 3 Imported by: 0

README

INotify

Go based Django-like signal utilities.

codecov

Usage

import (
    "fmt"

    "github.com/junzki/inotify"
)

func sigHandle(s inotify.ISignal, _ ...interface{}) {
    fmt.Printf("%s called.", s.Name())
}

func main() {
    sig := inotify.NewSignal("some-signal", sigHandle)
    sig.Send()  // Calls each handler function.
    
    // Console output: "some-signal called."
}

Documentation

Index

Constants

View Source
const (
	// SignalExitSuccess returns when handler function has exited successfully.
	SignalExitSuccess = 0

	// SignalExitFailure returns when handler function raises a panic.
	SignalExitFailure = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ISignal

type ISignal interface {
	Name() string
	Send(args ...interface{})
	SendAsync(wait chan int, args ...interface{})
	Connect(handler SignalHandler)
}

ISignal is the abstract Signal "class".

type Signal

type Signal struct {
	// contains filtered or unexported fields
}

Signal struct holds its receivers.

func NewSignal

func NewSignal(name string, handlers ...SignalHandler) *Signal

NewSignal initializes one new signal instance.

func (*Signal) Connect

func (s *Signal) Connect(handler SignalHandler)

Connect appends one signal handler.

func (*Signal) Name

func (s *Signal) Name() string

Name returns the signal name.

func (*Signal) Send

func (s *Signal) Send(args ...interface{})

Send calls each handler one-by-one.

func (*Signal) SendAsync

func (s *Signal) SendAsync(wait chan int, args ...interface{})

SendAsync calls handlers asynchonosly.

type SignalHandler

type SignalHandler func(ISignal, ...interface{})

SignalHandler type is the abstract handler function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL