Documentation
¶
Overview ¶
Package sqlrelay contains the standard-library SQL implementation shared by durable SQL providers. Database drivers remain application dependencies.
Index ¶
- Variables
- type Config
- type Dialect
- type Store
- func (store *Store) Append(groupID string, change replica.Change) (durable.AppendResult, error)
- func (store *Store) Close() error
- func (store *Store) Closed() bool
- func (store *Store) EnsureSchema(ctx context.Context) error
- func (store *Store) Replay(groupID string, after, maxEvents, maxBytes uint64, manifest replica.Manifest, ...) (events []durable.Event, highWater uint64, resultErr error)
Constants ¶
This section is empty.
Variables ¶
var ErrSequenceRange = errors.New("crdt SQL durable provider: sequence exceeds signed bigint range")
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config bounds one retained operation log per group. Timeout applies to each Append and Replay call because durable.Log intentionally has no context parameter; connection and pool lifetime remain application-owned.
type Dialect ¶
type Dialect struct {
Name string
MaxGroupIDBytes int
MaxActorIDBytes int
MaxEnvelopeBytes uint64
// ValidateGroupID and ValidateActorID provide a provider-specific final
// identifier check after the common non-empty and byte-limit guards. They
// are useful for stores whose indexed text keys have a second constraint,
// such as a UTF-16 code-unit limit. Nil keeps the common checks only.
ValidateGroupID func(string) bool
ValidateActorID func(string) bool
Schema []string
AppendOptions sql.TxOptions
ReplayOptions sql.TxOptions
InsertGroup string
LockGroup string
ReadDot string
InsertEvent string
InsertDot string
UpdateGroup string
ReadHighWater string
ReadEvents string
}
Dialect supplies fixed, audited SQL for one database family. All statements must use database/sql placeholders and must preserve the durable.Log transaction contract documented by the owning provider package.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements durable.Log with a provider-specific transaction dialect. It does not close the supplied *sql.DB, which may be shared by handlers.
func New ¶
New validates provider limits around an application-owned database/sql pool. It does not import or register a database driver.
func (*Store) Append ¶
Append atomically binds a dot to its canonical envelope, reserves the next group-local sequence, and updates capacity metadata.
func (*Store) EnsureSchema ¶
EnsureSchema creates fixed provider tables. It is intentionally explicit so applications can use a migration role instead of granting runtime DDL.
func (*Store) Replay ¶
func (store *Store) Replay(groupID string, after, maxEvents, maxBytes uint64, manifest replica.Manifest, policy crdt.ProtocolPolicy, maxMessageBytes, maxActorBytes int) (events []durable.Event, highWater uint64, resultErr error)
Replay reads one provider snapshot and refuses a partial, corrupt, over-budget, or manifest-incompatible suffix.