Documentation
¶
Overview ¶
Package runtime implements haistack-runtime, the composition and lifecycle library for HAIStack. It wires persistence, registry, modules, core, search, sync, and HTTP into three explicit deployment modes and owns startup, background workers, managed HTTP serving, and deterministic shutdown.
haistack-runtime is library-only. It does not ship a CLI or process supervisor. Callers construct a Builder, call Build to open stores and wire services, then Start and Shutdown to manage the runtime lifecycle.
Deployment modes ¶
The effective mode is inferred and validated from builder selections at Build time:
- ModeLocalSQLite — embedded SQLite as the only durable store. External blob, search, and warehouse adapters are rejected.
- ModeEdgePostgresAllInOne — one Postgres tenant for resources, history, search, jobs, modules, audit, blobs, and sync/event stores. Uses internal Postgres-backed stores, not external services.
- ModeCloudPostgresPlusExternalServices — Postgres for canonical resource, history, event, and module state plus explicitly injected external adapters for blob storage, search, and/or analytics warehouses.
One Postgres runtime instance serves one tenant. WithPostgresAllInOne requires a non-empty tenant ID. WithPostgresSchema optionally places hai_* tables and migrations in a non-public schema (for example "fhir").
Builder API ¶
Construct a runtime with the fluent builder:
rt, err := runtime.New().
WithSQLite("/data/haistack.db").
WithSearch().
WithModules("modules/core").
WithHTTP(":8080").
Build(ctx)
Builder methods:
- New — returns a new Builder
- WithSQLite(path) — select embedded SQLite storage
- WithPostgresAllInOne(dsn, tenantID) — select single-tenant Postgres
- WithPostgresSchema(schema) — optional Postgres schema for hai_* tables (default: public)
- WithExternalBlobStore, WithExternalSearch, WithExternalWarehouse — cloud adapter seams
- WithFHIRPath(engine) — optional; a default engine is created when omitted
- WithSDC(service) — optional SDC HTTP operation adapter; the default core/FHIRPath/CQL adapter is used when omitted
- WithSearch — enable search indexing and query execution
- WithSync(hubURL), WithSyncHub(hub), WithSyncNode(nodeID) — device sync
- WithSQLiteTenant, WithSQLiteTerminologyScope — local tenant namespaces
- WithModules(paths...) — install modules from local filesystem directories
- WithHTTP(addr) — optional managed HTTP server listen address
- WithHTTPAuth, WithHTTPMiddleware, WithHTTPRateLimit — managed HTTP policy
- WithModuleAuthorizer — module install/upgrade authorization
- WithModuleVerifier — optional module signature/content verification
- Build(ctx) — open stores, migrate, wire services, return *Runtime
Build validation rules:
- Exactly one storage root: SQLite or Postgres, not both
- Postgres modes require a tenant ID
- local-sqlite rejects external blob/search/warehouse adapters
- cloud mode is selected when Postgres is combined with any external adapter
- Sync requires WithSync hub URL or WithSyncHub
Runtime lifecycle ¶
- Start(ctx) — start background job workers and the managed http.Server when WithHTTP was configured. Cancellation of ctx stops workers; call Shutdown for deterministic resource cleanup. Returns ErrAlreadyStarted on repeats.
- Shutdown(ctx) — stop HTTP, cancel background workers, close adapters and DB connections. Repeated calls are safe.
- Mode, Config, Services, Handler — accessors for embedding and testing
- HTTPAddr — bound listen address after Start when HTTP is configured
- /health and /healthz — liveness probes on the managed HTTP handler
- SyncEngine, ReindexWorker — optional capability accessors
Shutdown order is deterministic:
- Stop HTTP accept loop
- Stop background workers (search reindex and sync job processors)
- Close external adapters implementing CloseableAdapter
- Close database connections last
Build failures roll back partially opened resources via an internal cleanup stack.
Service graph ¶
Build wires the following through ServiceContainer:
- registry.Manager with bundled R4 definitions seeded before module install
- modules.Manager for filesystem module directories (pkg/modules loader)
- fhirpath.Engine for registry-driven search indexing
- core.ResourceService with validator, indexer, and outbox as available
- search.Service when WithSearch is enabled
- subscriptions.Matcher (Engine + Registry) and Processor
- sync.Engine when sync is configured
- FHIR HTTP handler via pkg/http adapters (always built for Handler access)
ServiceContainer fields:
- RegistryManager, RegistrySnapshot, ModuleManager
- ResourceService, SearchService, SyncEngine, FHIRPathEngine
- SubscriptionManager, SubscriptionProcessor, SubscriptionMatcher
- TenantDB (Postgres modes only)
- BlobStore, ExternalSearch, Warehouse (cloud mode adapters)
Search behavior by mode ¶
WithSearch on SQLite enables embedded/basic search wiring using the local SearchStore executor. Advanced registry-driven search and background reindex workers are Postgres-first per pkg/search; reindex jobs run only in Postgres modes when WithSearch is enabled.
Sync behavior by mode ¶
SQLite with sync configured acts as a device node: local outbox, cursor, inbox, resource, and history stores plus a remote hub (HTTP via WithSync or a direct WithSyncHub adapter such as sync.PostgresHub).
Postgres edge mode does not start a device sync engine unless sync is explicitly configured. The runtime owns hub-side stores on Postgres but does not schedule device push unless WithSync or WithSyncHub is set.
Cloud adapter seams ¶
BlobStoreAdapter, ExternalSearchAdapter, and WarehouseAdapter are minimal runtime-facing interfaces for future cloud integrations. Concrete provider implementations live outside pkg/runtime. Adapters need only the methods required for dependency registration and future wiring in this phase. Bulk $export/$import files use the blob adapter's store.BlobStore when it is non-nil; otherwise they use the chunked Postgres blob store or the SQLite blob store. Job status records persist in store.JobStore. Wiring fails if neither an adapter nor a database blob store is available.
Adapters may implement CloseableAdapter to participate in Shutdown.
Background workers ¶
When enabled, the runtime owns one background job loop that polls:
- search.ReindexWorker via jobs.Runner (Postgres + WithSearch)
- sync.JobProcessor for retry push, scheduled pull, conflict, and replay jobs
- subscriptions.Processor for event matching and delivery enqueue
Workers start on Start and stop on Shutdown context cancellation.
Ownership boundaries ¶
haistack-runtime owns composition, mode inference, lifecycle, and the managed HTTP server. It does not own:
- FHIR resource business rules (pkg/core)
- Registry definition ingestion logic (pkg/registry)
- Module manifest parsing (pkg/modules)
- Search query planning and execution (pkg/search)
- Sync protocol details (pkg/sync)
- HTTP routing and OperationOutcome mapping (pkg/http)
- SQL migrations and store implementations (pkg/sqlite, pkg/postgres)
File layout ¶
- doc.go — package documentation
- mode.go — Mode constants
- config.go — normalized Config struct
- builder.go — Builder and mode resolution
- runtime.go — Runtime lifecycle (Build, Start, Shutdown)
- wire.go — store open/migrate and service wiring
- services.go — ServiceContainer
- adapters.go — cloud adapter seams
- sync_hub.go — HTTP hub adapter for WithSync
- indexer_bridge.go — search.Indexer to sync.SearchIndexer bridge
- errors.go — validation and lifecycle errors
Index ¶
- Variables
- type BlobStoreAdapter
- type Builder
- func (b *Builder) Build(ctx context.Context) (*Runtime, error)
- func (b *Builder) WithAnalytics() *Builder
- func (b *Builder) WithAnalyticsConcurrency(max int) *Builder
- func (b *Builder) WithBuiltinOAuth(cfg BuiltinOAuthConfig) *Builder
- func (b *Builder) WithDataDir(dir string) *Builder
- func (b *Builder) WithExternalBlobStore(store BlobStoreAdapter) *Builder
- func (b *Builder) WithExternalSearch(search ExternalSearchAdapter) *Builder
- func (b *Builder) WithExternalWarehouse(warehouse WarehouseAdapter) *Builder
- func (b *Builder) WithFHIRPath(engine fhirpath.Engine) *Builder
- func (b *Builder) WithHTTP(addr string) *Builder
- func (b *Builder) WithHTTPAuth(resolver hahttp.PrincipalResolver, checker hahttp.AuthChecker) *Builder
- func (b *Builder) WithHTTPMiddleware(middleware func(http.Handler) http.Handler) *Builder
- func (b *Builder) WithHTTPRateLimit(config hahttp.RateLimitConfig) *Builder
- func (b *Builder) WithHooks(h hooks.Hooks) *Builder
- func (b *Builder) WithMaxExpansion(max int) *Builder
- func (b *Builder) WithModuleAuthorizer(authorizer modules.InstallAuthorizer) *Builder
- func (b *Builder) WithModuleVerifier(verifier modules.ModuleVerifier) *Builder
- func (b *Builder) WithModules(paths ...string) *Builder
- func (b *Builder) WithPackageInstalls(specs ...packages.InstallSpec) *Builder
- func (b *Builder) WithPostgresAllInOne(dsn, tenantID string) *Builder
- func (b *Builder) WithPostgresReadReplica(dsn string) *Builder
- func (b *Builder) WithPostgresSchema(schema string) *Builder
- func (b *Builder) WithPreExpandValueSets(enabled bool) *Builder
- func (b *Builder) WithRemoteTerminology(baseURL string) *Builder
- func (b *Builder) WithRemoteTerminologyBearerToken(token string) *Builder
- func (b *Builder) WithRemoteTerminologyTranslate(baseURL string) *Builder
- func (b *Builder) WithRemoteTerminologyTranslateAuthorize(fn func(*http.Request) error) *Builder
- func (b *Builder) WithRemoteTerminologyTranslateHeader(key, value string) *Builder
- func (b *Builder) WithSDC(service hahttp.SDCService) *Builder
- func (b *Builder) WithSQLite(path string) *Builder
- func (b *Builder) WithSQLiteTenant(tenantID string) *Builder
- func (b *Builder) WithSQLiteTerminologyScope(scope string) *Builder
- func (b *Builder) WithSearch() *Builder
- func (b *Builder) WithSync(hubURL string) *Builder
- func (b *Builder) WithSyncHub(hub hasync.Hub) *Builder
- func (b *Builder) WithSyncMiddleware(middleware func(http.Handler) http.Handler) *Builder
- func (b *Builder) WithSyncNode(nodeID string) *Builder
- func (b *Builder) WithSyncServer(hub hasync.HubServer) *Builder
- func (b *Builder) WithViewExportDir(dir string) *Builder
- type BuiltinOAuthConfig
- type CloseableAdapter
- type Config
- type ConformanceRefresher
- type ConformanceRuntime
- type ConformanceRuntimeConfig
- type ExternalSearchAdapter
- type Mode
- type ParquetWarehouseAdapter
- type Persistence
- type PostgresReportingWarehouse
- type Runtime
- func (rt *Runtime) BackgroundError() error
- func (rt *Runtime) Config() Config
- func (rt *Runtime) HTTPAddr() net.Addr
- func (rt *Runtime) Handler() http.Handler
- func (rt *Runtime) IsStarted() bool
- func (rt *Runtime) Mode() Mode
- func (rt *Runtime) Persistence() Persistence
- func (rt *Runtime) ReindexWorker() *search.ReindexWorker
- func (rt *Runtime) Services() *ServiceContainer
- func (rt *Runtime) Shutdown(ctx context.Context) error
- func (rt *Runtime) Start(ctx context.Context) error
- func (rt *Runtime) SyncEngine() *hasync.Engine
- type ServiceContainer
- type WarehouseAdapter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoStorage is returned when neither SQLite nor Postgres is configured. ErrNoStorage = errors.New("runtime: exactly one storage backend is required") // ErrConflictingStorage is returned when both SQLite and Postgres are configured. ErrConflictingStorage = errors.New("runtime: SQLite and Postgres cannot both be configured") // ErrMissingTenantID is returned when Postgres is selected without a tenant ID. ErrMissingTenantID = errors.New("runtime: tenant ID is required for Postgres modes") // ErrExternalAdapterInSQLite is returned when external adapters are used with SQLite. ErrExternalAdapterInSQLite = errors.New("runtime: external blob/search/warehouse adapters are not supported in local-sqlite mode") // ErrInvalidModeCombination is returned for unsupported dependency combinations. ErrInvalidModeCombination = errors.New("runtime: invalid mode and dependency combination") // ErrSyncHubRequired is returned when sync is enabled without a hub. ErrSyncHubRequired = errors.New("runtime: sync requires WithSync hub URL or WithSyncHub") // ErrAlreadyStarted is returned when Start is called on a running runtime. ErrAlreadyStarted = errors.New("runtime: already started") // ErrNotStarted is returned when operations require a started runtime. ErrNotStarted = errors.New("runtime: not started") // ErrBackgroundWorker indicates a background worker or managed server failed. ErrBackgroundWorker = errors.New("runtime: background worker failed") )
Functions ¶
This section is empty.
Types ¶
type BlobStoreAdapter ¶
type BlobStoreAdapter interface {
// Name identifies the adapter for logging and capability reporting.
Name() string
// BlobStore returns the blob persistence contract used by binary transfer flows.
BlobStore() store.BlobStore
}
BlobStoreAdapter is the runtime seam for external object storage in cloud mode. Concrete provider implementations live outside pkg/runtime.
func TestNoopBlobStore ¶
func TestNoopBlobStore() BlobStoreAdapter
TestNoopBlobStore returns a minimal BlobStoreAdapter for seam tests.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder composes a runtime from storage backends and optional capabilities.
func (*Builder) WithAnalytics ¶
WithAnalytics enables Postgres reporting-table refresh, CDC-triggered jobs, and view execution wired through pkg/analytics. Requires Postgres storage.
func (*Builder) WithAnalyticsConcurrency ¶
WithAnalyticsConcurrency limits concurrent analytics refresh jobs to protect OLTP. Defaults to 1 when analytics is enabled and this is not set.
func (*Builder) WithBuiltinOAuth ¶
func (b *Builder) WithBuiltinOAuth(cfg BuiltinOAuthConfig) *Builder
WithBuiltinOAuth enables the built-in SMART OAuth authorization server.
func (*Builder) WithDataDir ¶
WithDataDir sets the absolute runtime data directory for view export artifacts and job metadata.
func (*Builder) WithExternalBlobStore ¶
func (b *Builder) WithExternalBlobStore(store BlobStoreAdapter) *Builder
WithExternalBlobStore registers an external blob store adapter for cloud mode.
func (*Builder) WithExternalSearch ¶
func (b *Builder) WithExternalSearch(search ExternalSearchAdapter) *Builder
WithExternalSearch registers an external search adapter for cloud mode.
func (*Builder) WithExternalWarehouse ¶
func (b *Builder) WithExternalWarehouse(warehouse WarehouseAdapter) *Builder
WithExternalWarehouse registers an external warehouse adapter for cloud mode.
func (*Builder) WithFHIRPath ¶
WithFHIRPath supplies a FHIRPath engine; when omitted, one is created at build time.
func (*Builder) WithHTTP ¶
WithHTTP sets the listen address for a managed HTTP server started by Runtime.Start.
func (*Builder) WithHTTPAuth ¶
func (b *Builder) WithHTTPAuth(resolver hahttp.PrincipalResolver, checker hahttp.AuthChecker) *Builder
WithHTTPAuth configures the built-in principal extraction and authorization middleware for the managed FHIR handler.
func (*Builder) WithHTTPMiddleware ¶
WithHTTPMiddleware wraps the managed FHIR handler with application middleware such as authentication, tracing, or request policy.
func (*Builder) WithHTTPRateLimit ¶
func (b *Builder) WithHTTPRateLimit(config hahttp.RateLimitConfig) *Builder
WithHTTPRateLimit enables process-local request limiting for the managed FHIR handler.
func (*Builder) WithHooks ¶
WithHooks registers the four-point intercept SPI on both core writes and the FHIR HTTP handler. The same registry should be used for incoming, pre-storage, post-commit, and outgoing callbacks.
func (*Builder) WithMaxExpansion ¶
WithMaxExpansion sets the maximum ValueSet expansion size for terminology services and pre-expand workers. Zero uses the default of 10000.
func (*Builder) WithModuleAuthorizer ¶
func (b *Builder) WithModuleAuthorizer(authorizer modules.InstallAuthorizer) *Builder
WithModuleAuthorizer configures authorization for module install and upgrade operations performed during Build and through the runtime module manager.
func (*Builder) WithModuleVerifier ¶
func (b *Builder) WithModuleVerifier(verifier modules.ModuleVerifier) *Builder
WithModuleVerifier configures cryptographic or policy verification for modules before install and upgrade. Unsigned modules remain supported when no verifier is configured.
func (*Builder) WithModules ¶
WithModules installs modules from local filesystem directories at build time.
func (*Builder) WithPackageInstalls ¶
func (b *Builder) WithPackageInstalls(specs ...packages.InstallSpec) *Builder
WithPackageInstalls installs FHIR NPM packages or local IG directories at build time. Already-installed package versions are skipped idempotently.
func (*Builder) WithPostgresAllInOne ¶
WithPostgresAllInOne selects a single-tenant Postgres deployment.
func (*Builder) WithPostgresReadReplica ¶
WithPostgresReadReplica configures a read-only Postgres DSN for analytics view scans.
func (*Builder) WithPostgresSchema ¶
WithPostgresSchema sets the Postgres schema for hai_* tables and migrations. When empty, postgres.Open uses the default public schema.
func (*Builder) WithPreExpandValueSets ¶
WithPreExpandValueSets enqueues async ValueSet pre-expansion jobs when IG packages install finite global ValueSets.
func (*Builder) WithRemoteTerminology ¶
WithRemoteTerminology configures an optional remote FHIR terminology server (for example https://tx.fhir.org/r4) as the final provider in the chain.
func (*Builder) WithRemoteTerminologyBearerToken ¶
WithRemoteTerminologyBearerToken sets a Bearer token for remote ConceptMap/$translate.
func (*Builder) WithRemoteTerminologyTranslate ¶
WithRemoteTerminologyTranslate sets a FHIR server base URL used for ConceptMap/$translate when local ConceptMaps are unavailable. It is an alias for WithRemoteTerminology.
func (*Builder) WithRemoteTerminologyTranslateAuthorize ¶
WithRemoteTerminologyTranslateAuthorize sets per-request auth for remote ConceptMap/$translate.
func (*Builder) WithRemoteTerminologyTranslateHeader ¶
WithRemoteTerminologyTranslateHeader adds a static request header for remote ConceptMap/$translate.
func (*Builder) WithSDC ¶
func (b *Builder) WithSDC(service hahttp.SDCService) *Builder
WithSDC supplies the HTTP SDC operation adapter. When omitted, runtime wires the default core/FHIRPath adapter; applications can inject extractors, terminology, and adaptive session policy through this seam.
func (*Builder) WithSQLite ¶
WithSQLite selects embedded SQLite at the given database path.
func (*Builder) WithSQLiteTenant ¶
WithSQLiteTenant sets the tenant namespace used by local sync and terminology persistence. It defaults to "local".
func (*Builder) WithSQLiteTerminologyScope ¶
WithSQLiteTerminologyScope sets the terminology namespace used by SQLite. It defaults to "default".
func (*Builder) WithSearch ¶
WithSearch enables search indexing and query execution. On SQLite this wires embedded/basic search; advanced search remains Postgres-first.
func (*Builder) WithSyncHub ¶
WithSyncHub enables device sync using a pre-built hub adapter.
func (*Builder) WithSyncMiddleware ¶
WithSyncMiddleware applies authentication and authorization to the runtime's /sync routes. It should bind the authenticated node and tenant to the request before the scoped hub is invoked.
func (*Builder) WithSyncNode ¶
WithSyncNode sets the device node ID used by the sync engine. When omitted, a default node ID is assigned at build time.
func (*Builder) WithSyncServer ¶
WithSyncServer exposes /sync/push and /sync/pull on the HTTP server.
func (*Builder) WithViewExportDir ¶
WithViewExportDir sets the filesystem directory for ViewDefinition export artifacts. When unset, SQLite runtimes use {db-dir}/view-exports and Postgres runtimes use view-exports/{tenantId}.
type BuiltinOAuthConfig ¶
type BuiltinOAuthConfig struct {
Production bool
RegistrationAccessToken string
AutoApprove *bool
IssuerURL string
TenantID string
StateDir string
}
BuiltinOAuthConfig enables the built-in pkg/oauth authorization server during runtime wire. IssuerURL defaults to http://{HTTPAddr} when empty.
type CloseableAdapter ¶
CloseableAdapter may be implemented by external adapters that hold connections.
type Config ¶
type Config struct {
Mode Mode
// Storage
SQLitePath string
SQLiteTenantID string
SQLiteTerminologyScope string
PostgresDSN string
PostgresSchema string // empty means the default public schema
TenantID string
// Capabilities
SearchEnabled bool
ModulePaths []string
HTTPAddr string
// Sync
SyncEnabled bool
SyncHubURL string
SyncNodeID string
// OAuth (builtin authorization server)
OAuthEnabled bool
OAuthIssuer string
}
Config is the normalized runtime configuration produced by Builder.Build.
type ConformanceRefresher ¶
ConformanceRefresher rebuilds the live registry snapshot, validation catalog, and related conformance consumers after IG or terminology installs.
func NewConformanceRefresher ¶
func NewConformanceRefresher(runtime *ConformanceRuntime, onDone func()) ConformanceRefresher
NewConformanceRefresher adapts ConformanceRuntime to ConformanceRefresher.
type ConformanceRuntime ¶
type ConformanceRuntime struct {
// contains filtered or unexported fields
}
ConformanceRuntime holds the live registry snapshot and validation state used by HTTP handlers and resource validation. Call Refresh after catalog changes.
func NewConformanceRuntime ¶
func NewConformanceRuntime(cfg ConformanceRuntimeConfig) (*ConformanceRuntime, error)
NewConformanceRuntime builds a runtime view from an initial compiled snapshot.
func (*ConformanceRuntime) Engine ¶
func (r *ConformanceRuntime) Engine() validate.Engine
Engine returns the current validation engine.
func (*ConformanceRuntime) ProfileCatalog ¶
func (r *ConformanceRuntime) ProfileCatalog() *validate.RegistryProfileCatalog
ProfileCatalog returns the live profile catalog.
func (*ConformanceRuntime) Refresh ¶
Refresh rebuilds the compiled snapshot and reloads validation consumers.
func (*ConformanceRuntime) Snapshot ¶
func (r *ConformanceRuntime) Snapshot() *registry.Snapshot
Snapshot returns the current compiled registry view.
type ConformanceRuntimeConfig ¶
type ConformanceRuntimeConfig struct {
Manager *registry.Manager
FHIRPath fhirpath.Engine
ProfileCatalog *validate.RegistryProfileCatalog
Engine *validate.ReloadableEngine
SearchRegistry *search.SnapshotRegistry
PatientResolver *registry.PatientReferenceResolver
InitialSnapshot *registry.Snapshot
}
ConformanceRuntimeConfig wires a conformance runtime from registry state.
type ExternalSearchAdapter ¶
type ExternalSearchAdapter interface {
// Name identifies the adapter for logging and capability reporting.
Name() string
// SearchExecutor returns the query executor when search is delegated externally.
SearchExecutor() store.SearchQueryExecutor
}
ExternalSearchAdapter is the runtime seam for external search services in cloud mode.
func TestNoopExternalSearch ¶
func TestNoopExternalSearch() ExternalSearchAdapter
TestNoopExternalSearch returns a minimal ExternalSearchAdapter for seam tests.
type Mode ¶
type Mode string
Mode identifies the effective runtime deployment shape inferred from builder selections.
const ( // ModeLocalSQLite uses embedded SQLite as the only durable store. ModeLocalSQLite Mode = "local-sqlite" // ModeEdgePostgresAllInOne uses one Postgres tenant for resources, history, // search, jobs, modules, audit, blobs, and sync/event stores. ModeEdgePostgresAllInOne Mode = "edge-postgres-all-in-one" // ModeCloudPostgresPlusExternalServices uses Postgres for canonical resource, // history, event, and module state with explicit external service adapters. ModeCloudPostgresPlusExternalServices Mode = "cloud-postgres-plus-external-services" )
type ParquetWarehouseAdapter ¶
type ParquetWarehouseAdapter struct {
Name_ string
Sink func() store.ReportingTableStore
}
ParquetWarehouseAdapter routes analytics export rows to object storage as Apache Parquet.
func (ParquetWarehouseAdapter) Name ¶
func (w ParquetWarehouseAdapter) Name() string
func (ParquetWarehouseAdapter) ReportingTables ¶
func (w ParquetWarehouseAdapter) ReportingTables() store.ReportingTableStore
type Persistence ¶
Persistence exposes narrow read-oriented access to underlying storage handles. It is intended for operator tooling such as the haistack CLI.
type PostgresReportingWarehouse ¶
type PostgresReportingWarehouse struct {
Store store.ReportingTableStore
Name_ string
}
PostgresReportingWarehouse wraps a Postgres reporting table store for edge/cloud wiring.
func (PostgresReportingWarehouse) Name ¶
func (w PostgresReportingWarehouse) Name() string
func (PostgresReportingWarehouse) ReportingTables ¶
func (w PostgresReportingWarehouse) ReportingTables() store.ReportingTableStore
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns composed services, optional HTTP serving, and background workers.
func (*Runtime) BackgroundError ¶
BackgroundError returns the first background worker or managed server error observed.
func (*Runtime) HTTPAddr ¶
HTTPAddr returns the bound listen address after Start when HTTP is configured.
func (*Runtime) IsStarted ¶
IsStarted reports whether the managed runtime has completed startup and is accepting requests. It is used by the readiness probe.
func (*Runtime) Persistence ¶
func (rt *Runtime) Persistence() Persistence
Persistence returns the wired persistence backends for the runtime, if any.
func (*Runtime) ReindexWorker ¶
func (rt *Runtime) ReindexWorker() *search.ReindexWorker
ReindexWorker returns the configured search reindex worker, if any.
func (*Runtime) Services ¶
func (rt *Runtime) Services() *ServiceContainer
Services exposes the wired service graph.
func (*Runtime) Shutdown ¶
Shutdown stops HTTP serving, background workers, and closes persistence backends. Repeated calls are safe.
func (*Runtime) Start ¶
Start begins background workers and the managed HTTP server when configured.
func (*Runtime) SyncEngine ¶
SyncEngine returns the configured sync engine, if any.
type ServiceContainer ¶
type ServiceContainer struct {
RegistryManager *registry.Manager
RegistrySnapshot *registry.Snapshot
ConformanceRuntime *ConformanceRuntime
ModuleManager *modules.Manager
ResourceService *core.ResourceService
SearchService *search.Service
SyncEngine *hasync.Engine
FHIRPathEngine fhirpath.Engine
TerminologyService terminology.Service
// TenantDB is set for Postgres modes.
TenantDB *postgres.TenantDB
// External adapters are populated in cloud mode when configured.
BlobStore BlobStoreAdapter
ExternalSearch ExternalSearchAdapter
Warehouse WarehouseAdapter
// BulkExportService handles FHIR Bulk Data export when job infrastructure is wired.
BulkExportService *export.Service
// BulkImportService handles FHIR Bulk Data import when job infrastructure is wired.
BulkImportService *bulkimport.Service
// AnalyticsRunner executes ViewDefinitions when analytics is enabled.
AnalyticsRunner *analytics.Runner
// ViewRegistry holds registered ViewDefinitions for analytics execution.
ViewRegistry *view.Registry
// ViewExecutor runs registered ViewDefinitions.
ViewExecutor *view.Executor
// MaterializeService handles ViewDefinition/$materialize operations.
MaterializeService *view.MaterializeService
// ViewRunService handles ViewDefinition/$viewdefinition-run operations.
ViewRunService *view.RunService
// SQLQueryService handles Library/$sqlquery-run operations.
SQLQueryService *view.SQLQueryService
// ViewExportService handles ViewDefinition/$viewdefinition-export operations.
ViewExportService *view.ExportService
// AnalyticsCDC consumes outbox events and schedules refresh jobs.
AnalyticsCDC *analytics.CDCProcessor
// SubscriptionManager registers and updates subscription records.
SubscriptionManager *subscriptions.Manager
// SubscriptionProcessor consumes resource events and enqueues deliveries.
SubscriptionProcessor *subscriptions.Processor
// SubscriptionMatcher evaluates triggers; Engine and Registry are always set.
SubscriptionMatcher *subscriptions.Matcher
// SubscriptionHandlers is the in-process local delivery handler registry.
SubscriptionHandlers *subscriptions.HandlerRegistry
}
ServiceContainer exposes the wired service graph for embedding and testing.
type WarehouseAdapter ¶
type WarehouseAdapter interface {
// Name identifies the adapter for logging and capability reporting.
Name() string
// ReportingTables returns the reporting table contract for analytics refresh flows.
ReportingTables() store.ReportingTableStore
}
WarehouseAdapter is the runtime seam for external analytics/reporting warehouses in cloud mode.
func TestNoopWarehouse ¶
func TestNoopWarehouse() WarehouseAdapter
TestNoopWarehouse returns a minimal WarehouseAdapter for seam tests.