serverruntime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 73 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrorKind

func IsErrorKind(err error, kind string) bool

IsErrorKind reports whether err is a GoX runtime error with the provided kind.

func OpenSessionRuntime

func OpenSessionRuntime(cluster server.ClusterAdapter, policy *SessionPolicy, instanceID string, maxMessageSize ...int64) (server.SessionStorageRuntime, server.ClusterRuntime, error)

Types

type Cache404

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

func LoadCache404

func LoadCache404(rootDir string) *Cache404

func (*Cache404) Add

func (c *Cache404) Add(path string)

func (*Cache404) AddIfGeneration

func (c *Cache404) AddIfGeneration(path string, generation uint64)

func (*Cache404) Clear

func (c *Cache404) Clear()

func (*Cache404) Close

func (c *Cache404) Close()

func (*Cache404) Generation

func (c *Cache404) Generation() uint64

func (*Cache404) Has

func (c *Cache404) Has(path string) bool

func (*Cache404) Len

func (c *Cache404) Len() int

func (*Cache404) Remove

func (c *Cache404) Remove(path string)

type ClientAssetFileMeta

type ClientAssetFileMeta struct {
	URL       string
	File      string
	Kind      string
	Name      string
	Framework string
	Entry     string
	Mode      string
}

func (ClientAssetFileMeta) CacheControl

func (m ClientAssetFileMeta) CacheControl() string

func (ClientAssetFileMeta) IsDev

func (m ClientAssetFileMeta) IsDev() bool

type ClientAssetPolicy

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

func NewClientAssetPolicy

func NewClientAssetPolicy(result *goxcompiler.CompileResult) *ClientAssetPolicy

func (*ClientAssetPolicy) ActionsRuntimeURL

func (p *ClientAssetPolicy) ActionsRuntimeURL() string

func (*ClientAssetPolicy) BaseStyleURL

func (p *ClientAssetPolicy) BaseStyleURL() string

func (*ClientAssetPolicy) BundleByEntryFile

func (p *ClientAssetPolicy) BundleByEntryFile(entryFile string) (goxcompiler.CompileClientBundle, bool)

func (*ClientAssetPolicy) BundlesForFrameworkMode

func (p *ClientAssetPolicy) BundlesForFrameworkMode(framework string, mode string) []goxcompiler.CompileClientBundle

func (*ClientAssetPolicy) ClientRuntimeHTML

func (p *ClientAssetPolicy) ClientRuntimeHTML() []byte

func (*ClientAssetPolicy) Clone

func (*ClientAssetPolicy) FilesForEntry

func (p *ClientAssetPolicy) FilesForEntry(entryFile string) []string

func (*ClientAssetPolicy) IsEmpty

func (p *ClientAssetPolicy) IsEmpty() bool

func (*ClientAssetPolicy) Merge

func (p *ClientAssetPolicy) Merge(result *goxcompiler.CompileResult)

func (*ClientAssetPolicy) Meta

func (*ClientAssetPolicy) ReferencedFiles

func (p *ClientAssetPolicy) ReferencedFiles() map[string]struct{}

func (*ClientAssetPolicy) ReplaceBundle

func (p *ClientAssetPolicy) ReplaceBundle(bundle goxcompiler.CompileClientBundle)

func (*ClientAssetPolicy) Resolve

func (p *ClientAssetPolicy) Resolve(url string) (string, bool)

func (*ClientAssetPolicy) ResolveClientIsland

func (p *ClientAssetPolicy) ResolveClientIsland(clientKey string) (gox.ClientIslandSnapshot, bool)

func (*ClientAssetPolicy) RuntimeURL

func (p *ClientAssetPolicy) RuntimeURL() string

func (*ClientAssetPolicy) StylesForEntry

func (p *ClientAssetPolicy) StylesForEntry(entryURL string) []string

type ConfigOverrides

type ConfigOverrides struct {
	DevEnabled    bool
	DevEnabledSet bool
	HTTPHost      string
	HTTPHostSet   bool
	HTTPPort      int
	HTTPPortSet   bool
}

ConfigOverrides contains execution-only values supplied by commands such as gox run. They are reapplied after config hot reload and never persisted.

type DynamicWarmupCache

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

func LoadDynamicWarmupCache

