Help us shape the future of Go! Take the 2026 Go Developer Survey

dataplane

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

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 NewReader

func NewReader(r io.Reader) *Reader

NewReader wraps r in a buffered CBOR reader.

func (*Reader) PeekHeader

func (r *Reader) PeekHeader() (byte, error)

PeekHeader returns the next header byte without consuming it.

func (*Reader) ReadArrayLength

func (r *Reader) ReadArrayLength() (int, error)

ReadArrayLength reads an array header and returns its element count.

func (*Reader) ReadBytes

func (r *Reader) ReadBytes() ([]byte, error)

ReadBytes reads a byte string.

func (*Reader) ReadInt

func (r *Reader) ReadInt() (int, error)

ReadInt reads a signed integer into an int.

func (*Reader) ReadInt64

func (r *Reader) ReadInt64() (int64, error)

ReadInt64 reads a signed 64-bit integer.

func (*Reader) ReadMapLength

func (r *Reader) ReadMapLength() (int, error)

ReadMapLength reads a map header and returns its pair count.

func (*Reader) ReadNull

func (r *Reader) ReadNull() (bool, error)

ReadNull consumes a CBOR null. It returns true if the next value was null.

func (*Reader) ReadNullableString

func (r *Reader) ReadNullableString() (string, error)

ReadNullableString reads either a CBOR null or a string.

func (*Reader) ReadString

func (r *Reader) ReadString() (string, error)

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

func NewServer(ctx context.Context, backend Backend, ttl TTLLookup) *Server

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.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr returns the bound listener address, or nil if not listening.

func (*Server) Close

func (s *Server) Close() error

Close stops accepting connections and closes all active connections.

func (*Server) Listen

func (s *Server) Listen(addr string) error

Listen binds the server to addr (e.g. ":8111") and serves connections until the server is closed. It returns once the listener is bound; serving runs in a background goroutine.

type TTLLookup

type TTLLookup interface {
	GetDefaultTTL() (recordTTL time.Duration, queryTTL time.Duration)
}

TTLLookup provides TTL configuration for the item and query caches.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer emits CBOR matching the DAX wire format.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter wraps w in a buffered CBOR writer.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush flushes buffered bytes to the underlying writer.

func (*Writer) WriteArrayHeader

func (w *Writer) WriteArrayHeader(n int) error

WriteArrayHeader writes an array header for n elements.

func (*Writer) WriteBigInt

func (w *Writer) WriteBigInt(v *big.Int) error

WriteBigInt writes an integer that may exceed int64 range, using big-int tags when required. Mirrors the DAX client's bigint encoding.

func (*Writer) WriteBool

func (w *Writer) WriteBool(b bool) error

WriteBool writes a CBOR boolean.

func (*Writer) WriteByte

func (w *Writer) WriteByte(b byte) error

WriteByte writes a single raw byte.

func (*Writer) WriteBytes

func (w *Writer) WriteBytes(b []byte) error

WriteBytes writes a byte string (major type 2).

func (*Writer) WriteFloat64

func (w *Writer) WriteFloat64(v float64) error

WriteFloat64 writes an IEEE-754 double.

func (*Writer) WriteInt

func (w *Writer) WriteInt(v int) error

WriteInt writes a signed integer.

func (*Writer) WriteInt64

func (w *Writer) WriteInt64(v int64) error

WriteInt64 writes a signed 64-bit integer using CBOR's pos/neg int encoding.

func (*Writer) WriteMapHeader

func (w *Writer) WriteMapHeader(n int) error

WriteMapHeader writes a map header for n key/value pairs.

func (*Writer) WriteMapStreamHeader

func (w *Writer) WriteMapStreamHeader() error

WriteMapStreamHeader writes an indefinite-length map header.

func (*Writer) WriteNull

func (w *Writer) WriteNull() error

WriteNull writes a CBOR null.

func (*Writer) WriteRaw

func (w *Writer) WriteRaw(b []byte) error

WriteRaw writes pre-encoded bytes verbatim (no CBOR header).

func (*Writer) WriteStreamBreak

func (w *Writer) WriteStreamBreak() error

WriteStreamBreak writes the indefinite-length break code.

func (*Writer) WriteString

func (w *Writer) WriteString(s string) error

WriteString writes a UTF-8 text string (major type 3).

func (*Writer) WriteTag

func (w *Writer) WriteTag(tag uint64) error

WriteTag writes a CBOR semantic tag header.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL