Skip to content

Latest commit

 

History

History
81 lines (63 loc) · 2.41 KB

File metadata and controls

81 lines (63 loc) · 2.41 KB

Pocket Go Library Documentation

Welcome to the Pocket Go library documentation. Pocket is a graph execution engine that you can embed in your Go applications to build composable workflows with type safety and powerful concurrency patterns.

What is the Pocket Library?

The Pocket library provides:

  • A graph execution engine for Go applications
  • Type-safe workflow building with generics
  • Built-in concurrency patterns
  • Extensible node architecture
  • State management with bounded stores

Quick Start

package main

import (
    "context"
    "fmt"
    "github.com/agentstation/pocket"
)

func main() {
    // Create a simple node
    greet := pocket.NewNode[string, string]("greet",
        pocket.WithExec(func(ctx context.Context, name string) (string, error) {
            return fmt.Sprintf("Hello, %s!", name), nil
        }),
    )
    
    // Create a graph and run it
    store := pocket.NewStore()
    graph := pocket.NewGraph(greet, store)
    
    result, _ := graph.Run(context.Background(), "World")
    fmt.Println(result) // "Hello, World!"
}

Documentation

Core Concepts

Graph Execution Engine

The Pocket library implements a graph execution engine where:

  • Nodes are the building blocks of workflows
  • Each node follows the Prep→Exec→Post lifecycle
  • Graphs can be composed and nested
  • Type safety is enforced at compile time

The Node Interface

type Node interface {
    Name() string
    Prep(ctx context.Context, store StoreReader, input any) (any, error)
    Exec(ctx context.Context, prepData any) (any, error)
    Post(ctx context.Context, store StoreWriter, input, prepData, result any) (any, string, error)
    Connect(action string, next Node)
    Successors() map[string]Node
    InputType() reflect.Type
    OutputType() reflect.Type
}

Next Steps

  1. Get started with the library
  2. Learn about type safety
  3. Explore patterns
  4. View examples