s4wave_sql_world

package
v0.53.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const SqlDbTypeID = "sql/db"

SqlDbTypeID is the world ObjectType id for SQL databases.

The id is the stable identity of the SQL database object across every build, so it lives in this unconstrained file: the SqlSetRootOp world operation (and the kvtx/sql_lite and TinyGo browser builds that compile it) resolves the id without the SRPC-server-backed factory in objecttype.go, which is gated to !tinygo && !sql_lite.

Variables

View Source
var (
	SqlStatementKind_name = map[int32]string{
		0: "SQL_STATEMENT_KIND_UNSPECIFIED",
		1: "SQL_STATEMENT_KIND_EXEC",
		2: "SQL_STATEMENT_KIND_QUERY",
	}
	SqlStatementKind_value = map[string]int32{
		"SQL_STATEMENT_KIND_UNSPECIFIED": 0,
		"SQL_STATEMENT_KIND_EXEC":        1,
		"SQL_STATEMENT_KIND_QUERY":       2,
	}
)

Enum value maps for SqlStatementKind.

View Source
var ErrCommitPersisted = errors.New("sql/db: commit persisted before world root update failed")

ErrCommitPersisted reports that SQL committed before the world root update failed.

SqlDbType registers the SQL database world ObjectType.

View Source
var SqlSetRootOpId = "sql/db/set-root"

SqlSetRootOpId is the world operation id for sql/db root updates.

Functions

func LookupSqlSetRootOp

func LookupSqlSetRootOp(ctx context.Context, id string) (world.Operation, error)

LookupSqlSetRootOp constructs a sql/db root update operation from its id.

func NewSqlSetRootOpBlock

func NewSqlSetRootOpBlock() block.Block

NewSqlSetRootOpBlock constructs a SqlSetRootOp block.

func SqlDbFactory

func SqlDbFactory(
	ctx context.Context,
	_ *logrus.Entry,
	_ bus.Bus,
	_ world.Engine,
	ws world.WorldState,
	objectKey string,
) (srpc.Invoker, func(), error)

SqlDbFactory opens a world-backed SQL database object over SRPC.

Types

type CommitPersistedError

type CommitPersistedError struct {
	Err error
}

CommitPersistedError wraps an error after the inner SQL root already committed.

func (*CommitPersistedError) Error

func (e *CommitPersistedError) Error() string

Error returns the commit persistence error message.

func (*CommitPersistedError) Is

func (e *CommitPersistedError) Is(target error) bool

Is matches ErrCommitPersisted.

func (*CommitPersistedError) Unwrap

func (e *CommitPersistedError) Unwrap() error

Unwrap returns the wrapped root update error.

type SqlArgument

