hook

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 3 Imported by: 0

README

Ssi Core / Hook

This package contains some hooks that listen for events sent by the machine.

OnClose

This hook is called when the program is closed.

type:

func NewOnClose() *OnClose
func (o *OnClose) AddHandler(h OnCloseHandler)
func (o *OnClose) Listen(signals ...os.Signal)

example:

package main

import (
    "github.com/ssibrahimbas/ssi-core/pkg/hook"
    "fmt"
    "os"
)

func main() {
    o := hook.NewOnClose()
    o.AddHandler(func(sig os.Signal) {
        fmt.Println("closing")
    })
    o.Listen(os.Interrupt)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OnClose

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

func NewOnClose

func NewOnClose() *OnClose

func (*OnClose) AddHandler

func (o *OnClose) AddHandler(h OnCloseHandler)

func (*OnClose) Listen

func (o *OnClose) Listen(signals ...os.Signal)

type OnCloseHandler

type OnCloseHandler func(sig os.Signal)

Jump to

Keyboard shortcuts

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