calltransform

package
v1.164.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package calltransform carries the transforms covering a tool call (#2634) to the paths where rows or a body reach the caller other than the tool result: the pages an export writes and the rows a script reads from an application database. The tool-call handlers put a Transformer on the call's context; each toolkit asks it where it produces rows or a body, so a covered caller gets the same data on every path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Body

func Body(ctx context.Context, body any) (any, error)

Body is body as the transforms covering ctx's call leave it, or body as it is when none covers it.

func Covered

func Covered(ctx context.Context) bool

Covered reports whether a transform covers ctx's call.

func Data

func Data(ctx context.Context, tool string, data json.RawMessage) (json.RawMessage, error)

Data is an export's JSON data as the transforms covering the call leave it; with none, or no data, as it is.

func Export

func Export(ctx context.Context, tool string, body io.Reader, maxBytes int64) (io.Reader, error)

Export is an export's body as the transforms covering the call leave it, for tool (which names the export in an error), or body as it is when none covers it. A covered body is read whole, at most maxBytes, decoded as JSON, transformed and written back; one that is not JSON is handed over as text.

func Pages

func Pages(ctx context.Context, tool string, sink func([]json.RawMessage) error) func([]json.RawMessage) error

Pages passes each page of items an export merges through the transforms covering the call before sink writes it; with none, sink as it is.

func Rows

func Rows(ctx context.Context, columns []string, rows []map[string]any) ([]map[string]any, error)

Rows is rows as the transforms covering ctx's call leave them, or rows as they are when none covers it.

func With

With carries the transforms covering a call to the toolkit serving it.

Types

type Transformer

type Transformer interface {
	// Rows is the rows a covered caller gets, columns naming their keys.
	Rows(ctx context.Context, columns []string, rows []map[string]any) ([]map[string]any, error)
	// Body is the body a covered caller gets.
	Body(ctx context.Context, body any) (any, error)
}

Transformer applies the transforms covering a call.

Jump to

Keyboard shortcuts

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