funcregistry

package
v0.0.0-...-2841839 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 3 Imported by: 0

README

funcregistry

import "github.com/cognusion/go-jar/funcregistry"

Overview

Index

Package files

funcr.go

Variables

var (
    // DebugOut is a log.Logger for debug messages
    DebugOut = log.New(io.Discard, "", 0)
)

type FuncRegistry

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

FuncRegistry is an aggregation of func()s that should be called during an orderly shutdown/restart. Examples include context.CancelFuncs, resource closing, etc.

func NewFuncRegistry
func NewFuncRegistry(callOnce bool) *FuncRegistry

NewFuncRegistry returns an initialized Stopper

func (*FuncRegistry) Add
func (s *FuncRegistry) Add(f func())

Add will append f to the list of funcs to call, if Call() is called

func (*FuncRegistry) AddOnce
func (s *FuncRegistry) AddOnce(f func())

AddOnce will append f to the list of funcs to call, if Call() is called, but will only be called once, regardless of the number of Call()s.

func (*FuncRegistry) Call
func (s *FuncRegistry) Call()

Call will iterate over the registered functions, calling them. Call may only be called once with effect if callOnce is true, but is safe to call multiple times, regardless.

func (*FuncRegistry) Close
func (s *FuncRegistry) Close()

Close will zero out the func list, and trip the invocation breaker preventing further use


Generated by godoc2md

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DebugOut is a log.Logger for debug messages
	DebugOut = log.New(io.Discard, "", 0)
)

Functions

This section is empty.

Types

type FuncRegistry

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

FuncRegistry is an aggregation of func()s that should be called during an orderly shutdown/restart. Examples include context.CancelFuncs, resource closing, etc.

func NewFuncRegistry

func NewFuncRegistry(callOnce bool) *FuncRegistry

NewFuncRegistry returns an initialized Stopper

func (*FuncRegistry) Add

func (s *FuncRegistry) Add(f func())

Add will append f to the list of funcs to call, if Call() is called

func (*FuncRegistry) AddOnce

func (s *FuncRegistry) AddOnce(f func())

AddOnce will append f to the list of funcs to call, if Call() is called, but will only be called once, regardless of the number of Call()s.

func (*FuncRegistry) Call

func (s *FuncRegistry) Call()

Call will iterate over the registered functions, calling them. Call may only be called once with effect if callOnce is true, but is safe to call multiple times, regardless.

func (*FuncRegistry) Close

func (s *FuncRegistry) Close()

Close will zero out the func list, and trip the invocation breaker preventing further use

Jump to

Keyboard shortcuts

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