batch

package
v0.0.185 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package batch provides common utilities for batch operations across all MCP tools.

This package includes helpers for:

  • Parsing parameters that accept both single values and arrays
  • Formatting batch results in a consistent structure
  • Processing batch operations with Google APIs
  • Handling partial failures in batch operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatResults

func FormatResults(results []Result) string

FormatResults creates a formatted JSON string from batch results

func ParseStringOrArray

func ParseStringOrArray(param interface{}, paramName string) ([]string, error)

ParseStringOrArray parses a parameter that can be either a single string or an array of strings

Types

type BatchResult

type BatchResult struct {
	Total      int      `json:"total"`
	Successful int      `json:"successful"`
	Failed     int      `json:"failed"`
	Results    []Result `json:"results"`
}

BatchResult represents the aggregated results of a batch operation

type Result

type Result struct {
	ID     string `json:"id"`
	Status string `json:"status"` // "success" or "error"
	Result string `json:"result,omitempty"`
	Error  string `json:"error,omitempty"`
}

Result represents the result of a single operation in a batch

func NewErrorResult

func NewErrorResult(id string, err error) Result

NewErrorResult creates an error result

func NewSuccessResult

func NewSuccessResult(id, message string) Result

NewSuccessResult creates a success result

func ProcessBatch

func ProcessBatch(ids []string, fn func(id string) (string, error)) []Result

ProcessBatch executes a function on each item and collects results fn should return (result string, error) for each item

Jump to

Keyboard shortcuts

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