embed

package module
v0.0.0-...-f679d5a Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 24 Imported by: 0

README

hatchet-embedded

Run a full Hatchet engine (migrations, API, and gRPC) in-process from your Go program. It starts the engine, seeds an admin tenant, and hands the Go SDK a client wired to the embedded instance.

By default it also spins up its own Postgres using fergusstrange/embedded-postgres, so you need zero external services to get running. Pass WithPostgres(url) to point at your own database instead — that disables the embedded Postgres.

Install

go get github.com/hatchet-dev/hatchet-embedded

Usage

The package registers itself with the Go SDK via a blank import. Import it for side effects alongside the SDK; the SDK detects the embedded config and boots the engine on NewClient:

import (
	hatchet "github.com/hatchet-dev/hatchet/sdks/go"
	_ "github.com/hatchet-dev/hatchet-embedded"
)

client, err := hatchet.NewClient(hatchet.WithEmbedded())

Options

Start also accepts functional options directly when you drive the engine yourself:

Option Effect
WithPostgres(url) Use your own Postgres instead of the embedded one
WithRabbitMQ(url) Use RabbitMQ instead of the Postgres message queue
WithAdminUser(email, password) Seed a specific admin user
WithKeysets(master, privateJWT, publicJWT) Supply encryption keysets instead of generating them
WithAPIPort(port) / WithGRPCPort(port) Bind the API / gRPC servers to specific ports
WithoutAPI() Start only the engine + gRPC, no REST API
WithoutMigrations() Skip running migrations on startup
WithLogLevel(level) Engine log level (default warn)

License

MIT — see LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

func Start

func Start(ctx context.Context, opts ...Option) (*Instance, error)

func (*Instance) APIURL

func (i *Instance) APIURL() string

func (*Instance) Client

func (i *Instance) Client() *hatchet.Client

func (*Instance) GRPCAddress

func (i *Instance) GRPCAddress() string

func (*Instance) Shutdown

func (i *Instance) Shutdown(ctx context.Context) error

func (*Instance) TenantID

func (i *Instance) TenantID() string

func (*Instance) Token

func (i *Instance) Token() string

type Option

type Option func(*Config)

func WithAPIPort

func WithAPIPort(port int) Option

func WithAdminUser

func WithAdminUser(email, password string) Option

func WithGRPCPort

func WithGRPCPort(port int) Option

func WithKeysets

func WithKeysets(master, privateJWT, publicJWT []byte) Option

func WithLogLevel

func WithLogLevel(level string) Option

func WithLogger

func WithLogger(l *zerolog.Logger) Option

WithLogger routes embed's logging (and the bundled Postgres output) through a caller-supplied logger instead of the default one derived from the log level.

func WithPostgres

func WithPostgres(url string) Option

func WithRabbitMQ

func WithRabbitMQ(url string) Option

func WithoutAPI

func WithoutAPI() Option

func WithoutMigrations

func WithoutMigrations() Option

Directories

Path Synopsis
examples
basic command
trigger command
worker command

Jump to

Keyboard shortcuts

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