Help us shape the future of Go! Take the 2026 Go Developer Survey

ps

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 20 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 RegisterDefer added in v0.1.3

func RegisterDefer(rt *runner.Runtime)

RegisterDefer installs defer() in the global function namespace.

func RegisterSession added in v0.2.2

func RegisterSession(rt *runner.Runtime)

RegisterSession installs session storage and manager bindings.

func RegisterSharedMemory added in v0.2.1

func RegisterSharedMemory(rt *runner.Runtime)

RegisterSharedMemory installs 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 {
	Bridge *client.Bridge
	ID     string
}

Database adds request tracing to the database binding.

func (*Database) Begin added in v0.2.2

func (b *Database) Begin(ctx context.Context) (any, error)

Begin starts a transaction and opens its tracing span.

func (*Database) Close

func (b *Database) Close(ctx context.Context) (any, error)

Close releases an exclusive connection back to the pool.

func (*Database) Commit added in v0.2.2

func (b *Database) Commit(ctx context.Context) (any, error)

Commit commits the active transaction and closes its tracing span.

func (*Database) Connect added in v0.2.2

func (b *Database) Connect(ctx context.Context) (any, error)

Connect reserves an exclusive connection from the pool.

func (*Database) Get added in v0.2.2

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

Get returns the first result row.

func (*Database) GetAll added in v0.2.2

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

GetAll returns all result rows.

func (*Database) Insert added in v0.2.2

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

Insert inserts a dynamically typed named value.

func (*Database) InsertID added in v0.2.2

func (b *Database) InsertID(ctx context.Context) (any, error)

InsertID returns the ID generated by the last insert.

func (*Database) Query added in v0.2.2

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

Query executes a statement with dynamically typed arguments.

func (*Database) Replace added in v0.2.2

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

Replace replaces a row using a dynamically typed named value.

func (*Database) Rollback added in v0.2.2

func (b *Database) Rollback(ctx context.Context) (any, error)

Rollback rolls back the active transaction and closes its tracing span.

func (*Database) RowsAffected added in v0.2.2

func (b *Database) RowsAffected(ctx context.Context) (any, error)

RowsAffected returns the affected row count from the last write.

func (*Database) SetID added in v0.2.2

func (b *Database) SetID(id string)

SetID records the PHP variable receiving this constructed client.

func (*Database) Update added in v0.2.2

func (b *Database) 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 SessionManager added in v0.2.2

type SessionManager struct {
	// SessionCookieName is the mutable name used to read and write the session
	// cookie. PHP may change it with `$session->SessionCookieName = "sid"`.
	SessionCookieName string
	// contains filtered or unexported fields
}

SessionManager associates an HTTP-only cookie with data in SessionStorage. The cookie contains only an opaque, randomly generated session ID.

func NewSessionManager added in v0.2.2

func NewSessionManager(storage SessionStorage) (*SessionManager, error)

NewSessionManager creates a manager backed by storage.

func (*SessionManager) Get added in v0.2.2

func (s *SessionManager) Get(ctx context.Context) (string, error)

Get returns the user ID stored for the current session cookie.

func (*SessionManager) Start added in v0.2.2

func (s *SessionManager) Start(ctx context.Context, userID any) error

Start creates a new session, stores userID, and stages its HTTP-only cookie.

func (*SessionManager) Valid added in v0.2.2

func (s *SessionManager) Valid(ctx context.Context) (bool, error)

Valid reports whether the request has a well-formed cookie whose session is present in storage. Missing and malformed cookies are invalid, not errors.

type SessionStorage added in v0.2.2

type SessionStorage interface {
	Load(ctx context.Context, id string) ([]byte, error)
	Save(ctx context.Context, id string, data []byte) error
	Delete(ctx context.Context, id string) error
	Prune(ctx context.Context, maxAge time.Duration) error
}

SessionStorage persists opaque session data by ID.

type SessionStorageDisk added in v0.2.2

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

SessionStorageDisk stores sessions in a local folder.

func NewSessionStorageDisk added in v0.2.2

func NewSessionStorageDisk(storagePaths ...string) (*SessionStorageDisk, error)

NewSessionStorageDisk creates the storage folder and verifies that it is writable. With no path, it uses the operating system's temporary directory.

func (*SessionStorageDisk) Delete added in v0.2.2

func (s *SessionStorageDisk) Delete(ctx context.Context, id string) error

Delete removes a session from disk.

func (*SessionStorageDisk) Load added in v0.2.2

func (s *SessionStorageDisk) Load(ctx context.Context, id string) ([]byte, error)

Load retrieves a session from disk.

func (*SessionStorageDisk) Prune added in v0.2.2

func (s *SessionStorageDisk) Prune(ctx context.Context, maxAge time.Duration) error

Prune removes sessions that have not been saved within maxAge.

func (*SessionStorageDisk) Save added in v0.2.2

func (s *SessionStorageDisk) Save(ctx context.Context, id string, data []byte) error

Save atomically writes a session to disk.

type SessionStorageMemory added in v0.2.2

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

SessionStorageMemory stores sessions in memory. Its contents are not durable.

func NewSessionStorageMemory added in v0.2.2

func NewSessionStorageMemory() *SessionStorageMemory

NewSessionStorageMemory creates empty in-memory session storage.

func (*SessionStorageMemory) Delete added in v0.2.2

func (s *SessionStorageMemory) Delete(ctx context.Context, id string) error

Delete removes a session from memory.

func (*SessionStorageMemory) Load added in v0.2.2

func (s *SessionStorageMemory) Load(ctx context.Context, id string) ([]byte, error)

Load retrieves a copy of a session's data.

func (*SessionStorageMemory) Prune added in v0.2.2

func (s *SessionStorageMemory) Prune(ctx context.Context, maxAge time.Duration) error

Prune removes sessions that have not been saved within maxAge.

func (*SessionStorageMemory) Save added in v0.2.2

func (s *SessionStorageMemory) Save(ctx context.Context, id string, data []byte) error

Save stores a copy of the session data.

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 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 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