Help us shape the future of Go! Take the 2026 Go Developer Survey

embedded

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Overview

Package embedded runs the Temporal server in-process inside fallbck-server.

All Temporal services (frontend, internal-frontend, history, matching, worker) bind to a loopback address; nothing here is reachable from outside the host. Agents reach the frontend only through the authenticating gateway on the public port.

Index

Constants

View Source
const (
	DefaultBindIP             = "127.0.0.1"
	DefaultPortBase           = 7233
	DefaultHistoryShards      = 4
	DefaultRetention          = 72 * time.Hour
	DefaultStopTimeout        = 30 * time.Second
	DefaultClusterName        = "fallbck"
	DefaultNamespace          = "default"
	DefaultTemporalDatabase   = "temporal"
	DefaultVisibilityDatabase = "temporal_visibility"
	PostgresPluginName        = "postgres12_pgx"
)

Default values for Config

View Source
const DefaultReadyTimeout = 90 * time.Second

DefaultReadyTimeout bounds how long Start waits for the frontend to answer

Variables

This section is empty.

Functions

func BootstrapSchema

func BootstrapSchema(ctx context.Context, cfg Config, logger *slog.Logger) error

BootstrapSchema creates the Temporal databases if missing and applies the embedded, versioned schema up to the version shipped with the linked server. It is idempotent and safe to run on every start. Creating databases requires the CREATEDB privilege; if that is not available, pre-create the databases and this only applies the schema.

func NewLogger

func NewLogger(l *slog.Logger) tlog.Logger

NewLogger wraps a slog logger for the Temporal server. Temporal is verbose at Info; callers typically pass a logger at Warn level for production.

Types

type Config

type Config struct {
	// BindIP is the loopback address every Temporal service listens on
	BindIP string
	// PortBase is the frontend gRPC port; the other services use PortBase+1..+6 and
	// membership ports PortBase-300+n (7233 → 6933…)
	PortBase int
	// Persistence selects postgres (default) or sqlite (tests)
	Persistence Persistence
	// DatabaseURL is a postgres:// URL; the database in its path is ignored and replaced
	// with TemporalDatabase / VisibilityDatabase
	DatabaseURL string
	// TemporalDatabase and VisibilityDatabase are the two Postgres databases Temporal needs
	TemporalDatabase   string
	VisibilityDatabase string
	// SQLiteFile is the database file for sqlite persistence; empty = in-memory
	SQLiteFile string
	// HistoryShards is immutable after the first start (persisted in cluster metadata)
	HistoryShards int32
	// Namespace is registered on first start with Retention
	Namespace string
	Retention time.Duration
	// ClusterName is immutable after the first start
	ClusterName string
	// DataDir persists the generated cluster ID; empty = random per start (tests)
	DataDir string
	// StopTimeout bounds Stop(): Temporal's own shutdown can wait minutes for system
	// worker long polls to drain; after this the shutdown continues in the background.
	StopTimeout time.Duration
}

Config describes the embedded Temporal deployment

func (Config) FrontendAddr

func (c Config) FrontendAddr() string

FrontendAddr is the loopback address of the public-facing (but loopback-bound) frontend

func (Config) Validate

func (c Config) Validate() error

Validate checks the configuration

type Persistence

type Persistence string

Persistence selects the backing store of the embedded server

const (
	// PersistencePostgres stores Temporal state in PostgreSQL (production)
	PersistencePostgres Persistence = "postgres"
	// PersistenceSQLite stores state in an in-memory or file SQLite database (tests only;
	// requires the `sqlite` build tag)
	PersistenceSQLite Persistence = "sqlite"
)

type Server

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

Server is an in-process Temporal cluster

func New

func New(cfg Config, logger *slog.Logger) (out *Server, err error)

New validates the configuration and constructs the Temporal server (not yet started). For Postgres persistence, BootstrapSchema must have been run first.

func (*Server) FrontendAddr

func (s *Server) FrontendAddr() string

FrontendAddr is the loopback host:port of the frontend gRPC service

func (*Server) Namespace

func (s *Server) Namespace() string

Namespace is the namespace ensured by Start

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts every service, waits until the frontend answers, and ensures the configured namespace exists. ctx bounds the readiness wait (DefaultReadyTimeout if none).

func (*Server) Stop

func (s *Server) Stop() error

Stop shuts the server down, waiting at most cfg.StopTimeout. Temporal's internal shutdown can block for minutes waiting for its own system workers' long polls; once the timeout passes the remaining teardown continues in the background (the process normally exits right after). Safe to call more than once.

Jump to

Keyboard shortcuts

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