Documentation
¶
Overview ¶
Package dataplane implements enough of the Amazon DAX binary wire protocol to serve the core DynamoDB data-plane operations over a raw TCP socket.
The DAX SDK (amazon-dax-go / amazon-dax-client) does not talk HTTP for item operations. Instead it opens a socket to the cluster endpoint and exchanges CBOR-encoded, method-ID-framed messages. This package speaks that protocol so that gopherstack can accept real DAX client connections and delegate the work to the existing in-memory DynamoDB backend.
The CBOR codec here is a faithful re-implementation of the encoding used by github.com/aws/aws-dax-go/dax/internal/cbor. It is intentionally self-contained so the data plane has no third-party runtime dependency.
Index ¶
- Variables
- type Backend
- type Reader
- func (r *Reader) PeekHeader() (byte, error)
- func (r *Reader) ReadArrayLength() (int, error)
- func (r *Reader) ReadBytes() ([]byte, error)
- func (r *Reader) ReadInt() (int, error)
- func (r *Reader) ReadInt64() (int64, error)
- func (r *Reader) ReadMapLength() (int, error)
- func (r *Reader) ReadNull() (bool, error)
- func (r *Reader) ReadNullableString() (string, error)
- func (r *Reader) ReadString() (string, error)
- type Server
- type TTLLookup
- type Writer
- func (w *Writer) Flush() error
- func (w *Writer) WriteArrayHeader(n int) error
- func (w *Writer) WriteBigInt(v *big.Int) error
- func (w *Writer) WriteBool(b bool) error
- func (w *Writer) WriteByte(b byte) error
- func (w *Writer) WriteBytes(b []byte) error
- func (w *Writer) WriteFloat64(v float64) error
- func (w *Writer) WriteInt(v int) error
- func (w *Writer) WriteInt64(v int64) error
- func (w *Writer) WriteMapHeader(n int) error
- func (w *Writer) WriteMapStreamHeader() error
- func (w *Writer) WriteNull() error
- func (w *Writer) WriteRaw(b []byte) error
- func (w *Writer) WriteStreamBreak() error
- func (w *Writer) WriteString(s string) error
- func (w *Writer) WriteTag(tag uint64) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNaN is returned when a value that should be numeric is not. ErrNaN = errors.New("cbor: not a number") )
Codec sentinel errors.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
GetItem(context.Context, *awsddb.GetItemInput) (*awsddb.GetItemOutput, error)
PutItem(context.Context, *awsddb.PutItemInput) (*awsddb.PutItemOutput, error)
DeleteItem(context.Context, *awsddb.DeleteItemInput) (*awsddb.DeleteItemOutput, error)
UpdateItem(context.Context, *awsddb.UpdateItemInput) (*awsddb.UpdateItemOutput, error)
Query(context.Context, *awsddb.QueryInput) (*awsddb.QueryOutput, error)
Scan(context.Context, *awsddb.ScanInput) (*awsddb.ScanOutput, error)
BatchGetItem(context.Context, *awsddb.BatchGetItemInput) (*awsddb.BatchGetItemOutput, error)
BatchWriteItem(context.Context, *awsddb.BatchWriteItemInput) (*awsddb.BatchWriteItemOutput, error)
TransactGetItems(context.Context, *awsddb.TransactGetItemsInput) (*awsddb.TransactGetItemsOutput, error)
TransactWriteItems(context.Context, *awsddb.TransactWriteItemsInput) (*awsddb.TransactWriteItemsOutput, error)
DescribeTable(context.Context, *awsddb.DescribeTableInput) (*awsddb.DescribeTableOutput, error)
}
Backend is the subset of the DynamoDB storage backend that the DAX data plane delegates to. The gopherstack *dynamodb.InMemoryDB satisfies this interface, so DAX item operations pass through to the real DynamoDB emulation.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decodes CBOR from the DAX wire format.
func (*Reader) PeekHeader ¶
PeekHeader returns the next header byte without consuming it.
func (*Reader) ReadArrayLength ¶
ReadArrayLength reads an array header and returns its element count.
func (*Reader) ReadMapLength ¶
ReadMapLength reads a map header and returns its pair count.
func (*Reader) ReadNull ¶
ReadNull consumes a CBOR null. It returns true if the next value was null.
func (*Reader) ReadNullableString ¶
ReadNullableString reads either a CBOR null or a string.
func (*Reader) ReadString ¶
ReadString reads a UTF-8 text string.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a DAX data-plane TCP listener. It accepts DAX client connections, performs the protocol handshake, and serves item operations by delegating to a DynamoDB Backend.
func NewServer ¶
NewServer creates a DAX data-plane server backed by the given DynamoDB backend. ctx is the process lifecycle context; the server tags it worker=dax-dataplane so all data-plane records are attributable.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer emits CBOR matching the DAX wire format.
func (*Writer) WriteArrayHeader ¶
WriteArrayHeader writes an array header for n elements.
func (*Writer) WriteBigInt ¶
WriteBigInt writes an integer that may exceed int64 range, using big-int tags when required. Mirrors the DAX client's bigint encoding.
func (*Writer) WriteBytes ¶
WriteBytes writes a byte string (major type 2).
func (*Writer) WriteFloat64 ¶
WriteFloat64 writes an IEEE-754 double.
func (*Writer) WriteInt64 ¶
WriteInt64 writes a signed 64-bit integer using CBOR's pos/neg int encoding.
func (*Writer) WriteMapHeader ¶
WriteMapHeader writes a map header for n key/value pairs.
func (*Writer) WriteMapStreamHeader ¶
WriteMapStreamHeader writes an indefinite-length map header.
func (*Writer) WriteStreamBreak ¶
WriteStreamBreak writes the indefinite-length break code.
func (*Writer) WriteString ¶
WriteString writes a UTF-8 text string (major type 3).