common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstanceCtxKey ctxKey = iota
	DoorCtxKey
	ThreadCtxKey
	RenderMapCtxKey
	BlockingCtxKey
	AdaptersCtxKey
	SessionStoreCtxKey
	InstanceStoreCtxKey
	ParentCtxKey
	AttrsCtxKey
)

Variables

This section is empty.

Functions

func AsBytes

func AsBytes(s string) []byte

func AsString

func AsString(buf *[]byte) string

func Catch

func Catch(f func()) (err error)

func CatchValue

func CatchValue[V any](f func() V) (value V, err error)

func ClearBlockingCtx

func ClearBlockingCtx(ctx context.Context) context.Context

func Debug

func Debug(a any) string

func GetChildren

func GetChildren(ctx context.Context) (context.Context, templ.Component, bool)

func Hash

func Hash(input []byte) string

func InitDefaults

func InitDefaults(s *SystemConf)

func IsBlockingCtx

func IsBlockingCtx(ctx context.Context) bool

func IsNill

func IsNill(i any) bool

func LogBlockingWarning

func LogBlockingWarning(ctx context.Context, entity string, operation string)

func MarshalJSON

func MarshalJSON(value any) ([]byte, error)

func MinifyCSS

func MinifyCSS(input []byte) ([]byte, error)

func RandId

func RandId() string

func RenderError

func RenderError(msg string) templ.Component

func RenderErrorLog

func RenderErrorLog(ctx context.Context, w io.Writer, message string, args ...any) error

func ResultChannel

func ResultChannel(ctx context.Context, action string) (chan error, bool)

func SetBlockingCtx

func SetBlockingCtx(ctx context.Context) context.Context

func StripN

func StripN(buf []byte) []byte

func Ts

func Ts()

func Zip

func Zip(input []byte) ([]byte, error)

Types

type Attrs

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

func NewAttrs

func NewAttrs() *Attrs

func (*Attrs) AppendArray

func (a *Attrs) AppendArray(name string, value any)

func (*Attrs) Items

func (a *Attrs) Items() []templ.KeyValue[string, any]

func (*Attrs) Join

func (a *Attrs) Join(attrs *Attrs)

func (*Attrs) Set

func (a *Attrs) Set(name string, value any)

func (*Attrs) SetObject

func (a *Attrs) SetObject(name string, value any)

func (*Attrs) SetRaw

func (a *Attrs) SetRaw(attrs templ.Attributes)

type CSP

type CSP struct {
	// nil or empty = 'self'
	DefaultSources      []string
	ScriptStrictDynamic bool
	// Add extra sources besides  imported hashes and nonces
	ScriptSources []string
	// Add extra sources besides  imported hashes and nonces
	StyleSources []string
	// Add extra sources besides self
	ConnectSources []string
	// nill or empty = 'none' (framework handeles via js)
	FormActions []string // nil - none
	// If null empty 'none'
	ObjectSources []string
	// If null empty 'none'
	FrameSources []string
	// If null empty 'none'
	FrameAcestors []string
	// If null empty 'none'
	BaseURIAllow []string
	// If null empy directive will not be added
	ImgSources []string
	// If null empy directive will not be added
	FontSources []string
	// If null empy directive will not be added
	MediaSources []string
	// If null empy directive will not be added
	Sandbox []string
	// If null empy directive will not be added
	WorkerSources []string
	// Inlines ScriptLocal* and StyleLocal* with nonce, impoves first time loading, not recommended. Adds nonce to style and script direcrives in header
	InlineLocal bool
}

func (*CSP) NewCollector

func (c *CSP) NewCollector() *CSPCollector

type CSPCollector

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

func (*CSPCollector) Generate

func (c *CSPCollector) Generate() string

func (*CSPCollector) Nonce

func (c *CSPCollector) Nonce() string

func (*CSPCollector) ScriptHash

func (c *CSPCollector) ScriptHash(hash []byte)

func (*CSPCollector) ScriptSource

func (c *CSPCollector) ScriptSource(source string)

func (*CSPCollector) StyleHash

func (c *CSPCollector) StyleHash(hash []byte)

func (*CSPCollector) StyleSource

func (c *CSPCollector) StyleSource(source string)

type Call

type Call interface {
	Data() *CallData
	Result(error)
}

type CallData

type CallData struct {
	Name    string
	Arg     any
	Payload Writable
}

type ClientConf

type ClientConf struct {
	TTL            time.Duration
	RequestTimeout time.Duration
	SleepTimeout   time.Duration
}

func GetClientConf

func GetClientConf(s *SystemConf) *ClientConf

type FuncCollector

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

func NewFuncCollector

func NewFuncCollector() *FuncCollector

func (*FuncCollector) Add

func (c *FuncCollector) Add(f func())

func (*FuncCollector) Apply

func (c *FuncCollector) Apply()

type Primea

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

func NewPrima

func NewPrima() *Primea

func (*Primea) Gen

func (p *Primea) Gen() uint64

type RenderMap

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

func NewRenderMap

func NewRenderMap() *RenderMap

func (*RenderMap) Destroy

func (r *RenderMap) Destroy()

func (*RenderMap) Render

func (r *RenderMap) Render(w io.Writer, index uint64) error

func (*RenderMap) RenderBuf

