Documentation
¶
Index ¶
Constants ¶
const ( LvlEMERG int = iota // Not to be used by applications. LvlALERT LvlCRIT LvlERROR LvlWARN LvlNOTICE LvlINFO LvlDEBUG )
Syslog priority levels
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Descripter ¶
type Descripter interface {
Description() string
}
Descripter - A Server implementing the Descriptor interface will use that description in any logging
type Listener ¶
type Listener interface {
Listen() error
}
Listener - Servers implementing the Listener interface will be called upon to Listen() before being asked to Serve()
type LoggerFunc ¶
A LoggerFunc can be set to make the library log to a custom log library
type MultiServer ¶
type MultiServer struct {
// contains filtered or unexported fields
}
MultiServer manages a slice of servers implementing the Serve interface (and possibly Listener/Waiter) The servers are started by calling Serve() and stopped by calling Shutdown().
func (*MultiServer) Log ¶
func (m *MultiServer) Log(level int, msg string)
Log is used by a MultiServer to log internal actions if a LoggerFunc is set. You can call this your self if you need to. It's go-routine safe if the provided Log function is.
func (*MultiServer) Serve ¶
func (m *MultiServer) Serve(servers []Server, readyCallback func() error) (done chan struct{}, err error)
Serve starts the supplied "servers" and waits until signaled to stopped via Shutdown() call. Once the servers are successfully started the callback will be called. Serve will exit as soon as all servers have recognized the Shutdown(). Servers can acknowledge Shutdown() without having fully exited if they implement the Wait() method. The done channel will be closed when all servers have exited and any implementors of Wait() has been waited on.
func (*MultiServer) SetLogger ¶
func (m *MultiServer) SetLogger(f LoggerFunc)
SetLogger sets a custom log function.
func (*MultiServer) Shutdown ¶
func (m *MultiServer) Shutdown()
Shutdown send an async signal to the server to exit Serve() by calling Shutdown in the individual servers
type Server ¶
type Server interface { Serve() error // start serving and block until exit Shutdown() // async req. to shutdown, must not block }
Server is an server started by the master MultiServer, by calling Serve() which is expected to block until the server is signaled to stop by an invocation of Shutdown()
Calling Shutdown() should start the shutdown process and return immediately, causing Serve() to exit. If the server implements Wait() its Serve() method can exit asynchronously before shutdown is fully completed. The master server will call Wait() before any restart of the server.
If Serve() returns no error, the master server regards the server as fully finished and ready to (maybe) be restarted by another invocation of the master MultiServer Serve() method.
type Waiter ¶
type Waiter interface {
Wait()
}
Waiter - implmented on Servers if they expect the caller of Serve() to Wait() for complete shutdown. Servers are allowed to exit Serve() before being fully shutdown immediately after Shutdown() by implementing Wait() to allow the master MultiServer to wait for full shutdown. Servers not implementing Wait() are expected to be fully shutdown and restartable once Serve() exists with a non-nil error. Calling Wait() on a not running and fully shut down server should be a NOOP.