function

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ToolFunc

type ToolFunc[In any, Out any] func(context.Context, In) (Out, error)

ToolFunc defines the signature for a generic Go function that can be wrapped as a tool. It accepts a context and a strongly-typed input, and returns a strongly-typed output and an error.

type Wrapper

type Wrapper[In any, Out any] struct {
	// contains filtered or unexported fields
}

Wrapper adapts a generic ToolFunc into the universal core.Action interface. This allows any regular Go function to be managed, supervised, and traced by Manglekit.

func New

func New[In any, Out any](name string, fn ToolFunc[In, Out]) *Wrapper[In, Out]

New creates a new Action wrapper for the provided function.

Parameters:

  • name: The unique name of the action.
  • fn: The function to wrap.

Returns:

  • A pointer to the initialized Wrapper.

func (*Wrapper[In, Out]) Execute

func (w *Wrapper[In, Out]) Execute(ctx context.Context, input core.Envelope) (core.Envelope, error)

Execute performs the action logic. It automatically handles type assertion from the generic Envelope payload to the function's input type, and wraps the function's output back into an Envelope.

Parameters:

  • ctx: The execution context.
  • input: The input Envelope.

Returns:

  • The result Envelope, or an error if type assertion or execution fails.

func (*Wrapper[In, Out]) Metadata

func (w *Wrapper[In, Out]) Metadata() core.ActionMetadata

Metadata returns the action's metadata (name and type "function").

func (*Wrapper[In, Out]) SetContentType

func (w *Wrapper[In, Out]) SetContentType(ct core.ContentType)

SetContentType allows configuring the expected input content type (e.g., JSON vs Struct).

Jump to

Keyboard shortcuts

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