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 ¶
- func Body(ctx context.Context, body any) (any, error)
- func Covered(ctx context.Context) bool
- func Data(ctx context.Context, tool string, data json.RawMessage) (json.RawMessage, error)
- func Export(ctx context.Context, tool string, body io.Reader, maxBytes int64) (io.Reader, error)
- func Pages(ctx context.Context, tool string, sink func([]json.RawMessage) error) func([]json.RawMessage) error
- func Rows(ctx context.Context, columns []string, rows []map[string]any) ([]map[string]any, error)
- func With(ctx context.Context, t Transformer) context.Context
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Body ¶
Body is body as the transforms covering ctx's call leave it, or body as it is when none covers it.
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 ¶
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.
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.