func LoadDynamicWarmupCache(rootDir string) *DynamicWarmupCache

func (*DynamicWarmupCache) Close

func (c *DynamicWarmupCache) Close()

func (*DynamicWarmupCache) FlushRuntime

func (c *DynamicWarmupCache) FlushRuntime(r *Runtime) error

func (*DynamicWarmupCache) FlushRuntimeForRestart

func (c *DynamicWarmupCache) FlushRuntimeForRestart(r *Runtime, request RestartRequest) error

func (*DynamicWarmupCache) Start

func (c *DynamicWarmupCache) Start(r *Runtime)

func (*DynamicWarmupCache) WarmupPaths

func (c *DynamicWarmupCache) WarmupPaths() dynamicWarmupSelection

type GoxError

type GoxError = goxerrors.GoxError

GoxError is the internal runtime error model. Public SDK access still goes through github.com/gox-lang/gox.Error.

func NewGoxError

func NewGoxError(stage gox.GoxErrorStage, message string, cause error) *GoxError

func NewGoxPanicError

func NewGoxPanicError(recovered any) *GoxError

type GoxErrorRuntime

type GoxErrorRuntime struct {
	Route    *GoxRouteRuntime
	Handlers map[string]func(*gox.Context)
	// contains filtered or unexported fields
}

type GoxRouteDependency

type GoxRouteDependency struct {
	AbsPath string
	Size    int64
	ModTime time.Time
	IsEntry bool
}

type GoxRouteRuntime

type GoxRouteRuntime struct {
	RoutePath     string
	AbsPath       string
	RelPath       string
	ModTime       time.Time
	Size          int64
	BuildDir      string
	BuildVersion  string
	GeneratedPath string
	PluginPath    string
	GoBinary      string
	State         GoxRouteState
	LastError     string

	GeneratedExists bool
	GeneratedSize   int64
	PluginExists    bool
	PluginSize      int64

	Plugin           *plugin.Plugin
	HTTPHandlers     map[string]func(*gox.Context)
	HTTPContentTypes map[string]string
	Actions          map[string]gox.ActionHandler
	WebSocketHandler gox.WebSocketHandler
	ChannelHandler   gox.ChannelHandler

	Dependencies  []GoxRouteDependency
	CompileResult *goxcompiler.CompileResult
	WarmupHits    atomic.Int64
	// contains filtered or unexported fields
}

type GoxRouteState

type GoxRouteState string
const (
	GoxRouteCold      GoxRouteState = "cold"
	GoxRouteCompiling GoxRouteState = "compiling"
	GoxRouteCompiled  GoxRouteState = "compiled"
	GoxRouteBuilding  GoxRouteState = "building"
	GoxRouteBuilt     GoxRouteState = "built"
	GoxRouteLoading   GoxRouteState = "loading"
	GoxRouteLoaded    GoxRouteState = "loaded"
	GoxRouteFailed    GoxRouteState = "failed"
)

type GoxWriter

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

func (*GoxWriter) BufferedBytes

func (w *GoxWriter) BufferedBytes() int

func (*GoxWriter) BytesIn

func (w *GoxWriter) BytesIn() int64

func (*GoxWriter) BytesOut

func (w *GoxWriter) BytesOut() int64

func (*GoxWriter) Close

func (w *GoxWriter) Close() error

func (*GoxWriter) ConfigureRoute

func (w *GoxWriter) ConfigureRoute(isAction bool, traceDeep bool) error

func (*GoxWriter) DiscardBuffered

func (w *GoxWriter) DiscardBuffered()

func (*GoxWriter) Flush

func (w *GoxWriter) Flush() error

func (*GoxWriter) Stats

func (w *GoxWriter) Stats() GoxWriterStats

func (*GoxWriter) Write

func (w *GoxWriter) Write(p []byte) (int, error)

func (*GoxWriter) WriteByte

func (w *GoxWriter) WriteByte(value byte) error

func (*GoxWriter) WriteBytes

func (w *GoxWriter) WriteBytes(value []byte)

func (*GoxWriter) WriteError

func (w *GoxWriter) WriteError(value error)

func (*GoxWriter) WriteRawAny

func (w *GoxWriter) WriteRawAny(value any)