func (r *RenderMap) RenderBuf(w io.Writer, buf []byte) error

func (*RenderMap) WriteAttrs

func (r *RenderMap) WriteAttrs(w io.Writer, attr *Attrs) error

func (*RenderMap) Writer

func (r *RenderMap) Writer(index uint64) (*RenderWriter, bool)

type RenderWriter

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

func (*RenderWriter) Holdplace

func (rw *RenderWriter) Holdplace(w io.Writer) error

func (*RenderWriter) Len

func (rw *RenderWriter) Len() int

func (*RenderWriter) Submit

func (rw *RenderWriter) Submit()

func (*RenderWriter) SubmitEmpty

func (rw *RenderWriter) SubmitEmpty()

func (*RenderWriter) SubmitError

func (rw *RenderWriter) SubmitError(err error, args ...any)

func (*RenderWriter) Write

func (w *RenderWriter) Write(b []byte) (int, error)

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T comparable]() Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(v T) bool

func (*Set[T]) Has

func (s *Set[T]) Has(v T) bool

func (*Set[T]) IsEmpty

func (s *Set[T]) IsEmpty() bool

func (*Set[T]) Iter

func (s *Set[T]) Iter() map[T]struct{}

func (*Set[T]) Len

func (s *Set[T]) Len() int

func (*Set[T]) Remove

func (s *Set[T]) Remove(v T) bool

func (*Set[T]) Slice

func (s *Set[T]) Slice() []T

type SolitaireConf

type SolitaireConf struct {
	Request         time.Duration
	RollSize        int
	RollTime        time.Duration
	RollPendingTime time.Duration
	Queue           int
	Pending         int
}

func GetSolitaireConf

func GetSolitaireConf(s *SystemConf) *SolitaireConf

type SystemConf

type SystemConf struct {
	// SessionInstanceLimit controls the maximum number of page instances that can
	// exist simultaneously within a single session. When this limit is exceeded,
	// the oldest and least active instances are suspended to make room for new ones.
	// Default: 6.
	SessionInstanceLimit int

	// SessionExpiration sets the session expiration timeout. The session will be
	// automatically cleaned up after this duration of inactivity, regardless of
	// whether instances are present.
	// Default: 0 (session cleaned up when no more instances left).
	SessionExpiration time.Duration

	// SessionCookieExpiration sets the expiration time for the session cookie sent
	// to the client's browser. This should typically be longer than SessionExpiration
	// to allow for proper session restoration.
	// Default and recommended: 0 (session cookies expire when browser closes).
	SessionCookieExpiration time.Duration

	// InstanceGoroutineLimit sets the maximum number of goroutines that can be spawned
	// per page instance. This controls resource usage for render tasks and reactive
	// updates within each instance. Default: 16.
	InstanceGoroutineLimit int

	// InstanceTTL (Time To Live) sets how long an inactive page instance remains alive
	// before being automatically killed. Instances are considered active when they
	// have ongoing connections or recent client interactions. Default: 15 minutes
	// or at least twice SolitaireRequestTimeout (whichever is greater).
	InstanceTTL time.Duration

	// ServerDisableGzip disables gzip compression for HTTP responses when set to true.
	// Compression is enabled by default to reduce bandwidth usage, but may be disabled
	// for debugging or when using external compression. Default: false.
	ServerDisableGzip bool

	// DisconnectHiddenTimer controls how long hidden/background page instances keep
	// connection active. This helps manage CPU/RAM usage when many tabs are open
	// but not actively viewed. Default: 10 minutes.
	DisconnectHiddenTimer time.Duration

	// SolitaireRollSize sets the maximum number of bytes that can be sent in a single
	// response before commanding the client to roll to a new request. Default: 8 KB.
	SolitaireRollSize int

	// SolitaireRequestTimeout sets the maximum duration a client-server communication
	// request can remain open. Default: 30 seconds.
	SolitaireRequestTimeout time.Duration

	// SolitaireRollPendingTime sets how long the server waits if there are pending calls
	// before commanding the client to roll to a new request, even if SolitaireRollSize
	// hasn't been reached. This balances latency against request efficiency.
	// Default: 100 milliseconds.
	SolitaireRollPendingTime time.Duration

	// SolitaireQueue sets the maximum number of client calls that can be queued
	// waiting to be sent to the client. When this limit is exceeded, the instance
	// will be terminated to prevent memory exhaustion. Default: 1024.
	SolitaireQueue int

	// SolitairePending sets the maximum number of calls that can be sent to the
	// client but not yet acknowledged. Default: 256.
	SolitairePending int
}

SystemConf contains system-wide configuration options that control various aspects of the doors framework including session management, instance lifecycle, performance settings, and client-server communication parameters.

type Writable

type Writable interface {
	Destroy()
	Write(io.Writer) error
}

type WritableNone

type WritableNone struct{}

func (WritableNone) Destroy

func (w WritableNone) Destroy()

func (WritableNone) Write

func (w WritableNone) Write(io.Writer) error

type WritableRenderMap

type WritableRenderMap struct {
	Rm    *RenderMap
	Index uint64
}

func (*WritableRenderMap) Destroy

func (wrm *WritableRenderMap) Destroy()

func (*WritableRenderMap) Write

func (wrm *WritableRenderMap) Write(w io.Writer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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