service

package
v0.0.0-...-d58b641 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2014 License: BSD-2-Clause, BSD-2-Clause Imports: 10 Imported by: 0

README

service

Basic service component management for go applications.

Documentation

Index

Constants

View Source
const (
	ChannelBufferSize = 5000
)

Variables

View Source
var (
	// DefaultWatchInterval is the default interval for which we will record
	// values in the Watch functions.
	DefaultWatchInterval = time.Minute * 1
)
View Source
var (
	Messages chan<- Message
)

Functions

func Count

func Count() uint

Count returns the number of services.

func GetSettingValue

func GetSettingValue(na, de string, se url.Values) (out string, def bool)

GetSettingValue will get the value from the given settings. If the setting is not defined the function will return the given default value.

func ParseBool

func ParseBool(na, de string, se url.Values) (out bool, def bool, err error)

ParseBool will parse the boolean for the given settings name. When the setting is not defined we will use the given default.

func ParseDuration

func ParseDuration(na, de string, se url.Values) (out time.Duration, def bool, err error)

ParseDuration will parse the duration for the given settings name. When the setting is not defined we will use the given default.

func ParseFileMode

func ParseFileMode(na, de string, se url.Values) (out os.FileMode, def bool, err error)

ParseFileMode will parse the os.FileMode for the given settings name. When the setting is not defined we will use the given default.

func ParseInt

func ParseInt(na, de string, se url.Values) (out int, def bool, err error)

ParseInt will parse the uint in base 10 for the given settings name. When the setting is not defined we will use the given default.

func ParseSettings

func ParseSettings(ur *url.URL) (set url.Values, err error)

func ParseUint

func ParseUint(na, de string, se url.Values) (out uint, def bool, err error)

ParseUint will parse the uint in base 10 for the given settings name. When the setting is not defined we will use the given default.

func RecordFloat

func RecordFloat(name string, value float64)

RecordFloat will take a metricname and a float value and record it to syslog.

func RecordInt

func RecordInt(name string, value int)

RecordInt will take a metricname and a int value and record it to syslog.

func RecordUint

func RecordUint(name string, value uint)

RecordUint will take a metricname and a uint value and record it to syslog.

func Start

func Start(name string, service Service) (<-chan Message, error)

Start will start a given service and return the message channel. This function can be run multible times and will always return the same message channel.

func WatchFloat

func WatchFloat(name string, value func() float64)

WatchFloat will take a function that returns a float value and record the output of that function every DefaultWatchInterval.

func WatchInt

func WatchInt(name string, value func() int)

WatchInt will take a function that returns a int value and record the output of that function every DefaultWatchInterval.

func WatchRuntimeMemory

func WatchRuntimeMemory(name string)

WatchRuntimeMemory will record the runtime memory stats every DefaultWatchInterval.

func WatchSignals

func WatchSignals()

WatchSignals waits for unix signals and handles them appropiatly. SIGINT/SIGTERM: Stop services and return. SIGHUP: Reload services. SIGQUIT: Dump core and return.

func WatchUint

func WatchUint(name string, value func() uint)

WatchUint will take a function that returns a uint value and record the output of that function every DefaultWatchInterval.

Types

type Message

type Message interface {
	Type() MessageType
	Source() string
}

type MessageError

type MessageError struct {
	Error error
	// contains filtered or unexported fields
}

func (MessageError) Source

func (me MessageError) Source() string

func (MessageError) Type

func (me MessageError) Type() MessageType

type MessageType

type MessageType uint8
const (
	MessageTypeError MessageType = iota
)

type Service

type Service interface {
	Start(chan<- Message) error
	Stop()
	Reload()
}

Jump to

Keyboard shortcuts

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