func (*GoxWriter) WriteRawBigFloat

func (w *GoxWriter) WriteRawBigFloat(value *big.Float)

func (*GoxWriter) WriteRawBigFloatValue

func (w *GoxWriter) WriteRawBigFloatValue(value big.Float)

func (*GoxWriter) WriteRawBigInt

func (w *GoxWriter) WriteRawBigInt(value *big.Int)

func (*GoxWriter) WriteRawBigIntValue

func (w *GoxWriter) WriteRawBigIntValue(value big.Int)

func (*GoxWriter) WriteRawBigRat

func (w *GoxWriter) WriteRawBigRat(value *big.Rat)

func (*GoxWriter) WriteRawBigRatValue

func (w *GoxWriter) WriteRawBigRatValue(value big.Rat)

func (*GoxWriter) WriteRawBool

func (w *GoxWriter) WriteRawBool(value bool)

func (*GoxWriter) WriteRawBytes

func (w *GoxWriter) WriteRawBytes(value []byte)

func (*GoxWriter) WriteRawFloat32

func (w *GoxWriter) WriteRawFloat32(value float32)

func (*GoxWriter) WriteRawFloat64

func (w *GoxWriter) WriteRawFloat64(value float64)

func (*GoxWriter) WriteRawInt

func (w *GoxWriter) WriteRawInt(value int)

func (*GoxWriter) WriteRawInt8

func (w *GoxWriter) WriteRawInt8(value int8)

func (*GoxWriter) WriteRawInt16

func (w *GoxWriter) WriteRawInt16(value int16)

func (*GoxWriter) WriteRawInt32

func (w *GoxWriter) WriteRawInt32(value int32)

func (*GoxWriter) WriteRawInt64

func (w *GoxWriter) WriteRawInt64(value int64)

func (*GoxWriter) WriteRawString

func (w *GoxWriter) WriteRawString(value string)

func (*GoxWriter) WriteRawUint

func (w *GoxWriter) WriteRawUint(value uint)

func (*GoxWriter) WriteRawUint8

func (w *GoxWriter) WriteRawUint8(value uint8)

func (*GoxWriter) WriteRawUint16

func (w *GoxWriter) WriteRawUint16(value uint16)

func (*GoxWriter) WriteRawUint32

func (w *GoxWriter) WriteRawUint32(value uint32)

func (*GoxWriter) WriteRawUint64

func (w *GoxWriter) WriteRawUint64(value uint64)

func (*GoxWriter) WriteRawUintptr

func (w *GoxWriter) WriteRawUintptr(value uintptr)

func (*GoxWriter) WriteSpreadAttrs

func (w *GoxWriter) WriteSpreadAttrs(attrs map[string]string)

func (*GoxWriter) WriteStream

func (w *GoxWriter) WriteStream(value io.Reader)

func (*GoxWriter) WriteTextAny

func (w *GoxWriter) WriteTextAny(value any)

func (*GoxWriter) WriteTextBigFloat

func (w *GoxWriter) WriteTextBigFloat(value *big.Float)

func (*GoxWriter) WriteTextBigFloatValue

func (w *GoxWriter) WriteTextBigFloatValue(value big.Float)

func (*GoxWriter) WriteTextBigInt

func (w *GoxWriter) WriteTextBigInt(value *big.Int)

func (*GoxWriter) WriteTextBigIntValue

func (w *GoxWriter) WriteTextBigIntValue(value big.Int)

func (*GoxWriter) WriteTextBigRat

func (w *GoxWriter) WriteTextBigRat(value *big.Rat)

func (*GoxWriter) WriteTextBigRatValue

func (w *GoxWriter) WriteTextBigRatValue(value big.Rat)

func (*GoxWriter) WriteTextBool

func (w *GoxWriter) WriteTextBool(value bool)

func (*GoxWriter) WriteTextBytes

func (w *GoxWriter) WriteTextBytes(value []byte)

func (*GoxWriter) WriteTextFloat32

func (w *GoxWriter) WriteTextFloat32(value float32)

func (*GoxWriter) WriteTextFloat64

func (w *GoxWriter) WriteTextFloat64(value float64)

func (*GoxWriter) WriteTextInt

func (w *GoxWriter) WriteTextInt(value int)

