Documentation
¶
Overview ¶
Package glqlwasm runs the GLQL transpiler WebAssembly module in-process.
The module is the same artifact the frontend uses (the @gitlab/query-language-rust npm package). It is a wasm-bindgen build whose only host imports are a clock, an opaque Date handle, a panic hook and an externref table initialiser, so it runs under a plain WebAssembly runtime with no JavaScript engine.
Index ¶
Constants ¶
const MaxLegalTransformBytes = maxLegalTransformBytes
MaxLegalTransformBytes is maxLegalTransformBytes for the gateway package.
Variables ¶
var ErrDisabled = errors.New("glql: transpiler not loaded")
ErrDisabled is returned when the transpiler was never loaded.
var ErrPoolExhausted = errors.New("glql: all transpiler instances busy")
ErrPoolExhausted is returned when every pooled instance is busy.
var ErrQueryTooLarge = errors.New("glql: query too large to compile")
ErrQueryTooLarge is the compile-path counterpart. Both paths hit the same per-instance ceiling, but they are not interchangeable: on the compile path there is no result set yet, so reporting a result-size problem sends the caller after a limit that does not exist. Which sentinel a size failure carries is therefore decided by the function being called, not by the allocation site, which cannot tell the two apart.
var ErrResultTooLarge = errors.New("glql: result too large to transform")
ErrResultTooLarge is returned when a transform exhausts an instance's memory ceiling. This is deterministic for a given response, so a caller must be told to narrow the query rather than to retry: the same request will fail the same way every time.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// WasmPath is the .wasm file to load.
WasmPath string
// PoolSize bounds concurrent transpilations. Defaults to GOMAXPROCS.
PoolSize int
}
Options configures a Transpiler.
type Transpiler ¶
type Transpiler struct {
// contains filtered or unexported fields
}
Transpiler compiles GLQL to GraphQL and transforms GraphQL responses back. It is safe for concurrent use.
func New ¶
func New(ctx context.Context, opts Options) (*Transpiler, error)
New loads the module from disk and pre-instantiates the pool. The AOT compile costs ~1.5s, so this belongs in process start-up, not in a request path.
func (*Transpiler) Close ¶
func (t *Transpiler) Close(ctx context.Context) error
Close releases the runtime and every pooled instance.
func (*Transpiler) Compile ¶
Compile transpiles a GLQL query into a GraphQL document. compileContext is the JSON the frontend passes: username, mode, project, group, fields, featureFlags.
func (*Transpiler) PoolSize ¶
func (t *Transpiler) PoolSize() int
PoolSize reports how many transpilations can run concurrently.