ps

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(rt *runner.Runtime)

Register installs symbols into the runtime.

func RegisterDatabase

func RegisterDatabase(rt *runner.Runtime)

RegisterDatabase installs the Go database bridge as PS\Database.

func RegisterDefer added in v0.1.3

func RegisterDefer(rt *runner.Runtime)

RegisterDefer installs defer() in the global function namespace.

func RegisterSharedMemory added in v0.2.1

func RegisterSharedMemory(rt *runner.Runtime)

RegisterSharedMemory installs PS\SharedMemory in the runtime.

func RegisterShutdown added in v0.2.1

func RegisterShutdown(rt *runner.Runtime)

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

func NewDatabase(ctx context.Context, name string) (*Database, error)

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

func (d *Database) LastInsertId(ctx context.Context) (int64, error)

LastInsertId returns the SQLite last inserted row ID.

func (*Database) Prepare

func (d *Database) Prepare(query string) (*DatabaseStatement, error)

Prepare creates a database statement for query.

type DatabaseClient added in v0.2.1

type DatabaseClient struct {
	DatabaseClient *client.Bridge
	ID             string
}

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) Get added in v0.2.1

func (b *DatabaseClient) Get(ctx context.Context, query string, args ...any) (any, error)

Get returns the first result row.

func (*DatabaseClient) GetAll added in v0.2.1

func (b *DatabaseClient) GetAll(ctx context.Context, query string, args ...any) (any, error)

GetAll returns all result rows.

func (*DatabaseClient) Insert added in v0.2.1

func (b *DatabaseClient) Insert(ctx context.Context, table string, value any) (any, error)

Insert inserts a dynamically typed named value.

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

func (b *DatabaseClient) Query(ctx context.Context, query string, args ...any) (any, error)

Query executes a statement with dynamically typed arguments.

func (*DatabaseClient) Replace added in v0.2.1

func (b *DatabaseClient) Replace(ctx context.Context, table string, value any) (any, error)

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.

func (*DatabaseClient) Update added in v0.2.1

func (b *DatabaseClient) Update(ctx context.Context, table string, value any, keyColumns ...any) (any, error)

Update updates a row using dynamically typed named values and key columns.

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.

func (*SharedMemory) Incr added in v0.2.1

func (s *SharedMemory) Incr(_ context.Context, key string) int64

Incr atomically increments and returns a counter.

func (*SharedMemory) Set added in v0.2.1

func (s *SharedMemory) Set(_ context.Context, key, value string)

Set stores a string value.

Jump to

Keyboard shortcuts

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