Documentation
¶
Overview ¶
Package bolt is a server-side implementation of the Bolt protocol (v4.4 and v5.0 to v5.4) and PackStream.
Index ¶
- Constants
- Variables
- func Serve(ctx context.Context, nc net.Conn, cfg Config)
- func Split(l net.Listener, serve func(net.Conn)) net.Listener
- type Backend
- type Client
- func (c *Client) Call(tag byte, fields ...any) (Response, error)
- func (c *Client) PullAll(n int64) ([][]any, Response, error)
- func (c *Client) Query(query string, params map[string]any) ([][]any, Response, error)
- func (c *Client) Recv() (Response, error)
- func (c *Client) Send(tag byte, fields ...any) error
- type Config
- type Decoder
- type Encoder
- type Error
- type Node
- type Path
- type Relationship
- type Response
- type Result
- type Session
- type Struct
- type UnboundRelationship
- type Version
Constants ¶
const ( TagSuccess = msgSuccess TagRecord = msgRecord TagIgnore = msgIgnored TagFailure = msgFailure )
Response tags a client can see.
const ( TagHello = msgHello TagGoodbye = msgGoodbye TagReset = msgReset TagRun = msgRun TagBegin = msgBegin TagCommit = msgCommit TagRollback = msgRollback TagDiscard = msgDiscard TagPull = msgPull TagRoute = msgRoute TagLogon = msgLogon TagLogoff = msgLogoff )
Request tags a client can send.
const ( CodeSyntax = "Neo.ClientError.Statement.SyntaxError" CodeInvalid = "Neo.ClientError.Request.Invalid" CodeConstraint = "Neo.ClientError.Schema.ConstraintValidationFailed" CodeTransient = "Neo.TransientError.Transaction.Terminated" CodeDatabaseError = "Neo.DatabaseError.General.UnknownError" CodeProtocol = "Neo.ClientError.Request.Invalid" )
Failure codes sent to drivers.
const Preamble = 4
Preamble is the length of the Bolt magic preamble.
Variables ¶
var ( ErrTruncated = errors.New("bolt: truncated packstream value") ErrTooDeep = errors.New("bolt: packstream nesting too deep") ErrBadMarker = errors.New("bolt: unknown packstream marker") ErrUnsupported = errors.New("bolt: unsupported value type") ErrTooLarge = errors.New("bolt: packstream size exceeds message") )
Errors returned while decoding.
var ( ErrBadMagic = errors.New("bolt: bad handshake preamble") ErrNoVersion = errors.New("bolt: no common protocol version") ErrMsgTooBig = errors.New("bolt: message exceeds size limit") ErrBadMessage = errors.New("bolt: malformed message") )
Errors raised by the transport layer.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
NewSession() Session
Authenticate(ctx context.Context, auth map[string]any) error
}
Backend creates sessions and checks credentials.
type Client ¶
type Client struct {
// Version is the negotiated protocol version.
Version Version
// contains filtered or unexported fields
}
Client is a minimal Bolt client for protocol tests.
func Dial ¶
func Dial(rw io.ReadWriter, versions ...Version) (*Client, error)
Dial performs the handshake proposing the given versions (newest preference first, at most four).
func DialRaw ¶
func DialRaw(rw io.ReadWriter, slots [16]byte) (*Client, error)
DialRaw sends the given 16 version bytes after the preamble.
type Config ¶
type Config struct {
Backend Backend
// Agent is the HELLO "server" string.
Agent string
// Database is reported as the default database name.
Database string
// Addr is the address advertised by ROUTE; the connection's local address is used when empty.
Addr string
}
Config configures Serve.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads PackStream values from a bounded in-memory message.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder appends PackStream values to a buffer.
func NewEncoder ¶
NewEncoder returns an encoder whose graph structures follow the given protocol version.
type Path ¶
type Path struct {
Nodes []Node
Rels []UnboundRelationship
Indices []int64
}
Path is an alternating walk; Indices holds (rel index, node index) pairs, relationship indices 1-based and negative when traversed backwards.
type Relationship ¶
type Relationship struct {
Props map[string]any
ElementID string
Type string
StartElementID string
EndElementID string
ID int64
StartID int64
EndID int64
}
Relationship is a Bolt relationship with both endpoints.
type Session ¶
type Session interface {
Run(ctx context.Context, query string, params map[string]any) (*Result, error)
Begin(ctx context.Context) error
Commit(ctx context.Context) error
Rollback(ctx context.Context) error
Close()
}
Session is one connection's view of the database. Run executes inside the open transaction, if any.
type UnboundRelationship ¶
UnboundRelationship is a relationship inside a Path.