Documentation ¶
Index ¶
Constants ¶
View Source
const ( Debug = iota Conn Error Fatal )
Message levels control which messages will be sent to h.Msgr
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.34.0
type Config struct { // Sockname is the location/IP+port of the socket. For Unix // sockets, it takes the form "/path/to/socket". For TCP, it is an // IPv4 or IPv6 address followed by the desired port number // ("127.0.0.1:9090", "[::1]:9090"). Sockname string // Timeout is the number of milliseconds the Server will wait // when performing network ops before timing out. Default // (zero) is no timeout. Each connection to the server is // handled in a separate goroutine, however, so one blocked // connection does not affect any others (unless you run out of // file descriptors for new conns). Timeout int64 // Reqlen is the maximum number of bytes in a single read from // the network. If a request exceeds this limit, the // connection will be dropped. Use this to prevent memory // exhaustion by arbitrarily long network reads. The default // (0) is unlimited. Reqlen uint32 // Buffer sets how many instances of Msg may be queued in // Server.Msgr. Non-Fatal Msgs which arrive while the buffer // is full are dropped on the floor to prevent the Server from // blocking. Defaults to 32. Buffer int // Msglvl determines which messages will be sent to the // Server's message channel. Valid values: debug, conn, error, // fatal. Msglvl string // LogIP determines if the IP of clients is logged on // connect. Enabling IP logging creates a bit of overhead on // each connect. If this isn't needed, or if the client can be // identified at the application layer, leaving this off will // somewhat improve performance in high-usage scenarios. LogIP bool //HMACKey is the secret key used to generate MACs for signing //and verifying messages. Default (nil) means MACs will not be //generated for messages sent, or expected for messages //received. Enabling message authentication adds significant //overhead for each message sent and received, so use this //when security outweighs performance. HMACKey []byte }
Config holds values to be passed to server constuctors.
type Msg ¶
type Msg struct { // Conn is the connection ID that the Msg is coming from. Conn uint32 // Req is the request number that resulted in the Msg. Req uint32 // Code is the numeric status indicator. Code int // Txt is the content/description. Txt string // Err is the error (if any) passed upward as part of the Msg. Err error }
Msg is the format which Petrel uses to communicate informational messages and errors to its host program via the s.Msgr channel.
type Responder ¶
Responder is the type which functions passed to Server.Register must match: taking a slice of bytes as an argument and returning a slice of bytes and an error.
type Server ¶
type Server struct { // Msgr is the channel which receives notifications from // connections. Msgr chan *Msg // Sig is p.Sigchan, made available so apps can waatch it Sig chan os.Signal // contains filtered or unexported fields }
Server is a Petrel server instance.
func UnixServer ¶
UnixServer returns a Server which uses Unix domain sockets. Argument `p` is the Unix permissions to set on the socket (e.g. 770)
Click to show internal directories.
Click to hide internal directories.