vihren

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0

README

Vihren

Go Reference Latest release License

Vihren is a Go toolkit for building typed Temporal workflows with less boilerplate. You write ordinary Go activities and workflows, mark them with //vihren:activity and //vihren:workflow, and vihren-gen generates the Temporal registration, workflow-safe activity proxies, and typed clients you'd otherwise hand-write.

If you're building Temporal workflows in Go, Vihren gives you:

  • Code Generation — typed activity/workflow plumbing without the hand-written boilerplate.
  • Large Payload Storage — a claim-check pattern that keeps large data out of Temporal's workflow history.
  • Embedded Temporal — an in-process server so examples and local development need no external infrastructure.

Install

Requires Go 1.26 or newer.

go get vihren.dev/vihren
go install vihren.dev/vihren/cmd/vihren-gen@latest

Code Generation

Write the activity and workflow:

type GreetingInput struct{ Name string }
type GreetingOutput struct{ Message string }

//vihren:activity
func (a *GreetingActivities) ComposeGreeting(ctx context.Context, in GreetingInput) (GreetingOutput, error) {
	return GreetingOutput{Message: fmt.Sprintf("%s, %s", a.Prefix, in.Name)}, nil
}

//vihren:workflow
func HelloWorkflow(ctx workflow.Context, in GreetingInput) (GreetingOutput, error) {
	ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{StartToCloseTimeout: time.Second})
	return Activity.ComposeGreeting(ctx, in)
}

Generate the plumbing:

go generate ./...

vihren-gen writes Register (worker registration), the type-checked Activity proxy used above, and a typed NewClient for starting workflows and awaiting typed results — none of it hand-maintained.

Run it with zero infrastructure:

go run ./examples/codegenhello/cmd/codegenhello-embedded
# Hello, Ada

See examples/codegenhello for the full walkthrough.

Large Payload Storage

Large workflow data — agentic LLM context, documents, ML models — can blow past Temporal's workflow history size limits. blob solves this with a claim-check pattern: activities offload data to a backend and pass a typed handle through the workflow instead of the bytes.

//vihren:activity
func GenerateLargePrompt(ctx context.Context, input string) (blob.Value[string], error) {
	veryLargeString := "..." // e.g., fetched from a database
	return blob.Offload(ctx, veryLargeString)
}

//vihren:activity
func CallLLM(ctx context.Context, prompt blob.Value[string]) (string, error) {
	actualPrompt, err := prompt.Resolve(ctx)
	if err != nil {
		return "", err
	}
	return runInference(actualPrompt), nil
}

The workflow only ever passes prompt around; it never touches the underlying bytes. See blob and examples/conversationstorage for backend setup and a full walkthrough.

Embedded Temporal

embeddedtemporal runs a Temporal server inside your own process — no Docker, no daemon, no temporal server start-dev. It's built for examples, demos, and single-binary local development, not production deployments.

server, err := embeddedtemporal.Start()
if err != nil {
	return err
}
defer server.Close()

See docs/embedded-temporal.md.

License

Vihren is licensed under the Apache License, Version 2.0. See the NOTICE file for attribution.

Directories

Path Synopsis
Package blob provides claim-check values and content-addressed storage for large Temporal workflow payloads.
Package blob provides claim-check values and content-addressed storage for large Temporal workflow payloads.
cmd
vihren-gen command
Package embeddedtemporal runs a Temporal server inside the current process so a single Go binary can host durable workflows with no external infrastructure.
Package embeddedtemporal runs a Temporal server inside the current process so a single Go binary can host durable workflows with no external infrastructure.
examples
codegenhello
Package codegenhello is the minimal vihren-gen example: a developer writes one activity and one workflow, and the generator supplies all Temporal registration and typed-call plumbing (see vihren.gen.go).
Package codegenhello is the minimal vihren-gen example: a developer writes one activity and one workflow, and the generator supplies all Temporal registration and typed-call plumbing (see vihren.gen.go).
codegenhello/cmd/codegenhello-embedded command
Command codegenhello-embedded runs the whole codegenhello example in a single process: it starts an embedded Temporal server, hosts a worker for the generated activity and workflow, and starts the workflow through the generated typed client — no Docker, no daemon, no `just temporal-start`.
Command codegenhello-embedded runs the whole codegenhello example in a single process: it starts an embedded Temporal server, hosts a worker for the generated activity and workflow, and starts the workflow through the generated typed client — no Docker, no daemon, no `just temporal-start`.
codegenhello/cmd/codegenhello-start command
Command codegenhello-start starts HelloWorkflow through the generated typed client and prints the result.
Command codegenhello-start starts HelloWorkflow through the generated typed client and prints the result.
codegenhello/cmd/codegenhello-worker command
Command codegenhello-worker runs a Temporal worker for the codegenhello example.
Command codegenhello-worker runs a Temporal worker for the codegenhello example.
conversationstorage
Package conversationstorage demonstrates why an agent's growing multi-turn context should be carried as a list of small blob.Ref handles instead of one growing value handed to Temporal's native ExternalStorage.
Package conversationstorage demonstrates why an agent's growing multi-turn context should be carried as a list of small blob.Ref handles instead of one growing value handed to Temporal's native ExternalStorage.
conversationstorage/cmd/conversationstorage-demo command
Command conversationstorage-demo runs the O(n)-vs-O(n^2) storage comparison example on an embedded Temporal server.
Command conversationstorage-demo runs the O(n)-vs-O(n^2) storage comparison example on an embedded Temporal server.
temporalhello
Package temporalhello is the vanilla Temporal SDK counterpart to examples/codegenhello.
Package temporalhello is the vanilla Temporal SDK counterpart to examples/codegenhello.
temporalhello/cmd/temporalhello-embedded command
Command temporalhello-embedded runs the vanilla Temporal counterpart to codegenhello in a single process: it starts an embedded Temporal server, manually registers the activity and workflow, starts the workflow through client.ExecuteWorkflow, and awaits the result through WorkflowRun.Get.
Command temporalhello-embedded runs the vanilla Temporal counterpart to codegenhello in a single process: it starts an embedded Temporal server, manually registers the activity and workflow, starts the workflow through client.ExecuteWorkflow, and awaits the result through WorkflowRun.Get.
internal
codegen
Package codegen discovers vihren activity/workflow markers and generates typed Temporal registration and call surfaces from the ADR 20260619 contract.
Package codegen discovers vihren activity/workflow markers and generates typed Temporal registration and call surfaces from the ADR 20260619 contract.
toolschema
Package toolschema contains public support helpers used by the v0.1 command surface.
Package toolschema contains public support helpers used by the v0.1 command surface.
Package toolcontract owns logical tool contracts and shared tool-call result types used by tool catalogs and provider adapters.
Package toolcontract owns logical tool contracts and shared tool-call result types used by tool catalogs and provider adapters.

Jump to

Keyboard shortcuts

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