Documentation ¶
Index ¶
- Constants
- 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 WsConn
Constants ¶
const ( ResetMsg Type = "RESET" RunMsg = "RUN" DiscardMsg = "DISCARD" PullMsg = "PULL" RecordMsg = "RECORD" SuccessMsg = "SUCCESS" IgnoreMsg = "IGNORE" FailureMsg = "FAILURE" HelloMsg = "HELLO" GoodbyeMsg = "GOODBYE" BeginMsg = "BEGIN" CommitMsg = "COMMIT" RollbackMsg = "ROLLBACK" UnknownMsg = "?UNKNOWN?" NopMsg = "NOP" ChunkedMsg = "CHUNKED" // not a true bolt message )
Variables ¶
This section is empty.
Functions ¶
func IntToBytes ¶ added in v0.4.0
Serialize an int to a byte slice
func ParseArray ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
Serialize a string to a byte slice
func TinyMapToBytes ¶ added in v0.4.0
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 containining any available Messages. (Might rename this later.) They should be handled async by the conncetion 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 ¶ added in v0.2.0
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
const ( ReadMode Mode = "READ" WriteMode = "WRITE" )
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
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