type SqlArgument struct {

	// Name is the named-argument name, if any.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Ordinal is the positional argument ordinal.
	Ordinal int32 `protobuf:"varint,2,opt,name=ordinal,proto3" json:"ordinal,omitempty"`
	// Value is the SQL bind value.
	Value *sql.SqlValue `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

SqlArgument records one SQL bind argument.

func (*SqlArgument) CloneMessageVT

func (m *SqlArgument) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*SqlArgument) CloneVT

func (m *SqlArgument) CloneVT() *SqlArgument

func (*SqlArgument) EqualMessageVT

func (this *SqlArgument) EqualMessageVT(thatMsg any) bool

func (*SqlArgument) EqualVT

func (this *SqlArgument) EqualVT(that *SqlArgument) bool

func (*SqlArgument) GetName

func (x *SqlArgument) GetName() string

func (*SqlArgument) GetOrdinal

func (x *SqlArgument) GetOrdinal() int32

func (*SqlArgument) GetValue

func (x *SqlArgument) GetValue() *sql.SqlValue

func (*SqlArgument) MarshalJSON

func (x *SqlArgument) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SqlArgument to JSON.

func (*SqlArgument) MarshalProtoJSON

func (x *SqlArgument) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SqlArgument message to JSON.

func (*SqlArgument) MarshalProtoText

func (x *SqlArgument) MarshalProtoText() string

func (*SqlArgument) MarshalToSizedBufferVT

func (m *SqlArgument) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SqlArgument) MarshalToVT

func (m *SqlArgument) MarshalToVT(dAtA []byte) (int, error)

func (*SqlArgument) MarshalVT

func (m *SqlArgument) MarshalVT() (dAtA []byte, err error)

func (*SqlArgument) ProtoMessage

func (*SqlArgument) ProtoMessage()

func (*SqlArgument) Reset

func (x *SqlArgument) Reset()

func (*SqlArgument) SizeVT

func (m *SqlArgument) SizeVT() (n int)

func (*SqlArgument) String

func (x *SqlArgument) String() string

func (*SqlArgument) UnmarshalJSON

func (x *SqlArgument) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SqlArgument from JSON.

func (*SqlArgument) UnmarshalProtoJSON

func (x *SqlArgument) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SqlArgument message from JSON.

func (*SqlArgument) UnmarshalVT

func (m *SqlArgument) UnmarshalVT(dAtA []byte) error

type SqlSetRootOp

type SqlSetRootOp struct {

	// ObjectKey is the sql/db object key to update.
	ObjectKey string `protobuf:"bytes,1,opt,name=object_key,json=objectKey,proto3" json:"objectKey,omitempty"`
	// RootRef is the committed SQL root reference.
	RootRef *bucket.ObjectRef `protobuf:"bytes,2,opt,name=root_ref,json=rootRef,proto3" json:"rootRef,omitempty"`
	// BaseRef is the object root the transaction committed from.
	BaseRef *bucket.ObjectRef `protobuf:"bytes,3,opt,name=base_ref,json=baseRef,proto3" json:"baseRef,omitempty"`
	// Statements are the committed writes needed to rebase from a moved base.
	Statements []*SqlStatement `protobuf:"bytes,4,rep,name=statements,proto3" json:"statements,omitempty"`
	// contains filtered or unexported fields
}

SqlSetRootOp advances a sql/db world object's root after a SQL commit.

func NewSqlSetRootOp

func NewSqlSetRootOp(
	objectKey string,
	baseRef *bucket.ObjectRef,
	rootRef *bucket.ObjectRef,
	statements []*SqlStatement,
) *SqlSetRootOp

NewSqlSetRootOp constructs a sql/db root update operation.

func (*SqlSetRootOp) ApplyWorldObjectOp

func (o *SqlSetRootOp) ApplyWorldObjectOp(
	ctx context.Context,
	le *logrus.Entry,
	os world.ObjectState,
	sender peer.ID,
) (bool, error)

ApplyWorldObjectOp applies the root update to an already-resolved object.

func (*SqlSetRootOp) ApplyWorldOp

func (o *SqlSetRootOp) ApplyWorldOp(
	ctx context.Context,
	le *logrus.Entry,
	ws world.WorldState,
	sender peer.ID,
) (bool, error)

ApplyWorldOp applies the root update to a sql/db world object.

func (*SqlSetRootOp) CloneMessageVT

func (m *SqlSetRootOp) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*SqlSetRootOp) CloneVT

func (m *SqlSetRootOp) CloneVT() *SqlSetRootOp

func (*SqlSetRootOp) EqualMessageVT

func (this *SqlSetRootOp) EqualMessageVT(thatMsg any) bool

func (*SqlSetRootOp) EqualVT

func (this *SqlSetRootOp) EqualVT(that *SqlSetRootOp) bool

func (*SqlSetRootOp) GetBaseRef

func (x *SqlSetRootOp) GetBaseRef() *bucket.ObjectRef

func (*SqlSetRootOp) GetObjectKey

func (x *SqlSetRootOp) GetObjectKey() string

func (*SqlSetRootOp) GetOperationTypeId

func (o *SqlSetRootOp) GetOperationTypeId() string

GetOperationTypeId returns the operation type identifier.

func (*SqlSetRootOp) GetRootRef

func (x *SqlSetRootOp) GetRootRef() *bucket.ObjectRef

func (*SqlSetRootOp) GetStatements

func (x *SqlSetRootOp) GetStatements() []*SqlStatement

func (*SqlSetRootOp) MarshalBlock

func (o *SqlSetRootOp) MarshalBlock() ([]byte, error)

MarshalBlock marshals the operation block.

func (*SqlSetRootOp) MarshalJSON

func (x *SqlSetRootOp) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SqlSetRootOp to JSON.

func (*SqlSetRootOp) MarshalProtoJSON

func (x *SqlSetRootOp) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SqlSetRootOp message to JSON.

func (*SqlSetRootOp) MarshalProtoText

func (x *SqlSetRootOp) MarshalProtoText() string

func (*SqlSetRootOp) MarshalToSizedBufferVT

func (m *SqlSetRootOp) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SqlSetRootOp) MarshalToVT

func (m *SqlSetRootOp) MarshalToVT(dAtA []byte) (int, error)

func (*SqlSetRootOp) MarshalVT

func (m *SqlSetRootOp) MarshalVT() (dAtA []byte, err error)

func (*SqlSetRootOp) ProtoMessage

func (*SqlSetRootOp) ProtoMessage()

func (*SqlSetRootOp) Reset

func (x *SqlSetRootOp) Reset()

func (*SqlSetRootOp) SizeVT

func (m *SqlSetRootOp) SizeVT() (n int)

func (*SqlSetRootOp) String

func (x *SqlSetRootOp) String() string

func (*SqlSetRootOp) UnmarshalBlock

func (o *SqlSetRootOp) UnmarshalBlock(b []byte) error

UnmarshalBlock unmarshals the operation block.

func (*SqlSetRootOp) UnmarshalJSON

func (x *SqlSetRootOp) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SqlSetRootOp from JSON.

func (*SqlSetRootOp) UnmarshalProtoJSON

func (x *SqlSetRootOp) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SqlSetRootOp message from JSON.

func (*SqlSetRootOp) UnmarshalVT

func (m *SqlSetRootOp) UnmarshalVT(dAtA []byte) error

func (*SqlSetRootOp) Validate

func (o *SqlSetRootOp) Validate() error

Validate performs cursory checks on the operation.

type SqlStatement

type SqlStatement struct {

	// Kind is the replay method.
	Kind SqlStatementKind `protobuf:"varint,1,opt,name=kind,proto3" json:"kind,omitempty"`
	// Dsn is the transaction default database.
	Dsn string `protobuf:"bytes,2,opt,name=dsn,proto3" json:"dsn,omitempty"`
	// Query is the SQL statement text.
	Query string `protobuf:"bytes,3,opt,name=query,proto3" json:"query,omitempty"`
	// Args are the bind arguments.
	Args []*SqlArgument `protobuf:"bytes,4,rep,name=args,proto3" json:"args,omitempty"`
	// contains filtered or unexported fields
}

SqlStatement records one statement in transaction execution order.

func (*SqlStatement) CloneMessageVT

func (m *SqlStatement) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*SqlStatement) CloneVT

func (m *SqlStatement) CloneVT() *SqlStatement

func (*SqlStatement) EqualMessageVT

func (this *SqlStatement) EqualMessageVT(thatMsg any) bool

func (*SqlStatement) EqualVT

func (this *SqlStatement) EqualVT(that *SqlStatement) bool

func (*SqlStatement) GetArgs

func (x *SqlStatement) GetArgs() []*SqlArgument

func (*SqlStatement) GetDsn

func (x *SqlStatement) GetDsn() string

func (*SqlStatement) GetKind

func (x *SqlStatement) GetKind() SqlStatementKind

func (*SqlStatement) GetQuery

func (x *SqlStatement) GetQuery() string

func (*SqlStatement) MarshalJSON

func (x *SqlStatement) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SqlStatement to JSON.

func (*SqlStatement) MarshalProtoJSON

func (x *SqlStatement) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SqlStatement message to JSON.

func (*SqlStatement) MarshalProtoText

func (x *SqlStatement) MarshalProtoText() string

func (*SqlStatement) MarshalToSizedBufferVT

func (m *SqlStatement) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*SqlStatement) MarshalToVT

func (m *SqlStatement) MarshalToVT(dAtA []byte) (int, error)

func (*SqlStatement) MarshalVT

func (m *SqlStatement) MarshalVT() (dAtA []byte, err error)

func (*SqlStatement) ProtoMessage

func (*SqlStatement) ProtoMessage()

func (*SqlStatement) Reset

func (x *SqlStatement) Reset()

func (*SqlStatement) SizeVT

func (m *SqlStatement) SizeVT() (n int)

func (*SqlStatement) String

func (x *SqlStatement) String() string

func (*SqlStatement) UnmarshalJSON

func (x *SqlStatement) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SqlStatement from JSON.

func (*SqlStatement) UnmarshalProtoJSON

func (x *SqlStatement) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SqlStatement message from JSON.

func (*SqlStatement) UnmarshalVT

func (m *SqlStatement) UnmarshalVT(dAtA []byte) error

type SqlStatementKind

type SqlStatementKind int32

SqlStatementKind identifies a replayable SQL transaction statement.

const (
	// SQL_STATEMENT_KIND_UNSPECIFIED is invalid.
	SqlStatementKind_SQL_STATEMENT_KIND_UNSPECIFIED SqlStatementKind = 0
	// SQL_STATEMENT_KIND_EXEC replays via ExecContext.
	SqlStatementKind_SQL_STATEMENT_KIND_EXEC SqlStatementKind = 1
	// SQL_STATEMENT_KIND_QUERY replays via QueryContext and drains rows.
	SqlStatementKind_SQL_STATEMENT_KIND_QUERY SqlStatementKind = 2
)

func (SqlStatementKind) Enum

func (SqlStatementKind) MarshalJSON

func (x SqlStatementKind) MarshalJSON() ([]byte, error)

MarshalJSON marshals the SqlStatementKind to JSON.

func (SqlStatementKind) MarshalProtoJSON

func (x SqlStatementKind) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the SqlStatementKind to JSON.

func (SqlStatementKind) MarshalProtoText

func (x SqlStatementKind) MarshalProtoText() string

func (SqlStatementKind) MarshalText

func (x SqlStatementKind) MarshalText() ([]byte, error)

MarshalText marshals the SqlStatementKind to text.

func (SqlStatementKind) String

func (x SqlStatementKind) String() string

func (*SqlStatementKind) UnmarshalJSON

func (x *SqlStatementKind) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the SqlStatementKind from JSON.

func (*SqlStatementKind) UnmarshalProtoJSON

func (x *SqlStatementKind) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the SqlStatementKind from JSON.

func (*SqlStatementKind) UnmarshalText

func (x *SqlStatementKind) UnmarshalText(b []byte) error

UnmarshalText unmarshals the SqlStatementKind from text.

type WorldBackedSql

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

WorldBackedSql commits SQL roots through world operations.

func NewWorldBackedSql

func NewWorldBackedSql(
	_ context.Context,
	root worldCursor,
	ws world.WorldState,
	objectKey string,
) (*WorldBackedSql, error)

NewWorldBackedSql opens a world-backed SQL database.

func (*WorldBackedSql) Close

func (s *WorldBackedSql) Close()

Close releases the backing world cursor.

func (*WorldBackedSql) NewSqlTransaction

func (s *WorldBackedSql) NewSqlTransaction(
	ctx context.Context,
	write bool,
	dsn string,
) (hydra_sql.SqlTransaction, error)

NewSqlTransaction opens a SQL transaction.

Jump to

Keyboard shortcuts

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