Documentation ¶
Index ¶
- Variables
- func IntToBytes(i int) ([]byte, error)
- func ParseArray(buf []byte) ([]interface{}, int, error)
- func ParseInt(buf []byte) (int, int, error)
- func ParseMap(buf []byte) (map[string]interface{}, int, error)
- func ParseString(buf []byte) (string, int, error)
- func ParseTinyInt(b byte) (int, error)
- func ParseTinyString(buf []byte) (string, int, error)
- func StringToBytes(s string) ([]byte, error)
- func TinyMapToBytes(tinymap map[string]interface{}) ([]byte, error)
- func ValidateHandshake(client, server []byte) ([]byte, error)
- func ValidateMagic(magic []byte) (bool, error)
- type BoltConn
- type DirectConn
- type Message
- type Mode
- type Type
- type Version
- type WsConn
Constants ¶
This section is empty.
Variables ¶
var ( BoltSignature = [...]byte{0x60, 0x60, 0xb0, 0x17} HttpSignature = [...]byte{0x47, 0x45, 0x54, 0x20} )
Functions ¶
func ParseArray ¶
Parse a byte slice into a TinyArray as an array of interface{} values, returning the array, the last position in the byte slice read, and optionally an error.
func ParseMap ¶
Try parsing some bytes into a Packstream Map, returning it as a map of strings to their values as byte arrays.
If not found or something horribly wrong, return nil and an error. Also, will panic on a nil input.
func ParseString ¶
Parse a byte slice into a string, returning the string value, the last position used in the byte slice, and optionally an error
func ParseTinyInt ¶
Parse a TinyInt...which is a simply 7-bit number.
func ParseTinyString ¶
Parse a TinyString from a byte slice, returning the string (if valid) and the number of bytes processed from the slice (including the 0x80 prefix).
Otherwise, return an empty string, 0, and an error.
func StringToBytes ¶
Serialize a string to a byte slice
func TinyMapToBytes ¶
Serialize a TinyMap to a byte slice
func ValidateHandshake ¶
Inspect client and server communication for valid Bolt handshake, returning the handshake value's bytes.
In order to pick the version, we use a simple formula of:
min( max(client versions), max(server versions) )
So if client_versions=[4.0, 3.5, 3.4] and server_versions=[4.2, 4.1, 4.0, 3.5] then min(max(4.0, 3.5, 3.4), max([4.2, 4.1, 4.0, 3.5])) ==>
min(4.0, 4.2) ==> 4.0!
Though, in reality, right now we already have the max(serverVersion) as the server []byte argument.
If the handshake is input bytes or handshake is invalid, returns an error and an empty byte array.
func ValidateMagic ¶
Inspect bytes for valid Bolt Magic pattern, returning true if found. Otherwise, returns false with an error.
Types ¶
type BoltConn ¶
An abstraction of a Bolt-aware io.ReadWriterCloser. Allows for sending and receiving Messages, abstracting away the nuances of the transport.
R() should simply be a means of accessing the channel containing any available Messages. (Might rename this later.) They should be handled async by the connection instance.
WriteMessage() should synchronously try to write a Bolt Message to the connection.
type DirectConn ¶
type DirectConn struct {
// contains filtered or unexported fields
}
Designed for operating direct (e.g. TCP/IP-only) Bolt connections
func NewDirectConn ¶
func NewDirectConn(c io.ReadWriteCloser) DirectConn
Create a new Direct Bolt Connection that uses simple Read/Write calls to transfer data.
Note: the buffer size of 1024*128 is based off some manual testing as it was found 1024*64 was not enough, for instance, as some messages larger than 64kb have been encountered.
func (DirectConn) Close ¶
func (c DirectConn) Close() error
func (DirectConn) R ¶
func (c DirectConn) R() <-chan *Message
func (DirectConn) String ¶
func (c DirectConn) String() string
func (DirectConn) WriteMessage ¶
func (c DirectConn) WriteMessage(m *Message) error
type Mode ¶
type Mode string
Mode of a Bolt Transaction for determining cluster routing
func ValidateMode ¶
Try to find and validate the Mode for some given bytes, returning the Mode if found or if valid looking Bolt chatter. Otherwise, returns nil and an error.
type Type ¶
type Type string
const ( ResetMsg Type = "RESET" RunMsg Type = "RUN" DiscardMsg Type = "DISCARD" PullMsg Type = "PULL" RecordMsg Type = "RECORD" SuccessMsg Type = "SUCCESS" IgnoreMsg Type = "IGNORE" FailureMsg Type = "FAILURE" HelloMsg Type = "HELLO" GoodbyeMsg Type = "GOODBYE" BeginMsg Type = "BEGIN" CommitMsg Type = "COMMIT" RollbackMsg Type = "ROLLBACK" UnknownMsg Type = "?UNKNOWN?" NopMsg Type = "NOP" ChunkedMsg Type = "CHUNKED" // not a true bolt message )
func IdentifyType ¶
Try to extract the BoltMsg from some given bytes.
func TypeFromByte ¶
Parse a byte into the corresponding Bolt message Type
type WsConn ¶
type WsConn struct {
// contains filtered or unexported fields
}
Used for WebSocket-based Bolt connections
func NewWsConn ¶
func NewWsConn(c io.ReadWriteCloser) WsConn