Documentation
¶
Index ¶
- func Register(rt *runner.Runtime)
- func RegisterDatabase(rt *runner.Runtime)
- func RegisterDefer(rt *runner.Runtime)
- func RegisterSharedMemory(rt *runner.Runtime)
- func RegisterShutdown(rt *runner.Runtime)
- func SharedMemoryContext(ctx context.Context, s *SharedMemory) context.Context
- type Database
- type DatabaseClient
- func (b *DatabaseClient) Begin(ctx context.Context) (any, error)
- func (b *DatabaseClient) Close(ctx context.Context) (any, error)
- func (b *DatabaseClient) Commit(ctx context.Context) (any, error)
- func (b *DatabaseClient) Connect(ctx context.Context) (any, error)
- func (b *DatabaseClient) Get(ctx context.Context, query string, args ...any) (any, error)
- func (b *DatabaseClient) GetAll(ctx context.Context, query string, args ...any) (any, error)
- func (b *DatabaseClient) Insert(ctx context.Context, table string, value any) (any, error)
- func (b *DatabaseClient) InsertID(ctx context.Context) (any, error)
- func (b *DatabaseClient) Query(ctx context.Context, query string, args ...any) (any, error)
- func (b *DatabaseClient) Replace(ctx context.Context, table string, value any) (any, error)
- func (b *DatabaseClient) Rollback(ctx context.Context) (any, error)
- func (b *DatabaseClient) RowsAffected(ctx context.Context) (any, error)
- func (b *DatabaseClient) SetID(id string)
- func (b *DatabaseClient) Update(ctx context.Context, table string, value any, keyColumns ...any) (any, error)
- type DatabaseStatement
- type Options
- type SharedMemory
- func (s *SharedMemory) Clear(_ context.Context)
- func (s *SharedMemory) Count(_ context.Context, key string) string
- func (s *SharedMemory) Delete(_ context.Context, key string) bool
- func (s *SharedMemory) Get(_ context.Context, key string) string
- func (s *SharedMemory) Has(_ context.Context, key string) bool
- func (s *SharedMemory) Incr(_ context.Context, key string) int64
- func (s *SharedMemory) Set(_ context.Context, key, value string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDatabase ¶
RegisterDatabase installs the Go database bridge as PS\Database.
func RegisterDefer ¶ added in v0.1.3
RegisterDefer installs defer() in the global function namespace.
func RegisterSharedMemory ¶ added in v0.2.1
RegisterSharedMemory installs PS\SharedMemory in the runtime.
func RegisterShutdown ¶ added in v0.2.1
RegisterShutdown installs register_shutdown_function() in the global function namespace. Callbacks run in registration order when Runtime.Run finishes, including after exit or an execution error.
func SharedMemoryContext ¶ added in v0.2.1
func SharedMemoryContext(ctx context.Context, s *SharedMemory) context.Context
SharedMemoryContext binds an SharedMemory instance into the context.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database wraps a SQL database connection for PHP scripts.
func NewDatabase ¶
NewDatabase opens a database connection from the named DB_DSN_* env var.
func (*Database) Close ¶
func (d *Database) Close()
Close closes the underlying database connection.
func (*Database) EnableTracing ¶ added in v0.2.1
func (d *Database) EnableTracing()
EnableTracing enables the internal span telemetry.
func (*Database) LastInsertId ¶
LastInsertId returns the SQLite last inserted row ID.
type DatabaseClient ¶ added in v0.2.1
DatabaseClient adds request tracing to the database client binding.
func (*DatabaseClient) Begin ¶ added in v0.2.1
func (b *DatabaseClient) Begin(ctx context.Context) (any, error)
Begin starts a transaction and opens its tracing span.
func (*DatabaseClient) Close ¶ added in v0.2.1
func (b *DatabaseClient) Close(ctx context.Context) (any, error)
Close releases an exclusive connection back to the pool.
func (*DatabaseClient) Commit ¶ added in v0.2.1
func (b *DatabaseClient) Commit(ctx context.Context) (any, error)
Commit commits the active transaction and closes its tracing span.
func (*DatabaseClient) Connect ¶ added in v0.2.1
func (b *DatabaseClient) Connect(ctx context.Context) (any, error)
Connect reserves an exclusive connection from the pool.
func (*DatabaseClient) InsertID ¶ added in v0.2.1
func (b *DatabaseClient) InsertID(ctx context.Context) (any, error)
InsertID returns the ID generated by the last insert.
func (*DatabaseClient) Query ¶ added in v0.2.1
Query executes a statement with dynamically typed arguments.
func (*DatabaseClient) Replace ¶ added in v0.2.1
Replace replaces a row using a dynamically typed named value.
func (*DatabaseClient) Rollback ¶ added in v0.2.1
func (b *DatabaseClient) Rollback(ctx context.Context) (any, error)
Rollback rolls back the active transaction and closes its tracing span.
func (*DatabaseClient) RowsAffected ¶ added in v0.2.1
func (b *DatabaseClient) RowsAffected(ctx context.Context) (any, error)
RowsAffected returns the affected row count from the last write.
func (*DatabaseClient) SetID ¶ added in v0.2.1
func (b *DatabaseClient) SetID(id string)
SetID records the PHP variable receiving this constructed client.
type DatabaseStatement ¶
type DatabaseStatement struct {
// contains filtered or unexported fields
}
DatabaseStatement holds a prepared query and bound values for execution.
func (*DatabaseStatement) BindValue ¶
func (s *DatabaseStatement) BindValue(key, value any) error
BindValue binds value to a named or positional query parameter.
func (*DatabaseStatement) Close ¶
func (s *DatabaseStatement) Close() error
Close closes the active result cursor.
func (*DatabaseStatement) Execute ¶
func (s *DatabaseStatement) Execute(ctx context.Context) error
Execute runs the statement and stores the result cursor.
func (*DatabaseStatement) Fetch ¶
func (s *DatabaseStatement) Fetch() (any, error)
Fetch returns the next result row or false when no rows remain.
type Options ¶ added in v0.2.1
type Options struct {
EnableTracing bool
}
Options contains mutable flags for the database client.
type SharedMemory ¶ added in v0.2.1
type SharedMemory struct {
// contains filtered or unexported fields
}
SharedMemory is a thread-safe in-memory key-value and atomic counter store exposed as PS\SharedMemory to scripts.
func NewSharedMemory ¶ added in v0.2.1
func NewSharedMemory() *SharedMemory
NewSharedMemory returns a new empty SharedMemory instance.
func NewSharedMemoryBinding ¶ added in v0.2.1
func NewSharedMemoryBinding(ctx context.Context) (*SharedMemory, error)
NewSharedMemoryBinding is the constructor callback registered for PS\SharedMemory.
func (*SharedMemory) Clear ¶ added in v0.2.1
func (s *SharedMemory) Clear(_ context.Context)
Clear resets all keys and counters.
func (*SharedMemory) Count ¶ added in v0.2.1
func (s *SharedMemory) Count(_ context.Context, key string) string
Count returns a counter as a formatted string.
func (*SharedMemory) Delete ¶ added in v0.2.1
func (s *SharedMemory) Delete(_ context.Context, key string) bool
Delete removes a key from storage.
func (*SharedMemory) Get ¶ added in v0.2.1
func (s *SharedMemory) Get(_ context.Context, key string) string
Get retrieves a string value by key, or returns empty string if missing.
func (*SharedMemory) Has ¶ added in v0.2.1
func (s *SharedMemory) Has(_ context.Context, key string) bool
Has checks if a key exists in data or counters.