Documentation ¶
Overview ¶
Package server provides server for Policy Information Point.
Index ¶
- Variables
- type ConnErrHandler
- type Option
- func WithAddress(addr string) Option
- func WithBufferSize(n int) Option
- func WithConnErrHandler(f ConnErrHandler) Option
- func WithHandler(f ServiceHandler) Option
- func WithMaxConnections(n int) Option
- func WithMaxMessageSize(n int) Option
- func WithNetwork(net string) Option
- func WithWorkers(n int) Option
- func WithWriteInterval(d time.Duration) Option
- type Server
- type ServiceHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBound indicates that server has been already bound to a port or file. ErrBound = errors.New("server has been already bound to a port or file") // ErrNotBound indicates that server hasn't been bound yet. ErrNotBound = errors.New("server hasn't been bound yet") // ErrStarted indicates that server has been already started. ErrStarted = errors.New("server has been already started") // ErrNotStarted indicates that server hasn't been started yet. ErrNotStarted = errors.New("server hasn't been started yet") )
var ErrMsgOverflow = errors.New("message buffer overflow")
ErrMsgOverflow indicates that message is too big for message buffer.
Functions ¶
This section is empty.
Types ¶
type ConnErrHandler ¶
ConnErrHandler is a function to process errors within a connection.
type Option ¶
type Option func(*options)
Option configures how we set up PIP server.
func WithAddress ¶
WithAddress returns an Option which sets service endpoint.
func WithBufferSize ¶
WithBufferSize returns an Option which sets size of input and output buffers. By default or if n <= 0 it is 1 MB.
func WithConnErrHandler ¶
func WithConnErrHandler(f ConnErrHandler) Option
WithConnErrHandler returns an Option which sets error handler for communication errors within a connection.
func WithHandler ¶
func WithHandler(f ServiceHandler) Option
WithHandler returns an Option which sets handler for service requests. The handler must write response and return the same buffer it got. It must not change buffer capacity.
func WithMaxConnections ¶
WithMaxConnections returns an Option which limits number of simultaneous connections. If n <= 0 server doesn't limit incoming connections.
func WithMaxMessageSize ¶
WithMaxMessageSize returns an Option which sets limit on message size. Default 10 KB.
func WithNetwork ¶
WithNetwork returns an Option which sets service network. It supports "tcp", "tcp4", "tcp6" and "unix" netwroks.
func WithWorkers ¶
WithWorkers returns an Option which sets a number of workers per connection.
func WithWriteInterval ¶
WithWriteInterval returns an Option which sets duration after which data from write buffer are sent to network even if write buffer isn't full.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server structure represents PIP server.
type ServiceHandler ¶
ServiceHandler is a prototye for service handler function. The handler must write response and return the same buffer it got. It must not change buffer capacity.