Documentation
¶
Index ¶
- func Register(rt *runner.Runtime)
- func RegisterDatabaseMigrate(rt *runner.Runtime)
- func RegisterDefer(rt *runner.Runtime)
- func RegisterSession(rt *runner.Runtime)
- func RegisterSharedMemory(rt *runner.Runtime)
- func RegisterShutdown(rt *runner.Runtime)
- func SharedMemoryContext(ctx context.Context, s *SharedMemory) context.Context
- type Database
- func (b *Database) Begin(ctx context.Context) (any, error)
- func (b *Database) Close(ctx context.Context) (any, error)
- func (b *Database) Commit(ctx context.Context) (any, error)
- func (b *Database) Connect(ctx context.Context) (any, error)
- func (b *Database) Get(ctx context.Context, query string, args ...any) (any, error)
- func (b *Database) GetAll(ctx context.Context, query string, args ...any) (any, error)
- func (b *Database) Insert(ctx context.Context, table string, value any) (any, error)
- func (b *Database) InsertID(ctx context.Context) (any, error)
- func (b *Database) Query(ctx context.Context, query string, args ...any) (any, error)
- func (b *Database) Replace(ctx context.Context, table string, value any) (any, error)
- func (b *Database) Rollback(ctx context.Context) (any, error)
- func (b *Database) RowsAffected(ctx context.Context) (any, error)
- func (b *Database) SetID(id string)
- func (b *Database) Update(ctx context.Context, table string, value any, keyColumns ...any) (any, error)
- type DatabaseMigrate
- type SessionManager
- type SessionStorage
- type SessionStorageDisk
- func (s *SessionStorageDisk) Delete(ctx context.Context, id string) error
- func (s *SessionStorageDisk) Load(ctx context.Context, id string) ([]byte, error)
- func (s *SessionStorageDisk) Prune(ctx context.Context, maxAge time.Duration) error
- func (s *SessionStorageDisk) Save(ctx context.Context, id string, data []byte) error
- type SessionStorageMemory
- func (s *SessionStorageMemory) Delete(ctx context.Context, id string) error
- func (s *SessionStorageMemory) Load(ctx context.Context, id string) ([]byte, error)
- func (s *SessionStorageMemory) Prune(ctx context.Context, maxAge time.Duration) error
- func (s *SessionStorageMemory) Save(ctx context.Context, id string, data []byte) error
- 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 RegisterDatabaseMigrate ¶ added in v0.2.3
RegisterDatabaseMigrate installs the Database\Migrate binding.
func RegisterDefer ¶ added in v0.1.3
RegisterDefer installs defer() in the global function namespace.
func RegisterSession ¶ added in v0.2.2
RegisterSession installs session storage and manager bindings.
func RegisterSharedMemory ¶ added in v0.2.1
RegisterSharedMemory installs 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 ¶
Database adds request tracing to the database binding.
func (*Database) Commit ¶ added in v0.2.2
Commit commits the active transaction and closes its tracing span.
func (*Database) Query ¶ added in v0.2.2
Query executes a statement with dynamically typed arguments.
func (*Database) Replace ¶ added in v0.2.2
Replace replaces a row using a dynamically typed named value.
func (*Database) Rollback ¶ added in v0.2.2
Rollback rolls back the active transaction and closes its tracing span.
func (*Database) RowsAffected ¶ added in v0.2.2
RowsAffected returns the affected row count from the last write.
type DatabaseMigrate ¶ added in v0.2.3
type DatabaseMigrate struct {
// contains filtered or unexported fields
}
DatabaseMigrate loads and runs SQL migrations against a platform database.
func (*DatabaseMigrate) Load ¶ added in v0.2.3
func (m *DatabaseMigrate) Load(pattern string) error
Load reads migrations matching pattern from the runtime source filesystem.
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.
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.
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.
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.