Documentation ¶
Overview ¶
Package petrel contains common code, data, and types that are shared between petrel/server and petrel/client.
Users should not import it directly.
Index ¶
- Constants
- Variables
- func ConnRead(c net.Conn, timeout time.Duration, plimit uint32, key []byte, seq *uint32) ([]byte, string, string, error)
- func ConnReadRaw(c net.Conn, timeout time.Duration) ([]byte, string, string, error)
- func ConnWrite(c net.Conn, payload, key []byte, timeout time.Duration, seq uint32) (string, error)
- func ConnWriteRaw(c net.Conn, timeout time.Duration, xmission []byte) (string, error)
- type Perr
Constants ¶
View Source
const ( Debug = iota Conn Error Fatal )
Message levels control which messages will be sent to h.Msgr
View Source
const ( // Proto is the version of the wire protocol implemented by // this library Proto = uint8(0) )
Variables ¶
View Source
var ( // Errs is the map of Perr instances. It is used by Msg // handling code throughout the Petrel packages. Errs = map[string]*Perr{ "connect": { 100, Conn, "client connected", nil}, "dispatch": { 101, Debug, "dispatching", nil}, "netreaderr": { 196, Conn, "network read error", nil}, "netwriteerr": { 197, Conn, "network write error", nil}, "disconnect": { 198, Conn, "client disconnected", nil}, "quit": { 199, Debug, "Quit called: closing listener socket", nil}, "success": { 200, Debug, "reply sent", nil}, "badreq": { 400, Debug, "bad command", []byte("PERRPERR400")}, "nilreq": { 401, Debug, "nil request", []byte("PERRPERR401")}, "plenex": { 402, Error, "payload size limit exceeded; closing conn", []byte("PERRPERR402")}, "reqerr": { 500, Error, "request failed", []byte("PERRPERR500")}, "internalerr": { 501, Error, "internal error", nil}, "badmac": { 502, Error, "HMAC verification failed; closing conn", []byte("PERRPERR502")}, "listenerfail": { 599, Fatal, "read from listener socket failed", nil}, } // Errmap lets you go the other way, from a numeric status to // the name of a Perr Errmap = map[int]string{ 100: "connect", 101: "dispatch", 196: "netreaderr", 197: "netwriteerr", 198: "disconnect", 199: "quit", 200: "success", 400: "badreq", 401: "nilreq", 402: "plenex", 403: "badmac", 500: "reqerr", 501: "internalerr", 599: "listenerfail"} // Loglvl maps string logging levels (from configurations) to // their int equivalents (actually used in code) Loglvl = map[string]int{ "debug": Debug, "conn": Conn, "error": Error, "fatal": Fatal} )
Functions ¶
func ConnRead ¶ added in v0.33.0
func ConnRead(c net.Conn, timeout time.Duration, plimit uint32, key []byte, seq *uint32) ([]byte, string, string, error)
ConnRead reads a message from a connection
func ConnReadRaw ¶ added in v0.33.0
ConnReadRaw is only used by the Client, via DispatchRaw. As such it has no payload length checking.
Types ¶
Click to show internal directories.
Click to hide internal directories.