Documentation ¶
Overview ¶
Diamond package provides runlevels to an application
API is considered unstable until further notice
Index ¶
- Variables
- type Client
- type Options
- type RunlevelFunc
- type System
- func (s *System) AddListener(ltype, laddr string) (n int, err error)
- func (s *System) GetListener(n int) net.Listener
- func (s *System) GetRunlevel() int
- func (s *System) NListeners() int
- func (s *System) Runlevel(level int) (err error)
- func (s *System) SetHandler(h http.Handler) error
- func (s *System) SetRunlevel(level int, fn RunlevelFunc)
- func (s *System) Wait() int
Constants ¶
This section is empty.
Variables ¶
var CHMODDIR os.FileMode = 0750
CHMODDIR by default is user read/write/searchable, group read/writable
var CHMODFILE os.FileMode = 0770
CHMODFILE (control socket) by default is user/group read/write/exectuable
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ServerName string // gets filled in with rpc, optional. Name string // optional, can be sent to identify the admin // contains filtered or unexported fields }
Client connects to a diamond.Server via unix socket
func NewClient ¶
NewClient returns an initialized Client, returning an error only if the socket can not be resolved It is possible that the socket does not exist yet
type Options ¶
type Options struct { // More verbose output Verbose bool // Able to be KICKed via control socket (same as command 'runlevel 0') Kickable bool // Force runlevel mode, regardless of errors Force bool }
Options modify how the diamond system functions
type RunlevelFunc ¶
type RunlevelFunc func() error
RunlevelFunc is any function with no arguments that returns an error It can be a method, such as `func (f foo) runlevel9000() error {}`
type System ¶
type System struct { // Config can be configured Config *Options // Log can be redirected Log *log.Logger Server *http.Server // contains filtered or unexported fields }
System listens on control socket, controlling listeners and runlevels
func (*System) AddListener ¶
AddListener to the list of listeners, returning the
func (*System) GetListener ¶
Get a listener by index
func (*System) GetRunlevel ¶
func (*System) NListeners ¶
func (*System) Runlevel ¶
Runlevel switches gears, into the specified level. func main() typically should os.Exit(0) some time after s.Wait()
func (*System) SetHandler ¶
SetHandler for all future connections via http socket or tcp listeners This is only useful for web applications and can be safely ignored
func (*System) SetRunlevel ¶
func (s *System) SetRunlevel(level int, fn RunlevelFunc)