sentinel

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: MIT Imports: 9 Imported by: 2

README

About

sentinel provides a server group sentinel.

Documentation

Overview

Package sentinel provides a sentinel run group manager.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreError

func IgnoreError(err error) func(error) bool

IgnoreError returns a func that returns true when passed errors match.

func IgnoreNetOpError

func IgnoreNetOpError(err error) bool

IgnoreNetOpError returns true when the passed error is a net.OpError with error "use of closed network connection".

func IgnoreServerClosed

func IgnoreServerClosed(err error) bool

IgnoreServerClosed returns true when the passed error is the http.ErrServerClosed error.

Types

type Error added in v1.0.0

type Error string

Error is an error.

const (
	// ErrAlreadyStarted is the already started error.
	ErrAlreadyStarted Error = "already started"

	// ErrUnknownType is the unknown type error
	ErrUnknownType Error = "unknown type"
)

func (Error) Error added in v1.0.0

func (err Error) Error() string

Error satisfies the error interface.

type Logger added in v1.0.0

type Logger interface{}

Logger is a logger interface.

Allowed types:

func(string, ...interface{}) func(string, ...interface{}) error func(string)

interface {
  Printf(string, ...interface{})
}

type Manager added in v1.0.0

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

Manager is a sentinel run manager holding the specific start and shutdown funcs for a sentinel.

func NewManager added in v1.0.0

func NewManager(start, shutdown interface{}, ignore ...func(error) bool) (Manager, error)

NewManager creates a sentinel run manager for the provided start and shutdown funcs.

type Sentinel

type Sentinel struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Sentinel is a sentinel run group manager.

func WithContext added in v1.0.1

func WithContext(ctx context.Context, sigs ...os.Signal) (*Sentinel, context.Context)

WithContext creates a new sentinel run group manager.

func (*Sentinel) Manage added in v1.0.0

func (s *Sentinel) Manage(start, shutdown interface{}, ignore ...func(error) bool) error

Manage creates and registers a manager to the sentinel for the provided start and shutdown funcs, adding any error ignores funcs to the run group.

func (*Sentinel) ManageHTTP added in v1.0.0

func (s *Sentinel) ManageHTTP(listener net.Listener, handler http.Handler, opts ...func(*http.Server) error) error

ManageHTTP creates and registers a manager for a HTTP server for the specified listener and handler, and registers the created HTTP server, its shutdown, and related ignore funcs (IgnoreServerClosed, IgnoreNetOpError) with the server sentinel group.

func (*Sentinel) Run

func (s *Sentinel) Run(logger Logger, timeout time.Duration) error

Run runs the sentinel run group using the logger, and kill timeout.

Jump to

Keyboard shortcuts

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