docflow

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package docflow connects document to the workflow engine and the action runner: Generate is the handler behind a "document.generate" effect, and Exists is the guard that keeps a case from advancing until a document of a given template exists for it. The document package itself stays independent of both.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(svc *document.Service, templateName string) workflow.GuardFunc

Exists returns a guard that passes only when the case already has a document of templateName, in any template version. Register it with Engine.RegisterGuard and name it on the transition that needs the document. Generation runs in the background, so a step that depends on a document must use this guard instead of assuming it is there.

func Generate

func Generate(svc *document.Service, db pgxtx.DBTX, build BuildFunc) action.Handler

Generate returns the handler for a document-generating effect. Each run generates at most one document: the source key defaults to r.IdempotencyKey() ("<case id>/<event seq>/<effect>", plus "/<part>" when r.Part is not zero, so each part of a split effect gets its own document), so a retried job returns the document a previous attempt stored. Input the document package rejects as invalid, a template that fails to parse or execute, a document the Renderer rejects (document.ErrRenderRejected) and an empty PDF cancel the job, since a retry cannot fix them; every other error, including one from build, is returned so River retries. db is where the metadata row is written, typically the pool. The document's id and sha256 are recorded on the attempt (action.RecordResult), so a Worker with an attempt log ties each attempt to the document it produced or found.

Types

type BuildFunc

type BuildFunc func(ctx context.Context, r action.Run) (document.GenerateInput, error)

BuildFunc returns the template and data for the document a run generates. It may leave Domain, ExternalID, CaseID and SourceKey empty: Generate fills them from the run.

Jump to

Keyboard shortcuts

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