data-prep/

directory
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0

README

Data Preparation Examples

This directory contains examples demonstrating how to separate data preparation from script evaluation in go-polyscript.

Overview

The data preparation pattern separates static data from runtime data, making code more modular and flexible. This pattern uses a composite data provider combining static and dynamic data sources, with a clear separation between configuration, preparation, and evaluation phases.

When to Use This Pattern

This pattern is valuable for:

  • Distributed Architecture: Prepare data on one system (e.g., web server) and evaluate on another (e.g., worker)
  • Separation of Concerns: Clearly separate data processing from script execution
  • Layered Data Access: Combine static data with runtime data
  • Performance Optimization: Prepare data asynchronously while other operations are happening

Implementation Pattern

These examples follow a consistent three-phase pattern:

  1. Create evaluator with static data: Set up an evaluator with configuration data that remains constant across executions
  2. Prepare runtime data: Add dynamic data to the context using the AddDataToContext method
  3. Evaluate script: Execute the script with the enriched context

Running the Examples

Each example follows the same pattern but demonstrates it with a different script engine:

go run examples/data-prep/<engine>/main.go

Note: The Extism example requires a WASM file. If not found automatically, you may need to compile it using the Makefile in /engines/extism/wasmdata/.

Directories

Path Synopsis
Package main provides an example of using Extism with go-polyscript
Package main provides an example of using Extism with go-polyscript

Jump to

Keyboard shortcuts

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