service

package
v0.0.0-...-ae3587a Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: LGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseOnSignal

func CloseOnSignal(s Service)

CloseOnSignal calls the closeFunc on the os signals SIGINT and SIGTERM

Types

type Executor

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

Executor handles gracefully closing execution for services Closing an executor goes through the states running, stopping, stopped and closed.

func New

func New() *Executor

New returns an Executor ready for use.

func (*Executor) IsRunning

func (e *Executor) IsRunning() bool

IsRunning should be used to determine if the execution should be halted. Will be false until Close() is called

func (*Executor) MarkAsClosed

func (e *Executor) MarkAsClosed()

MarkAsClosed is to be called when the service using the executor is closed. The process can be stopped or killed now

func (*Executor) MarkAsStopped

func (e *Executor) MarkAsStopped()

MarkAsStopped is to be called when the execution was stopped. All used resources can be cracefully closed and dispossed of now

func (*Executor) Stop

func (e *Executor) Stop()

Stop is to be called when the executor should stop This is only safe to call once

func (*Executor) WaitUntilClosed

func (e *Executor) WaitUntilClosed()

WaitUntilClosed waits until the Close func call of the executor is finished

func (*Executor) WaitUntilStopped

func (e *Executor) WaitUntilStopped(timeout time.Duration)

WaitUntilStopped blocks until either MarkAsStopped() was called in any goroutine or the timeout has passed

type Service

type Service interface {
	Close()
}

Service is a closeable service that usually includes an Executor

Jump to

Keyboard shortcuts

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