loom

module
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT

README

Latest release Go reference Go version Build status CodeQL status Ask DeepWiki MIT license

Loom

Loom is a design-first Go framework that turns one API definition into service interfaces, HTTP, gRPC, and JSON-RPC transports, type-safe clients, CLIs, and OpenAPI 3.1 contracts.

Quick start · Documentation · Go reference · Ask DeepWiki

Why Loom?

  • Contracts you can build against. Loom emits OpenAPI 3.1.1 using JSON Schema 2020-12. Representative contracts are parsed with libopenapi, linted with Redocly, and compiled through openapi-typescript and oapi-codegen in consumer smoke tests.
  • One design, multiple transports. The same service model drives HTTP, gRPC, and JSON-RPC servers and clients. SSE and WebSocket endpoints publish explicit message and handshake metadata under x-loom-async.
  • Framework-owned API behavior. Validation, authentication, CORS, RFC 9457 problem responses, streaming, and transport observability are modeled once instead of being rebuilt around every handler.
  • Repeatable generation. loom gen stages and validates the complete output before replacing generated files. Humans and coding agents follow the same design → generate → implement workflow.

How it works

You write Loom generates
design/*.go API definitions Service interfaces and endpoint wrappers
Business logic HTTP, gRPC, and JSON-RPC servers and clients
Application wiring and tests Request validation, CLIs, and transport code
Transport policy in the DSL OpenAPI 3.1 and Protocol Buffer definitions

Design files are the source of truth. Generated files live under gen/; your business logic stays in ordinary, non-generated Go files.

Loom and Goa

Loom was derived from Goa and retains its design-first model: describe the service in a Go DSL, generate the transport layer, and implement the resulting service interface.

Loom is intended for teams that specifically need:

  • OpenAPI 3.1 and JSON Schema 2020-12 as a tested machine-facing contract;
  • reusable contract components, request/response schema separation, and explicit async metadata;
  • RFC 9457 HTTP errors and framework-owned session, CORS, streaming, and observability behavior;
  • transactional code generation and compile-time generator extensions.

Goa remains the original project with the larger established community. If Loom's contract and transport guarantees are not requirements, Goa may be the better fit. Loom is actively diverging and does not promise source compatibility with every Goa release.

Quick start

Loom requires the Go version declared in go.mod, currently Go 1.26.1 or later.

Install the CLI and create a module:

go install github.com/CaliLuke/loom/cmd/loom@v1.7.1

mkdir hello && cd hello
go mod init example.com/hello
go get github.com/CaliLuke/loom@latest
mkdir design

Create design/design.go:

package design

import . "github.com/CaliLuke/loom/dsl"

var _ = Service("hello", func() {
	Method("greet", func() {
		Payload(func() {
			Field(1, "name", String, "Name to greet")
			Required("name")
		})
		Result(String)

		HTTP(func() {
			GET("/hello/{name}")
		})
	})
})

Generate the service and starter implementation:

loom gen example.com/hello/design
loom example example.com/hello/design
go mod tidy

In the generated starter file hello.go, replace the Greet method with:

func (s *hellosrvc) Greet(ctx context.Context, p *hello.GreetPayload) (string, error) {
	log.Printf(ctx, "hello.greet")
	return "Hello, " + p.Name + "!", nil
}

Run the service:

go run ./cmd/hello --http-port=8000

Then call it from another terminal:

$ curl http://localhost:8000/hello/Ada
"Hello, Ada!"

The same generation run creates a type-safe client and gen/http/openapi.{json,yaml}. Continue with the guided quickstart or explore the generated-code workflow.

Documentation

Project expectations

Loom is a code-generation framework: adopting it means keeping the design as the source of truth, regenerating after design changes, and committing generated code. If you prefer handwritten transport handlers or a schema-first workflow based on existing OpenAPI or Protocol Buffer files, Loom is probably not the right abstraction.

For releases and project activity, see GitHub Releases and GitHub Issues. Contributions are welcome; start with CONTRIBUTING.md.

License

Loom is available under the MIT License.

Directories

Path Synopsis
clue
log
cmd
loom command
Package codegen contains data structures and algorithms used by the Loom code generation tool.
Package codegen contains data structures and algorithms used by the Loom code generation tool.
cli
Package cli contains helpers used by transport-specific command-line client generators for parsing the command-line flags to identify the service and the method to make a request along with the request payload to be sent.
Package cli contains helpers used by transport-specific command-line client generators for parsing the command-line flags to identify the service and the method to make a request along with the request payload to be sent.
codegentest
Package codegentest provides utilities to assist writing unit test for codegen packages.
Package codegentest provides utilities to assist writing unit test for codegen packages.
example
Package example contains code generation algorithms to produce an example server and client implementation for the transports defined in the design.
Package example contains code generation algorithms to produce an example server and client implementation for the transports defined in the design.
generator
Package generator contains the code generation algorithms for a service server, client, and OpenAPI specification.
Package generator contains the code generation algorithms for a service server, client, and OpenAPI specification.
service
Package service is the base stage of the Loom codegen pipeline.
Package service is the base stage of the Loom codegen pipeline.
template
Package template provides a shared template reader for codegen packages.
Package template provides a shared template reader for codegen packages.
testutil
Package testutil provides testing utilities for the Loom code generation framework.
Package testutil provides testing utilities for the Loom code generation framework.
Package dsl implements the Loom DSL.
Package dsl implements the Loom DSL.
Package eval implements a DSL engine for executing arbitrary Go DSLs.
Package eval implements a DSL engine for executing arbitrary Go DSLs.
Package expr defines expressions and data types used by the DSL and the code generators.
Package expr defines expressions and data types used by the DSL and the code generators.
Package grpc contains code generation logic to produce a server that serves gRPC requests and a client that encode requests to and decode responses from a gRPC server.
Package grpc contains code generation logic to produce a server that serves gRPC requests and a client that encode requests to and decode responses from a gRPC server.
codegen
Package codegen generates gRPC servers, clients, and .proto definitions from an evaluated Loom design.
Package codegen generates gRPC servers, clients, and .proto definitions from an evaluated Loom design.
middleware
Package middleware contains gRPC server and client interceptors that wraps unary and streaming RPCs to provide additional functionality.
Package middleware contains gRPC server and client interceptors that wraps unary and streaming RPCs to provide additional functionality.
middleware/otel
Package otel provides thin OpenTelemetry helpers for Loom gRPC servers and clients.
Package otel provides thin OpenTelemetry helpers for Loom gRPC servers and clients.
pb
Package loompb contains protocol buffer message types used by the code generation logic.
Package loompb contains protocol buffer message types used by the code generation logic.
Package http contains HTTP specific constructs that complement the code generated by Loom.
Package http contains HTTP specific constructs that complement the code generated by Loom.
cli
Package cli contains runtime helpers for generated HTTP command-line clients.
Package cli contains runtime helpers for generated HTTP command-line clients.
codegen
Package codegen generates HTTP servers, clients, and OpenAPI specifications from an evaluated Loom design.
Package codegen generates HTTP servers, clients, and OpenAPI specifications from an evaluated Loom design.
codegen/openapi
Package openapi provides common algorithms and data structures used to generate OpenAPI 3.1 specifications from Loom designs.
Package openapi provides common algorithms and data structures used to generate OpenAPI 3.1 specifications from Loom designs.
codegen/openapi/v3
Package openapiv3 contains the algorithms and data structures used to generate OpenAPI 3.1 specifications from Loom designs.
Package openapiv3 contains the algorithms and data structures used to generate OpenAPI 3.1 specifications from Loom designs.
middleware
Package middleware contains HTTP middlewares that wrap a HTTP handler to provide ancillary functionality such as capturing HTTP details into the request context or printing debug information on incoming requests.
Package middleware contains HTTP middlewares that wrap a HTTP handler to provide ancillary functionality such as capturing HTTP details into the request context or printing debug information on incoming requests.
middleware/otel
Package otel provides thin OpenTelemetry middleware helpers for Loom HTTP servers and clients.
Package otel provides thin OpenTelemetry middleware helpers for Loom HTTP servers and clients.
internal
cmd/loomsource command
Command loomsource manages the worktree-local Loom source used by temporary integration modules.
Command loomsource manages the worktree-local Loom source used by temporary integration modules.
cmd/release command
Command release publishes a verified Loom release.
Command release publishes a verified Loom release.
identifier
Package identifier generates opaque identifiers from checked entropy.
Package identifier generates opaque identifiers from checked entropy.
loomsource
Package loomsource resolves the Loom checkout used by temporary integration modules.
Package loomsource resolves the Loom checkout used by temporary integration modules.
release
Package release implements Loom's transactional release workflow.
Package release implements Loom's transactional release workflow.
Package jsonrpc provides constructs and utilities for building JSON-RPC 2.0 services with Loom.
Package jsonrpc provides constructs and utilities for building JSON-RPC 2.0 services with Loom.
codegen
Package codegen generates JSON-RPC 2.0 servers and clients from an evaluated Loom design.
Package codegen generates JSON-RPC 2.0 servers and clients from an evaluated Loom design.
observability
otel
Package otel provides framework-owned OpenTelemetry bootstrap and transport instrumentation helpers.
Package otel provides framework-owned OpenTelemetry bootstrap and transport instrumentation helpers.
transport
Package transport defines the dependency-free observer contract used by Loom's generated HTTP, JSON-RPC, and Loom-MCP transports.
Package transport defines the dependency-free observer contract used by Loom's generated HTTP, JSON-RPC, and Loom-MCP transports.
Package loom contains the core runtime types and helpers for the Loom framework.
Package loom contains the core runtime types and helpers for the Loom framework.
pool
Package pool keeps its cross-map coordination scripts close to the pool admission code.
Package pool keeps its cross-map coordination scripts close to the pool admission code.
rmap
Package rmap maintains a Redis-backed replicated map whose local state is ordered by monotonic revisions and updated through pubsub notifications.
Package rmap maintains a Redis-backed replicated map whose local state is ordered by monotonic revisions and updated through pubsub notifications.
scripts
docscheck command
Command docscheck validates Loom's maintained Markdown documentation.
Command docscheck validates Loom's maintained Markdown documentation.
Package security contains the types used by the code generators to secure Loom endpoint.
Package security contains the types used by the code generators to secure Loom endpoint.

Jump to

Keyboard shortcuts

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