Documentation
¶
Overview ¶
Package geode provides a database/sql driver for the Geode graph database.
The driver connects to Geode servers over QUIC with TLS 1.3 and implements the full GQL (Graph Query Language) specification.
Usage ¶
Import the driver anonymously to register it with database/sql:
import (
"database/sql"
_ "geodedb.com/geode"
)
db, err := sql.Open("geode", "localhost:3141")
DSN Format ¶
The driver supports multiple DSN formats:
quic://host:port?options (QUIC transport - recommended) grpc://host:port?options (gRPC transport) host:port?options (defaults to QUIC) host:port host
Options:
- page_size: Results page size (default: 1000)
- hello_name: Client name (default: "geode-go")
- hello_ver: Client version (default: "0.1")
- conformance: GQL conformance level (default: "min")
- ca: Path to CA certificate
- cert: Path to client certificate (for mTLS)
- key: Path to client key (for mTLS)
- insecure: Skip TLS verification (testing only)
- connect_timeout: Connection timeout in seconds (default: 0 = no timeout)
Environment variables:
- GEODE_HOST: Default host if DSN is empty
- GEODE_PORT: Default port if not specified
- GEODE_TLS_CA: Default CA certificate path
Example ¶
db, err := sql.Open("geode", "quic://localhost:3141?page_size=500")
if err != nil {
log.Fatal(err)
}
defer db.Close()
rows, err := db.QueryContext(ctx, "MATCH (n:Person) RETURN n.name LIMIT 10")
if err != nil {
log.Fatal(err)
}
defer rows.Close()
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
log.Fatal(err)
}
fmt.Println(name)
}
Index ¶
- Constants
- Variables
- func IsRetryableError(err error) bool
- func NewTLSConfig(cfg *Config) (*tls.Config, error)
- func ParseTime(s string) (time.Time, error)
- func Retry(ctx context.Context, policy RetryPolicy, fn func(ctx context.Context) error) error
- func Utf8ToUtf16(s string) []uint16
- func Utf16ToUtf8(u []uint16) string
- func Wtf8Lossy(b []byte) string
- type ColumnInfo
- type Config
- type ConfigError
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)deprecated
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *Conn) CheckNamedValue(nv *driver.NamedValue) error
- func (c *Conn) Close() error
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) IsValid() bool
- func (c *Conn) Ping(ctx context.Context) error
- func (c *Conn) Prepare(query string) (driver.Stmt, error)deprecated
- func (c *Conn) PrepareContext(_ context.Context, query string) (driver.Stmt, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (c *Conn) ResetSession(ctx context.Context) error
- type ConnState
- type Connector
- type Driver
- type DriverError
- type Error
- type GQLType
- type GRPCTransport
- func (t *GRPCTransport) Addr() string
- func (t *GRPCTransport) Close() error
- func (t *GRPCTransport) IsClosed() bool
- func (t *GRPCTransport) ReceiveProto(_ context.Context) (*proto.QuicServerMessage, error)
- func (t *GRPCTransport) SendProto(ctx context.Context, msg *proto.QuicClientMessage) error
- func (t *GRPCTransport) TryReceiveProtoBuffered() (*proto.QuicServerMessage, bool, error)
- type Pool
- func (p *Pool) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
- func (p *Pool) Close() error
- func (p *Pool) Config() *Config
- func (p *Pool) DB() *sql.DB
- func (p *Pool) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (p *Pool) PingContext(ctx context.Context) error
- func (p *Pool) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (p *Pool) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- func (p *Pool) Stats() sql.DBStats
- type PoolOption
- type QUICPool
- type QUICTransport
- func (t *QUICTransport) Addr() string
- func (t *QUICTransport) Close() error
- func (t *QUICTransport) IsClosed() bool
- func (t *QUICTransport) ReceiveProto(ctx context.Context) (*proto.QuicServerMessage, error)
- func (t *QUICTransport) SendProto(ctx context.Context, msg *proto.QuicClientMessage) error
- func (t *QUICTransport) TryReceiveProtoBuffered() (*proto.QuicServerMessage, bool, error)
- type Result
- type RetryPolicy
- type Rows
- func (r *Rows) Close() error
- func (r *Rows) ColumnTypeDatabaseTypeName(index int) string
- func (r *Rows) ColumnTypeNullable(_ int) (nullable, ok bool)
- func (r *Rows) ColumnTypeScanType(index int) reflect.Type
- func (r *Rows) Columns() []string
- func (r *Rows) IsOrdered() bool
- func (r *Rows) Next(dest []driver.Value) error
- func (r *Rows) OrderKeys() []string
- type SecurityError
- type StateError
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)deprecated
- func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Stmt) NumInput() int
- func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)deprecated
- func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
- type Transport
- type TransportError
- type TransportType
- type Tx
- type UnsupportedSchemeError
Constants ¶
const ( // DefaultPort is the default Geode server port for QUIC. DefaultPort = "3141" // DefaultGRPCPort is the default Geode server port for gRPC. DefaultGRPCPort = "50051" // DefaultPageSize is the default number of rows per page. DefaultPageSize = 1000 // MaxPageSize is the maximum allowed page size. // This prevents potential DoS via memory exhaustion with extremely large page sizes. MaxPageSize = 100000 // DefaultHelloName is the default client name sent in HELLO. DefaultHelloName = "geode-go" // DefaultHelloVersion is the default client version sent in HELLO. DefaultHelloVersion = "0.1" // DefaultConformance is the default GQL conformance level. DefaultConformance = "min" // MaxQueryLength is the maximum allowed query length. MaxQueryLength = 1 << 20 // 1MB )
const ( StatusSuccess = "00000" // Successful completion StatusNoData = "02000" // No data StatusWarning = "01000" // Warning StatusTransactionState = "25000" // Invalid transaction state StatusAuth = "28000" // Authorization error StatusSerialization = "40001" // Serialization failure (retryable) StatusDeadlock = "40502" // Transaction deadlock (retryable) StatusSyntax = "42000" // Syntax error StatusConstraint = "23000" // Constraint violation StatusDuplicate = "42P07" // Duplicate object StatusInvalidParam = "22023" // Invalid parameter value StatusSystem = "58000" // System error )
ISO/IEC 39075 status class constants.
const ( // DefaultMaxOpenConns is the default maximum number of open connections. // Matches typical parallel worker counts (e.g. 8 chunk workers). DefaultMaxOpenConns = 16 // DefaultMaxIdleConns is the default maximum number of idle connections. DefaultMaxIdleConns = 4 // DefaultConnMaxLifetime is the default maximum lifetime of a connection. // Prevents connections from growing stale in long-running processes. DefaultConnMaxLifetime = 5 * time.Minute // DefaultConnMaxIdleTime is the default maximum idle time for a connection. // Set below QUIC's 30-second idle timeout to proactively recycle // connections before the server closes them. DefaultConnMaxIdleTime = 25 * time.Second // DefaultPingTimeout is the timeout for the initial ping when creating a pool. DefaultPingTimeout = 10 * time.Second )
Default pool settings tuned for Geode's QUIC transport.
const (
// DefaultQUICPoolSize is the maximum number of QUIC connections in the pool.
DefaultQUICPoolSize = 4
)
Default QUIC pool settings.
Variables ¶
var ( ErrClosed = errors.New("geode: connection closed") ErrQueryInProgress = errors.New("geode: query already in progress") ErrTxInProgress = errors.New("geode: transaction already in progress") ErrNoTx = errors.New("geode: no transaction in progress") ErrTxDone = errors.New("geode: transaction already committed or rolled back") ErrStmtClosed = errors.New("geode: statement closed") ErrRowsClosed = errors.New("geode: rows closed") ErrBadConn = errors.New("geode: bad connection") ErrInvalidState = errors.New("geode: invalid connection state") )
Sentinel errors for common conditions.
Functions ¶
func IsRetryableError ¶
IsRetryableError checks if an error is retryable.
func NewTLSConfig ¶
NewTLSConfig creates a TLS configuration for connecting to a Geode server.
The configuration enforces TLS 1.3 minimum and uses the ALPN protocol "geode/1". Certificate verification is always enabled unless explicitly disabled via Config.InsecureSkipVerify (which should only be used for testing).
CA certificates are loaded from (in order of precedence):
- Config.TLSCA (explicit path)
- GEODE_TLS_CA environment variable
- System certificate pool
If Config.TLSCert and Config.TLSKey are provided, mutual TLS (mTLS) is enabled.
func ParseTime ¶ added in v0.1.15
ParseTime parses a time string returned by the Geode server. It strips the Go monotonic clock suffix if present, then tries each supported layout in order from most specific to least specific. An error is returned for empty strings or unrecognised input.
func Retry ¶ added in v0.1.15
Retry executes fn up to policy.MaxAttempts times, retrying only when IsRetryableError returns true. Non-retryable errors and non-Geode errors are returned immediately without further attempts. Context cancellation is checked before each retry sleep.
func Utf8ToUtf16 ¶
Utf8ToUtf16 converts a UTF-8 string to UTF-16 code units.
CANARY: REQ=REQ-GQL-UNICODE-012; FEATURE="UTF-8 -> UTF-16 Conversion"; ASPECT=ClientWrapperGo; STATUS=IMPL; TEST=TestCANARY_ClientGo_Utf8Utf16RoundTrip; OWNER=clients; UPDATED=2025-09-27
func Utf16ToUtf8 ¶
Utf16ToUtf8 converts UTF-16 code units to a UTF-8 string.
CANARY: REQ=REQ-GQL-UNICODE-013; FEATURE="UTF-16 -> UTF-8 Conversion"; ASPECT=ClientWrapperGo; STATUS=IMPL; TEST=TestCANARY_ClientGo_Utf8Utf16RoundTrip; OWNER=clients; UPDATED=2025-09-27
func Wtf8Lossy ¶
Wtf8Lossy converts a byte slice to a UTF-8 string, replacing invalid sequences with the Unicode replacement character (U+FFFD).
CANARY: REQ=REQ-GQL-UNICODE-014; FEATURE="WTF-8 Lossy Decode"; ASPECT=ClientWrapperGo; STATUS=IMPL; TEST=TestCANARY_ClientGo_Wtf8Lossy; OWNER=clients; UPDATED=2025-09-27
Types ¶
type ColumnInfo ¶
ColumnInfo holds metadata about a column.
type Config ¶
type Config struct {
// Transport specifies the transport protocol (QUIC or gRPC).
Transport TransportType
// Host is the server hostname or IP address.
Host string
// Port is the server port.
Port string
// Username for authentication.
Username string
// Password for authentication.
Password string
// PageSize is the number of rows to fetch per page.
PageSize int
// HelloName is the client name sent in HELLO.
HelloName string
// HelloVersion is the client version sent in HELLO.
HelloVersion string
// Conformance is the GQL conformance level.
Conformance string
// TLS configuration
TLSCA string // Path to CA certificate
TLSCert string // Path to client certificate (for mTLS)
TLSKey string // Path to client private key (for mTLS)
// TLSDisabled disables TLS entirely (plaintext gRPC, for testing only).
TLSDisabled bool
// InsecureSkipVerify allows skipping TLS verification (for testing only).
// This should never be used in production.
InsecureSkipVerify bool
// ConnectTimeout is the maximum time to wait for a connection.
// Zero means no timeout. This helps prevent connection storms.
// For rate limiting, use database/sql's connection pool settings:
// db.SetMaxOpenConns(n) - limits concurrent connections
// db.SetMaxIdleConns(n) - limits idle connections
// db.SetConnMaxLifetime(d) - limits connection age
// db.SetConnMaxIdleTime(d) - limits idle time
ConnectTimeout int // in seconds, 0 = no timeout
// Graph is the name of the graph to select after connecting.
// When set, the driver automatically executes
// CREATE GRAPH IF NOT EXISTS <graph> and USE GRAPH <graph>
// after the HELLO handshake. This ensures every pooled connection
// targets the correct graph without manual initialization.
Graph string
}
Config holds the configuration for a Geode connection.
func ParseDSN ¶
ParseDSN parses a data source name into a Config.
See geode/docs/DSN.md for the complete DSN specification.
Supported formats:
- quic://host:port?options (QUIC transport)
- grpc://host:port?options (gRPC transport)
- host:port?options (QUIC transport, scheme-less)
- host:port (QUIC transport)
- host (QUIC transport, uses default port)
IPv6 hosts are supported:
- quic://[::1]:3141
- grpc://[2001:db8::1]:50051
Supported options:
- page_size: Results page size (default: 1000)
- hello_name: Client name (default: "geode-go")
- hello_ver: Client version (default: "0.1")
- conformance: GQL conformance level (default: "min")
- ca: Path to CA certificate
- cert: Path to client certificate (for mTLS)
- key: Path to client key (for mTLS)
- insecure_tls_skip_verify: Skip TLS verification (testing only, aliases: insecure, skip_verify)
- tls: Enable/disable TLS ("0" or "false" to disable, gRPC only)
Environment variables:
- GEODE_HOST: Default host if DSN is empty
- GEODE_PORT: Default port if not specified
- GEODE_TLS_CA: Default CA certificate path
type ConfigError ¶
type ConfigError struct {
Field string // Configuration field name
Value string // Invalid value
Message string // Error message
}
ConfigError represents DSN/configuration errors.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
Error implements the error interface.
func (*ConfigError) IsRetryable ¶
func (e *ConfigError) IsRetryable() bool
IsRetryable indicates if the operation can be retried.
func (*ConfigError) StatusClass ¶
func (e *ConfigError) StatusClass() string
StatusClass returns the status class.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a connection to a Geode database.
func (*Conn) CheckNamedValue ¶
func (c *Conn) CheckNamedValue(nv *driver.NamedValue) error
CheckNamedValue validates a named value before use.
func (*Conn) ExecContext ¶
func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext executes a query that doesn't return rows.
func (*Conn) Prepare
deprecated
Prepare returns a prepared statement. Note: Geode doesn't have server-side prepared statements, so this is a client-side implementation.
Deprecated: Use PrepareContext instead for explicit timeout control. This method uses a default 30-second timeout.
func (*Conn) PrepareContext ¶
PrepareContext returns a prepared statement with context.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector implements driver.Connector.
func (*Connector) Connect ¶
Connect returns a new connection to the database.
For QUIC transport with a shared pool, this opens a new QUIC stream on a pooled connection rather than dialing a new QUIC connection. The HELLO handshake is performed once per underlying QUIC connection, and subsequent streams inherit the authenticated state.
type Driver ¶
type Driver struct{}
Driver implements driver.Driver and driver.DriverContext.
func (*Driver) Open
deprecated
Open opens a new connection to the database. The name is a DSN (data source name) in the format described above.
Deprecated: Use OpenConnector and Connector.Connect with an explicit context for timeout control. This method uses defaultDeprecatedMethodTimeout (30s).
func (*Driver) OpenConnector ¶
OpenConnector returns a Connector for the given DSN. This allows for connection pooling with context support.
For QUIC transport, a shared connection pool is created so that multiple database/sql connections can multiplex streams over a small number of underlying QUIC connections, avoiding per-query TLS handshake overhead.
type DriverError ¶
type DriverError struct {
Class string // ISO/IEC 39075 status class (00000, 25000, etc.)
Subclass string // Status subclass
Code string // Error code (US001, IllegalOrderKey, etc.)
Message string // Human-readable message
Anchor string // Source location in query
Additional []string // Additional diagnostic info
Findings []string // Flagger findings
// contains filtered or unexported fields
}
DriverError represents errors returned from the Geode server.
func IsDriverError ¶
func IsDriverError(err error) (*DriverError, bool)
IsDriverError checks if err is a DriverError and returns it.
func (*DriverError) Error ¶
func (e *DriverError) Error() string
Error implements the error interface.
func (*DriverError) IsRetryable ¶
func (e *DriverError) IsRetryable() bool
IsRetryable indicates if the operation can be retried.
func (*DriverError) StatusClass ¶
func (e *DriverError) StatusClass() string
StatusClass returns the ISO/IEC 39075 status class.
func (*DriverError) Unwrap ¶
func (e *DriverError) Unwrap() error
Unwrap returns the underlying cause.
type Error ¶
type Error interface {
error
// StatusClass returns ISO/IEC 39075 status class.
StatusClass() string
// IsRetryable indicates if the operation can be retried.
IsRetryable() bool
}
Error is the interface for all Geode errors.
type GQLType ¶
type GQLType string
GQLType represents a GQL data type.
const ( GQLTypeInt GQLType = "INT" GQLTypeFloat GQLType = "FLOAT" GQLTypeString GQLType = "STRING" GQLTypeBool GQLType = "BOOL" GQLTypeNull GQLType = "NULL" GQLTypeList GQLType = "LIST" GQLTypeMap GQLType = "MAP" GQLTypeNode GQLType = "NODE" GQLTypeEdge GQLType = "EDGE" GQLTypePath GQLType = "PATH" GQLTypeUnknown GQLType = "UNKNOWN" )
GQL type constants.
type GRPCTransport ¶
type GRPCTransport struct {
// contains filtered or unexported fields
}
GRPCTransport implements Transport over gRPC.
func NewGRPCTransport ¶
func NewGRPCTransport(_ context.Context, cfg *Config) (*GRPCTransport, error)
NewGRPCTransport creates a new gRPC transport to the Geode server.
func (*GRPCTransport) IsClosed ¶
func (t *GRPCTransport) IsClosed() bool
IsClosed returns true if the transport is closed.
func (*GRPCTransport) ReceiveProto ¶
func (t *GRPCTransport) ReceiveProto(_ context.Context) (*proto.QuicServerMessage, error)
ReceiveProto reads a protobuf message from the gRPC stream.
func (*GRPCTransport) SendProto ¶
func (t *GRPCTransport) SendProto(ctx context.Context, msg *proto.QuicClientMessage) error
SendProto sends a protobuf message via gRPC.
func (*GRPCTransport) TryReceiveProtoBuffered ¶
func (t *GRPCTransport) TryReceiveProtoBuffered() (*proto.QuicServerMessage, bool, error)
TryReceiveProtoBuffered attempts to read a buffered message without blocking.
type Pool ¶ added in v0.1.13
type Pool struct {
// contains filtered or unexported fields
}
Pool manages a pool of Geode database connections. It wraps a *sql.DB with Geode-appropriate defaults and provides convenience methods for executing GQL queries.
Consumers should create a single Pool per DSN and share it across goroutines. The Pool handles connection lifecycle, health checking, and automatic reconnection through database/sql's built-in pooling.
Usage:
pool, err := geode.NewPool("quic://localhost:3141?graph=mydb&user=admin&pass=secret")
if err != nil {
log.Fatal(err)
}
defer pool.Close()
rows, err := pool.QueryContext(ctx, "MATCH (n:Person) RETURN n.name")
func NewPool ¶ added in v0.1.13
func NewPool(dsn string, opts ...PoolOption) (*Pool, error)
NewPool creates a connection pool for the given DSN. The DSN format is the same as for sql.Open("geode", dsn), with an additional optional `graph` parameter that auto-selects a graph on each new connection.
The pool is immediately validated with a ping. If the server is unreachable, NewPool returns an error.
Example DSNs:
quic://localhost:3141?graph=mydb&user=admin&pass=secret grpc://localhost:50051?graph=mydb&tls=0
func (*Pool) DB ¶ added in v0.1.13
DB returns the underlying *sql.DB for advanced use cases such as running transactions or using sql.Conn for connection-pinned operations.
func (*Pool) ExecContext ¶ added in v0.1.13
ExecContext executes a GQL query that doesn't return rows.
func (*Pool) PingContext ¶ added in v0.1.13
PingContext verifies a connection to the database is still alive.
func (*Pool) QueryContext ¶ added in v0.1.13
QueryContext executes a GQL query that returns rows.
func (*Pool) QueryRowContext ¶ added in v0.1.13
QueryRowContext executes a GQL query that returns at most one row.
type PoolOption ¶ added in v0.1.13
type PoolOption func(*poolConfig)
PoolOption configures a Pool.
func WithConnMaxIdleTime ¶ added in v0.1.13
func WithConnMaxIdleTime(d time.Duration) PoolOption
WithConnMaxIdleTime sets the maximum amount of time a connection may sit idle. Should be shorter than the server's idle timeout (QUIC default: 30s). Default: 25 seconds.
func WithConnMaxLifetime ¶ added in v0.1.13
func WithConnMaxLifetime(d time.Duration) PoolOption
WithConnMaxLifetime sets the maximum amount of time a connection may be reused. Expired connections are lazily closed before reuse. Default: 5 minutes.
func WithMaxIdleConns ¶ added in v0.1.13
func WithMaxIdleConns(n int) PoolOption
WithMaxIdleConns sets the maximum number of idle connections in the pool. Default: 4.
func WithMaxOpenConns ¶ added in v0.1.13
func WithMaxOpenConns(n int) PoolOption
WithMaxOpenConns sets the maximum number of open connections to the database. Zero means unlimited. Default: 16.
type QUICPool ¶ added in v0.1.15
type QUICPool struct {
// contains filtered or unexported fields
}
QUICPool manages a small pool of persistent QUIC connections. Each database/sql Conn gets a new QUIC stream on a pooled connection, amortizing the TLS handshake cost across many logical connections.
func NewQUICPool ¶ added in v0.1.15
NewQUICPool creates a new QUIC connection pool for the given config. The pool starts empty and creates connections on demand, up to maxSize.
type QUICTransport ¶
type QUICTransport struct {
// contains filtered or unexported fields
}
QUICTransport implements Transport over QUIC with TLS using length-prefixed protobuf.
QUICTransport operates in one of two modes:
- Standalone mode: owns a dedicated QUIC connection (conn != nil, pool == nil). Created via NewQUICTransport. Close() shuts down both stream and connection.
- Pooled mode: uses a stream on a shared pooled connection (pool != nil, pc != nil). Created via NewPooledQUICTransport. Close() shuts down only the stream and releases the pooled connection back to the pool.
func NewPooledQUICTransport ¶ added in v0.1.15
func NewPooledQUICTransport(ctx context.Context, pool *QUICPool) (*QUICTransport, error)
NewPooledQUICTransport creates a new QUIC transport that uses a stream from a shared QUIC connection pool. This avoids the TLS handshake overhead for each new database/sql connection.
func NewQUICTransport ¶
func NewQUICTransport(ctx context.Context, cfg *Config) (*QUICTransport, error)
NewQUICTransport creates a new QUIC transport to the Geode server.
func (*QUICTransport) Close ¶
func (t *QUICTransport) Close() error
Close closes the transport.
In standalone mode, both the stream and QUIC connection are closed. In pooled mode, only the stream is closed and the pooled connection is released back to the pool for reuse by other transports.
func (*QUICTransport) IsClosed ¶
func (t *QUICTransport) IsClosed() bool
IsClosed returns true if the transport is closed.
func (*QUICTransport) ReceiveProto ¶
func (t *QUICTransport) ReceiveProto(ctx context.Context) (*proto.QuicServerMessage, error)
ReceiveProto reads a length-prefixed protobuf message from the server. Note: This is a blocking call. Use context deadline for timeout control.
func (*QUICTransport) SendProto ¶
func (t *QUICTransport) SendProto(ctx context.Context, msg *proto.QuicClientMessage) error
SendProto writes a length-prefixed protobuf message to the server.
func (*QUICTransport) TryReceiveProtoBuffered ¶
func (t *QUICTransport) TryReceiveProtoBuffered() (*proto.QuicServerMessage, bool, error)
TryReceiveProtoBuffered reads a complete protobuf message if enough data is buffered. This avoids blocking when probing for inline frames.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result represents the result of an Exec query.
func (*Result) LastInsertId ¶
LastInsertId returns the last insert ID. Note: Geode doesn't support auto-increment IDs in the traditional sense, so this always returns 0.
func (*Result) RowsAffected ¶
RowsAffected returns the number of rows affected. Note: Geode doesn't always provide this information, so this may return 0 even when rows were affected.
type RetryPolicy ¶ added in v0.1.15
type RetryPolicy struct {
// MaxAttempts is the maximum number of attempts including the initial call.
// Values less than 1 are treated as 1.
MaxAttempts int
// InitialBackoff is the delay before the first retry.
InitialBackoff time.Duration
// MaxBackoff is the maximum backoff duration. The exponential backoff is
// clamped to this value.
MaxBackoff time.Duration
// Multiplier is the exponential backoff multiplier applied on each retry.
Multiplier float64
}
RetryPolicy configures retry behavior for transient errors.
func DefaultRetryPolicy ¶ added in v0.1.15
func DefaultRetryPolicy() RetryPolicy
DefaultRetryPolicy returns a RetryPolicy with sensible defaults: 3 max attempts, 1s initial backoff, 30s max backoff, 2.0 multiplier.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows represents a result set from a query.
func (*Rows) ColumnTypeDatabaseTypeName ¶
ColumnTypeDatabaseTypeName returns the database type name for a column.
func (*Rows) ColumnTypeNullable ¶
ColumnTypeNullable reports whether a column may be null.
func (*Rows) ColumnTypeScanType ¶
ColumnTypeScanType returns the Go type suitable for scanning.
type SecurityError ¶
type SecurityError struct {
Type string // Error type: "tls", "input", "validation"
Message string // Error message
// contains filtered or unexported fields
}
SecurityError represents security validation failures.
func (*SecurityError) Error ¶
func (e *SecurityError) Error() string
Error implements the error interface.
func (*SecurityError) IsRetryable ¶
func (e *SecurityError) IsRetryable() bool
IsRetryable indicates if the operation can be retried.
func (*SecurityError) StatusClass ¶
func (e *SecurityError) StatusClass() string
StatusClass returns the status class.
func (*SecurityError) Unwrap ¶
func (e *SecurityError) Unwrap() error
Unwrap returns the underlying cause.
type StateError ¶
type StateError struct {
Current ConnState // Current state
Expected ConnState // Expected state (if applicable)
Op string // Operation attempted
Message string // Additional message
}
StateError represents invalid connection state transitions.
func (*StateError) Error ¶
func (e *StateError) Error() string
Error implements the error interface.
func (*StateError) IsRetryable ¶
func (e *StateError) IsRetryable() bool
IsRetryable indicates if the operation can be retried.
func (*StateError) StatusClass ¶
func (e *StateError) StatusClass() string
StatusClass returns the status class.
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt represents a prepared statement. Note: Geode doesn't have server-side prepared statements, so this is a client-side implementation that stores the query and validates parameters.
func (*Stmt) ExecContext ¶
ExecContext executes a query that doesn't return rows.
func (*Stmt) QueryContext ¶
QueryContext executes a query that returns rows.
type Transport ¶
type Transport interface {
// SendProto writes a protobuf message to the server.
SendProto(ctx context.Context, msg *proto.QuicClientMessage) error
// ReceiveProto reads a protobuf message from the server.
ReceiveProto(ctx context.Context) (*proto.QuicServerMessage, error)
// TryReceiveProtoBuffered reads a message only if enough data is already buffered.
// Returns (nil, false, nil) when no complete message is buffered.
TryReceiveProtoBuffered() (*proto.QuicServerMessage, bool, error)
// Close closes the transport.
Close() error
// IsClosed returns true if the transport is closed.
IsClosed() bool
// Addr returns the remote address.
Addr() string
}
Transport defines the interface for communication with a Geode server.
type TransportError ¶
type TransportError struct {
Op string // Operation that failed
Addr string // Remote address (if applicable) - see Security Note above
// contains filtered or unexported fields
}
TransportError represents transport-layer failures.
Security Note: The Addr field contains the remote server address for diagnostic purposes. When logging errors to public locations (e.g., client telemetry, user-facing UI), callers should sanitize or omit this field to prevent internal network topology disclosure. For internal logs and debugging, the full address is valuable for troubleshooting.
func (*TransportError) Error ¶
func (e *TransportError) Error() string
Error implements the error interface.
func (*TransportError) IsRetryable ¶
func (e *TransportError) IsRetryable() bool
IsRetryable indicates if the operation can be retried.
func (*TransportError) StatusClass ¶
func (e *TransportError) StatusClass() string
StatusClass returns the status class (always system error for transport).
func (*TransportError) Temporary ¶
func (e *TransportError) Temporary() bool
Temporary indicates if this is a temporary error.
func (*TransportError) Unwrap ¶
func (e *TransportError) Unwrap() error
Unwrap returns the underlying cause.
type TransportType ¶
type TransportType int
TransportType specifies the transport protocol to use.
const ( // TransportQUIC uses QUIC transport with TLS 1.3 (default). TransportQUIC TransportType = iota // TransportGRPC uses gRPC transport. TransportGRPC )
func (TransportType) String ¶
func (t TransportType) String() string
String returns the string representation of the transport type.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a database transaction.
type UnsupportedSchemeError ¶
type UnsupportedSchemeError struct {
Scheme string
}
UnsupportedSchemeError is returned when an unsupported DSN scheme is used.
func (*UnsupportedSchemeError) Error ¶
func (e *UnsupportedSchemeError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
benchmark
command
Native Go client benchmark for Geode
|
Native Go client benchmark for Geode |
|
Package crypto provides field-level encryption for Geode node and edge properties.
|
Package crypto provides field-level encryption for Geode node and edge properties. |
|
Package graph provides a high-level API for the Geode graph database, built on top of the database/sql-compatible driver.
|
Package graph provides a high-level API for the Geode graph database, built on top of the database/sql-compatible driver. |
|
internal
|
|
|
redact
Package redact provides utilities to mask sensitive information before logging.
|
Package redact provides utilities to mask sensitive information before logging. |
|
validate
Package validate provides input validation utilities.
|
Package validate provides input validation utilities. |
|
Package proto provides protobuf message types and gRPC client for Geode.
|
Package proto provides protobuf message types and gRPC client for Geode. |