func (*GoxWriter) WriteTextInt8

func (w *GoxWriter) WriteTextInt8(value int8)

func (*GoxWriter) WriteTextInt16

func (w *GoxWriter) WriteTextInt16(value int16)

func (*GoxWriter) WriteTextInt32

func (w *GoxWriter) WriteTextInt32(value int32)

func (*GoxWriter) WriteTextInt64

func (w *GoxWriter) WriteTextInt64(value int64)

func (*GoxWriter) WriteTextString

func (w *GoxWriter) WriteTextString(value string)

func (*GoxWriter) WriteTextUint

func (w *GoxWriter) WriteTextUint(value uint)

func (*GoxWriter) WriteTextUint8

func (w *GoxWriter) WriteTextUint8(value uint8)

func (*GoxWriter) WriteTextUint16

func (w *GoxWriter) WriteTextUint16(value uint16)

func (*GoxWriter) WriteTextUint32

func (w *GoxWriter) WriteTextUint32(value uint32)

func (*GoxWriter) WriteTextUint64

func (w *GoxWriter) WriteTextUint64(value uint64)

func (*GoxWriter) WriteTextUintptr

func (w *GoxWriter) WriteTextUintptr(value uintptr)

type GoxWriterStats

type GoxWriterStats struct {
	BytesIn      int64
	BytesOut     int64
	FlushCount   int64
	Compressed   bool
	Encoding     string
	StartedAt    time.Time
	FirstWriteAt time.Time
	LastFlushAt  time.Time
	ClosedAt     time.Time
	BufferSize   int

	CloseFlushBufferDuration   time.Duration
	CloseResponseWriteDuration time.Duration
	ClosePoolPutDuration       time.Duration
	CompressionDuration        time.Duration
}

type IPResolverPolicy

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

func NewIPResolverPolicy

func NewIPResolverPolicy(config server.ResolverIPForwardedConfig) (*IPResolverPolicy, error)

func NewIPResolverPolicyUnsafe

func NewIPResolverPolicyUnsafe(headers []string) *IPResolverPolicy

func (*IPResolverPolicy) Resolve

func (p *IPResolverPolicy) Resolve(req *http.Request) (string, bool)

type MethodPolicy

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

func NewMethodPolicy

func NewMethodPolicy(methods []string) *MethodPolicy

type PreRouter

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

func NewPreRouter

func NewPreRouter(config server.RoutesConfig) (*PreRouter, error)

func (*PreRouter) LogLoaded

func (p *PreRouter) LogLoaded()

func (*PreRouter) Match

func (p *PreRouter) Match(path string) (pattern string, target string, params map[string]string, ok bool)

type RateLimitLimitPolicy

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

func (*RateLimitLimitPolicy) Allow

type RateLimitPolicy

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

func NewRateLimitPolicy

func NewRateLimitPolicy(config server.RateLimitConfig) (*RateLimitPolicy, error)

func (*RateLimitPolicy) Match

type RateLimitResult

type RateLimitResult struct {
	Allowed    bool
	Limit      int
	Remaining  int
	ResetAt    time.Time
	RetryAfter time.Duration
}

type RateLimitRulePolicy

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

type RateLimitStore

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

func NewRateLimitStore

func NewRateLimitStore() *RateLimitStore

func (*RateLimitStore) AllowFixedWindow

func (s *RateLimitStore) AllowFixedWindow(key string, limit int, window time.Duration, now time.Time) RateLimitResult

func (*RateLimitStore) AllowLeakyBucket

func (s *RateLimitStore) AllowLeakyBucket(key string, capacity int, every time.Duration, drain int, now time.Time) RateLimitResult

func (*RateLimitStore) AllowSlidingWindow

func (s *RateLimitStore) AllowSlidingWindow(key string, limit int, window time.Duration, now time.Time) RateLimitResult

func (*RateLimitStore) AllowTokenBucket

func (s *RateLimitStore) AllowTokenBucket(key string, burst int, every time.Duration, refill int, now time.Time) RateLimitResult

func (*RateLimitStore) Close

func (s *RateLimitStore) Close()

type RestartReason

type RestartReason string
const RestartReasonGoSourceChanged RestartReason = "go-source-changed"
const RestartReasonHTTPConfigChanged RestartReason = "http-config-changed"

type RestartRequest

type RestartRequest struct {
	Reason          RestartReason
	ChangedPath     string
	ChangedRelPath  string
	AffectedEntries []hotreload.ReloadEntry
}

func RestartRequestFromError

func RestartRequestFromError(err error) (RestartRequest, bool)

type RestartRequestedError

type RestartRequestedError struct {
	Request RestartRequest
}

func (*RestartRequestedError) Error

func (err *RestartRequestedError) Error() string

type Runtime

type Runtime struct {
	Config      server.Config
	Out         io.Writer
	ProjectRoot string
	// contains filtered or unexported fields
}

func New

func New(config server.Config, out io.Writer, p *project.Project, paths toolchain.Paths, result *goxcompiler.CompileResult, overrides ...ConfigOverrides) (*Runtime, error)

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) ListenAndServe

func (r *Runtime) ListenAndServe() error

func (*Runtime) ReloadConfig

func (r *Runtime) ReloadConfig() error

func (*Runtime) ServeHTTP

func (r *Runtime) ServeHTTP(w http.ResponseWriter, req *http.Request)

type RuntimeState

type RuntimeState struct {
	Config       server.Config
	Methods      *MethodPolicy
	IPResolver   *IPResolverPolicy
	Session      *SessionPolicy
	RateLimit    *RateLimitPolicy
	Static       *StaticPolicy
	PreRouter    *PreRouter
	ClientAssets *ClientAssetPolicy
}

func NewRuntimeState

func NewRuntimeState(config server.Config, projectRoot string, result *goxcompiler.CompileResult) (*RuntimeState, error)

type SessionPolicy

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

func NewSessionPolicy

func NewSessionPolicy(projectName string, config server.SessionConfig) (*SessionPolicy, error)

type StaticCache

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

func LoadStaticCache

func LoadStaticCache(rootDir string) *StaticCache

func (*StaticCache) Close

func (c *StaticCache) Close()

func (*StaticCache) GetEncoding

func (c *StaticCache) GetEncoding(routePath string, sourceInfo os.FileInfo, encoding string, level int) (string, os.FileInfo, bool)

func (*StaticCache) Len

func (c *StaticCache) Len() int

func (*StaticCache) MarkDeleted

func (c *StaticCache) MarkDeleted(routePath string)

func (*StaticCache) Set

func (c *StaticCache) Set(routePath string, modTime string)

func (*StaticCache) SetEncoding

func (c *StaticCache) SetEncoding(routePath string, sourceInfo os.FileInfo, encoding string, level int, artifactPath string, artifactInfo os.FileInfo, etag string)

func (*StaticCache) SetSource

func (c *StaticCache) SetSource(routePath string, info os.FileInfo, etag string, contentType string)

type StaticPolicy

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

func NewStaticPolicy

func NewStaticPolicy(projectRoot string, config server.StaticConfig) (*StaticPolicy, error)

type TestExecutor

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

TestExecutor executes github.com/gox-lang/gox/test pipelines against an in-memory Runtime. It is used by the gox test runner. The public SDK never imports serverruntime directly.

func NewTestExecutor

func NewTestExecutor(runtime *Runtime) *TestExecutor

func NewTestExecutorWithOptions

func NewTestExecutorWithOptions(runtime *Runtime, options TestExecutorOptions) *TestExecutor

func (*TestExecutor) Execute

func (e *TestExecutor) Execute(config sdk.Config, pipeline []sdk.ExecutePipeLine) (sdk.ExecuteResult, bool)

func (*TestExecutor) ExecuteBenchmark

func (e *TestExecutor) ExecuteBenchmark(config sdk.Config, pipeline []sdk.ExecutePipeLine) (sdk.ExecuteResult, bool)

type TestExecutorOptions

type TestExecutorOptions struct {
	// OutputRoot is the tests directory used by snapshot resolution.
	OutputRoot string

	// BaseConfig is the app/server config used when test.Config.OverrideConfig is set.
	BaseConfig *server.Config

	// RuntimeFactory creates a runtime from a possibly overridden config.
	RuntimeFactory func(server.Config) (*Runtime, error)
}

TestExecutorOptions configures the in-memory test executor.

Jump to

Keyboard shortcuts

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