creditflowapi

package
v1.41.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Description = `CreditFlow is an example microservice that demonstrates agentic workflow features.`

Description is the human-readable summary of the microservice, surfaced in OpenAPI and discovery.

View Source
const Hostname = "creditflow.example"

Hostname is the default hostname of the microservice.

View Source
const Name = "CreditFlow"

Name is the decorative PascalCase name of the microservice.

View Source
const Version = 7

Version is a generation counter bumped on each regeneration, not a semantic version.

Variables

View Source
var CreditApproval = define.Workflow{
	Host: Hostname, Method: "GET", Route: ":428/credit-approval",
	In: CreditApprovalIn{}, Out: CreditApprovalOut{},
}

CreditApproval defines the workflow graph for the full credit approval process.

View Source
var Decision = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/decision",
	In: DecisionIn{}, Out: DecisionOut{},
}

Decision determines whether to approve the credit application based on verification results.

View Source
var Demo = define.Web{
	Host: Hostname, Method: "ANY", Route: "/demo",
}

Demo serves the demo page for the credit approval workflow.

View Source
var HandleCreditError = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/handle-credit-error",
	In: HandleCreditErrorIn{}, Out: HandleCreditErrorOut{},
}

HandleCreditError handles a credit verification error by setting creditVerified to false.

View Source
var IdentityDecision = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/identity-decision",
	In: IdentityDecisionIn{}, Out: IdentityDecisionOut{},
}

IdentityDecision determines whether the applicant's identity is verified based on SSN, address, and phone checks.

View Source
var IdentityVerification = define.Workflow{
	Host: Hostname, Method: "GET", Route: ":428/identity-verification",
	In: IdentityVerificationIn{}, Out: IdentityVerificationOut{},
}

IdentityVerification defines the workflow graph for the identity verification process.

View Source
var InitIdentityVerification = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/init-identity-verification",
	In: InitIdentityVerificationIn{}, Out: InitIdentityVerificationOut{},
}

InitIdentityVerification is the entry point for the identity verification subgraph.

View Source
var RequestMoreInfo = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/request-more-info",
	In: RequestMoreInfoIn{}, Out: RequestMoreInfoOut{},
}

RequestMoreInfo requests additional information for the credit review and increments the review attempt counter.

View Source
var ReviewCredit = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/review-credit",
	In: ReviewCreditIn{}, Out: ReviewCreditOut{},
}

ReviewCredit performs a manual review of borderline credit scores.

View Source
var RunIdentityVerification = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/run-identity-verification",
	In: RunIdentityVerificationIn{}, Out: RunIdentityVerificationOut{},
}

RunIdentityVerification invokes the IdentityVerification subgraph via flow.Subgraph and adopts identityVerified.

View Source
var SubmitCreditApplication = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/submit-credit-application",
	In: SubmitCreditApplicationIn{}, Out: SubmitCreditApplicationOut{},
}

SubmitCreditApplication receives a credit application and sets up the workflow state.

View Source
var VerifyAddress = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/verify-address",
	In: VerifyAddressIn{}, Out: VerifyAddressOut{},
}

VerifyAddress checks the applicant's address.

View Source
var VerifyCredit = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/verify-credit",
	In: VerifyCreditIn{}, Out: VerifyCreditOut{},
}

VerifyCredit checks the applicant's credit score.

View Source
var VerifyEmployment = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/verify-employment",
	In: VerifyEmploymentIn{}, Out: VerifyEmploymentOut{},
}

VerifyEmployment checks the applicant's employment status.

View Source
var VerifyPhoneNumber = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/verify-phone-number",
	TimeBudget: time.Second,
	In:         VerifyPhoneNumberIn{}, Out: VerifyPhoneNumberOut{},
}

VerifyPhoneNumber checks the applicant's phone number.

View Source
var VerifySSN = define.Task{
	Host: Hostname, Method: "POST", Route: ":428/verify-ssn",
	In: VerifySSNIn{}, Out: VerifySSNOut{},
}

VerifySSN checks the applicant's SSN.

Functions

This section is empty.

Types

type Applicant

type Applicant struct {
	ApplicantName string   `json:"applicantName,omitzero"`
	SSN           string   `json:"ssn,omitzero"`
	Address       string   `json:"address,omitzero"`
	Phone         string   `json:"phone,omitzero"`
	Employers     []string `json:"employers,omitzero"`
	CreditScore   int      `json:"creditScore,omitzero"`
}

Applicant contains the input data for a credit application.

type Client

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

Client is a lightweight proxy for making unicast calls to the microservice.

func NewClient

func NewClient(caller service.Publisher) Client

NewClient creates a new unicast client proxy to the microservice.

func (Client) Demo

func (_c Client) Demo(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)

Demo serves the demo page for the credit approval workflow.

func (Client) ForHost

func (_c Client) ForHost(host string) Client

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (Client) WithOptions

func (_c Client) WithOptions(opts ...pub.Option) Client

WithOptions returns a copy of the client with options to be applied to requests.

type CreditApprovalIn

type CreditApprovalIn struct {
	Applicant Applicant `json:"applicant,omitzero"`
}

CreditApprovalIn are the input arguments of CreditApproval.

type CreditApprovalOut

type CreditApprovalOut struct {
	Approved           bool `json:"approved,omitzero"`
	CreditVerified     bool `json:"creditVerified,omitzero"`
	EmploymentFailures int  `json:"employmentFailures,omitzero"`
	IdentityVerified   bool `json:"identityVerified,omitzero"`
}

CreditApprovalOut are the output arguments of CreditApproval.

type DecisionIn

type DecisionIn struct {
	CreditVerified     bool `json:"creditVerified,omitzero"`
	EmploymentFailures int  `json:"employmentFailures,omitzero"`
	IdentityVerified   bool `json:"identityVerified,omitzero"`
}

DecisionIn are the input arguments of Decision.

type DecisionOut

type DecisionOut struct {
	Approved bool `json:"approved,omitzero"`
}

DecisionOut are the output arguments of Decision.

type Executor

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

Executor runs tasks and workflows synchronously, blocking until termination. It is primarily intended for integration tests.

func NewExecutor

func NewExecutor(caller service.Publisher) Executor

NewExecutor creates a new executor proxy to the microservice.

func (Executor) CreditApproval

func (_c Executor) CreditApproval(ctx context.Context, applicant Applicant) (approved bool, creditVerified bool, employmentFailures int, identityVerified bool, status string, err error)

CreditApproval defines the workflow graph for the full credit approval process.

func (Executor) Decision

func (_c Executor) Decision(ctx context.Context, creditVerified bool, employmentFailures int, identityVerified bool) (approved bool, err error)

Decision determines whether to approve the credit application based on verification results.

func (Executor) ForHost

func (_c Executor) ForHost(host string) Executor

ForHost returns a copy of the executor with a different hostname to be applied to requests.

func (Executor) HandleCreditError

func (_c Executor) HandleCreditError(ctx context.Context, onErr *errors.TracedError) (creditVerified bool, err error)

HandleCreditError handles a credit verification error by setting creditVerified to false.

func (Executor) IdentityDecision

func (_c Executor) IdentityDecision(ctx context.Context, ssnVerified bool, addressVerified bool, phoneVerified bool) (identityVerified bool, err error)

IdentityDecision determines whether the applicant's identity is verified based on SSN, address, and phone checks.

func (Executor) IdentityVerification

func (_c Executor) IdentityVerification(ctx context.Context, applicantName string, ssn string, address string, phone string) (identityVerified bool, status string, err error)

IdentityVerification defines the workflow graph for the identity verification process.

func (Executor) InitIdentityVerification

func (_c Executor) InitIdentityVerification(ctx context.Context, applicantName string, ssn string, address string, phone string) (err error)

InitIdentityVerification is the entry point for the identity verification subgraph.

func (Executor) RequestMoreInfo

func (_c Executor) RequestMoreInfo(ctx context.Context, reviewAttempts int) (reviewAttemptsOut int, err error)

RequestMoreInfo requests additional information for the credit review and increments the review attempt counter.

func (Executor) ReviewCredit

func (_c Executor) ReviewCredit(ctx context.Context, creditScore int, creditVerified bool, reviewAttempts int) (creditVerifiedOut bool, err error)

ReviewCredit performs a manual review of borderline credit scores.

func (Executor) RunIdentityVerification added in v1.41.0

func (_c Executor) RunIdentityVerification(ctx context.Context, applicantName string, ssn string, address string, phone string) (identityVerified bool, err error)

RunIdentityVerification invokes the IdentityVerification subgraph via flow.Subgraph and adopts identityVerified.

func (Executor) SubmitCreditApplication

func (_c Executor) SubmitCreditApplication(ctx context.Context, applicant Applicant) (applicantName string, ssn string, address string, phone string, employers []string, creditScore int, err error)

SubmitCreditApplication receives a credit application and sets up the workflow state.

func (Executor) VerifyAddress

func (_c Executor) VerifyAddress(ctx context.Context, address string) (addressVerified bool, err error)

VerifyAddress checks the applicant's address.

func (Executor) VerifyCredit

func (_c Executor) VerifyCredit(ctx context.Context, creditScore int) (creditVerified bool, err error)

VerifyCredit checks the applicant's credit score.

func (Executor) VerifyEmployment

func (_c Executor) VerifyEmployment(ctx context.Context, applicantName string, employerName string) (employmentFailuresOut int, err error)

VerifyEmployment checks the applicant's employment status.

func (Executor) VerifyPhoneNumber

func (_c Executor) VerifyPhoneNumber(ctx context.Context, phone string) (phoneVerified bool, err error)

VerifyPhoneNumber checks the applicant's phone number.

func (Executor) VerifySSN

func (_c Executor) VerifySSN(ctx context.Context, ssn string) (ssnVerified bool, err error)

VerifySSN checks the applicant's SSN.

func (Executor) WithFlowOptions added in v1.32.0

func (_c Executor) WithFlowOptions(flowOptions *workflow.FlowOptions) Executor

WithFlowOptions returns a copy of the executor that creates workflows with the given flow options (priority, fairness key and weight). It has no effect on task execution.

func (Executor) WithInputFlow

func (_c Executor) WithInputFlow(flow *workflow.Flow) Executor

WithInputFlow returns a copy of the executor with an input flow to use for task execution. The input flow's state is available to the task in addition to the typed input arguments.

func (Executor) WithOptions

func (_c Executor) WithOptions(opts ...pub.Option) Executor

WithOptions returns a copy of the executor with options to be applied to requests.

func (Executor) WithOutputFlow

func (_c Executor) WithOutputFlow(flow *workflow.Flow) Executor

WithOutputFlow returns a copy of the executor with an output flow to populate after task execution. The output flow captures the full flow state including control signals (Goto, Retry, Interrupt, Sleep).

func (Executor) WithWorkflowRunner

func (_c Executor) WithWorkflowRunner(runner WorkflowRunner) Executor

WithWorkflowRunner returns a copy of the executor with a workflow runner for executing workflows. foremanapi.NewClient(svc) satisfies the WorkflowRunner interface.

type HandleCreditErrorIn

type HandleCreditErrorIn struct {
	OnErr *errors.TracedError `json:"onErr,omitzero"`
}

HandleCreditErrorIn are the input arguments of HandleCreditError.

type HandleCreditErrorOut

type HandleCreditErrorOut struct {
	CreditVerified bool `json:"creditVerified,omitzero"`
}

HandleCreditErrorOut are the output arguments of HandleCreditError.

type IdentityDecisionIn

type IdentityDecisionIn struct {
	SsnVerified     bool `json:"ssnVerified,omitzero"`
	AddressVerified bool `json:"addressVerified,omitzero"`
	PhoneVerified   bool `json:"phoneVerified,omitzero"`
}

IdentityDecisionIn are the input arguments of IdentityDecision.

type IdentityDecisionOut

type IdentityDecisionOut struct {
	IdentityVerified bool `json:"identityVerified,omitzero"`
}

IdentityDecisionOut are the output arguments of IdentityDecision.

type IdentityVerificationIn

type IdentityVerificationIn struct {
	ApplicantName string `json:"applicantName,omitzero"`
	SSN           string `json:"ssn,omitzero"`
	Address       string `json:"address,omitzero"`
	Phone         string `json:"phone,omitzero"`
}

IdentityVerificationIn are the input arguments of IdentityVerification.

type IdentityVerificationOut

type IdentityVerificationOut struct {
	IdentityVerified bool `json:"identityVerified,omitzero"`
}

IdentityVerificationOut are the output arguments of IdentityVerification.

type InitIdentityVerificationIn

type InitIdentityVerificationIn struct {
	ApplicantName string `json:"applicantName,omitzero"`
	SSN           string `json:"ssn,omitzero"`
	Address       string `json:"address,omitzero"`
	Phone         string `json:"phone,omitzero"`
}

InitIdentityVerificationIn are the input arguments of InitIdentityVerification.

type InitIdentityVerificationOut

type InitIdentityVerificationOut struct {
}

InitIdentityVerificationOut are the output arguments of InitIdentityVerification.

type MulticastClient

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

MulticastClient is a lightweight proxy for making multicast calls to the microservice.

func NewMulticastClient

func NewMulticastClient(caller service.Publisher) MulticastClient

NewMulticastClient creates a new multicast client proxy to the microservice.

func (MulticastClient) Demo

func (_c MulticastClient) Demo(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]

Demo serves the demo page for the credit approval workflow.

func (MulticastClient) ForHost

func (_c MulticastClient) ForHost(host string) MulticastClient

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (MulticastClient) WithOptions

func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient

WithOptions returns a copy of the client with options to be applied to requests.

type RequestMoreInfoIn

type RequestMoreInfoIn struct {
	ReviewAttempts int `json:"reviewAttempts,omitzero"`
}

RequestMoreInfoIn are the input arguments of RequestMoreInfo.

type RequestMoreInfoOut

type RequestMoreInfoOut struct {
	ReviewAttemptsOut int `json:"reviewAttempts,omitzero"`
}

RequestMoreInfoOut are the output arguments of RequestMoreInfo.

type ReviewCreditIn

type ReviewCreditIn struct {
	CreditScore    int  `json:"creditScore,omitzero"`
	CreditVerified bool `json:"creditVerified,omitzero"`
	ReviewAttempts int  `json:"reviewAttempts,omitzero"`
}

ReviewCreditIn are the input arguments of ReviewCredit.

type ReviewCreditOut

type ReviewCreditOut struct {
	CreditVerifiedOut bool `json:"creditVerified,omitzero"`
}

ReviewCreditOut are the output arguments of ReviewCredit.

type RunIdentityVerificationIn added in v1.37.0

type RunIdentityVerificationIn struct {
	ApplicantName string `json:"applicantName,omitzero"`
	SSN           string `json:"ssn,omitzero"`
	Address       string `json:"address,omitzero"`
	Phone         string `json:"phone,omitzero"`
}

RunIdentityVerificationIn are the input arguments of RunIdentityVerification.

type RunIdentityVerificationOut added in v1.37.0

type RunIdentityVerificationOut struct {
	IdentityVerified bool `json:"identityVerified,omitzero"`
}

RunIdentityVerificationOut are the output arguments of RunIdentityVerification.

type Subflow added in v1.40.0

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

Subflow runs this microservice's tasks and workflows as isolated child flows from INSIDE a task body. Unlike Executor (which carries a service.Publisher and is for tests), Subflow carries the calling task's *workflow.Flow: each method parks the calling step and re-enters it when the child terminates, returning (..., yield bool, err error).

func NewSubflow added in v1.40.0

func NewSubflow(flow *workflow.Flow) Subflow

NewSubflow creates a subflow client bound to the calling task's flow carrier.

func (Subflow) CreditApproval added in v1.40.0

func (_sf Subflow) CreditApproval(ctx context.Context, applicant Applicant) (approved bool, creditVerified bool, employmentFailures int, identityVerified bool, yield bool, err error)

CreditApproval defines the workflow graph for the full credit approval process.

func (Subflow) Decision added in v1.40.0

func (_sf Subflow) Decision(ctx context.Context, creditVerified bool, employmentFailures int, identityVerified bool) (approved bool, yield bool, err error)

Decision determines whether to approve the credit application based on verification results.

func (Subflow) HandleCreditError added in v1.40.0

func (_sf Subflow) HandleCreditError(ctx context.Context, onErr *errors.TracedError) (creditVerified bool, yield bool, err error)

HandleCreditError handles a credit verification error by setting creditVerified to false.

func (Subflow) IdentityDecision added in v1.40.0

func (_sf Subflow) IdentityDecision(ctx context.Context, ssnVerified bool, addressVerified bool, phoneVerified bool) (identityVerified bool, yield bool, err error)

IdentityDecision determines whether the applicant's identity is verified based on SSN, address, and phone checks.

func (Subflow) IdentityVerification added in v1.40.0

func (_sf Subflow) IdentityVerification(ctx context.Context, applicantName string, ssn string, address string, phone string) (identityVerified bool, yield bool, err error)

IdentityVerification defines the workflow graph for the identity verification process.

func (Subflow) InitIdentityVerification added in v1.40.0

func (_sf Subflow) InitIdentityVerification(ctx context.Context, applicantName string, ssn string, address string, phone string) (yield bool, err error)

InitIdentityVerification is the entry point for the identity verification subgraph.

func (Subflow) RequestMoreInfo added in v1.40.0

func (_sf Subflow) RequestMoreInfo(ctx context.Context, reviewAttempts int) (reviewAttemptsOut int, yield bool, err error)

RequestMoreInfo requests additional information for the credit review and increments the review attempt counter.

func (Subflow) ReviewCredit added in v1.40.0

func (_sf Subflow) ReviewCredit(ctx context.Context, creditScore int, creditVerified bool, reviewAttempts int) (creditVerifiedOut bool, yield bool, err error)

ReviewCredit performs a manual review of borderline credit scores.

func (Subflow) RunIdentityVerification added in v1.41.0

func (_sf Subflow) RunIdentityVerification(ctx context.Context, applicantName string, ssn string, address string, phone string) (identityVerified bool, yield bool, err error)

RunIdentityVerification invokes the IdentityVerification subgraph via flow.Subgraph and adopts identityVerified.

func (Subflow) SubmitCreditApplication added in v1.40.0

func (_sf Subflow) SubmitCreditApplication(ctx context.Context, applicant Applicant) (applicantName string, ssn string, address string, phone string, employers []string, creditScore int, yield bool, err error)

SubmitCreditApplication receives a credit application and sets up the workflow state.

func (Subflow) VerifyAddress added in v1.40.0

func (_sf Subflow) VerifyAddress(ctx context.Context, address string) (addressVerified bool, yield bool, err error)

VerifyAddress checks the applicant's address.

func (Subflow) VerifyCredit added in v1.40.0

func (_sf Subflow) VerifyCredit(ctx context.Context, creditScore int) (creditVerified bool, yield bool, err error)

VerifyCredit checks the applicant's credit score.

func (Subflow) VerifyEmployment added in v1.40.0

func (_sf Subflow) VerifyEmployment(ctx context.Context, applicantName string, employerName string) (employmentFailuresOut int, yield bool, err error)

VerifyEmployment checks the applicant's employment status.

func (Subflow) VerifyPhoneNumber added in v1.40.0

func (_sf Subflow) VerifyPhoneNumber(ctx context.Context, phone string) (phoneVerified bool, yield bool, err error)

VerifyPhoneNumber checks the applicant's phone number.

func (Subflow) VerifySSN added in v1.40.0

func (_sf Subflow) VerifySSN(ctx context.Context, ssn string) (ssnVerified bool, yield bool, err error)

VerifySSN checks the applicant's SSN.

type SubmitCreditApplicationIn

type SubmitCreditApplicationIn struct {
	Applicant Applicant `json:"applicant,omitzero"`
}

SubmitCreditApplicationIn are the input arguments of SubmitCreditApplication.

type SubmitCreditApplicationOut

type SubmitCreditApplicationOut struct {
	ApplicantName string   `json:"applicantName,omitzero"`
	SSN           string   `json:"ssn,omitzero"`
	Address       string   `json:"address,omitzero"`
	Phone         string   `json:"phone,omitzero"`
	Employers     []string `json:"employers,omitzero"`
	CreditScore   int      `json:"creditScore,omitzero"`
}

SubmitCreditApplicationOut are the output arguments of SubmitCreditApplication.

type VerifyAddressIn

type VerifyAddressIn struct {
	Address string `json:"address,omitzero"`
}

VerifyAddressIn are the input arguments of VerifyAddress.

type VerifyAddressOut

type VerifyAddressOut struct {
	AddressVerified bool `json:"addressVerified,omitzero"`
}

VerifyAddressOut are the output arguments of VerifyAddress.

type VerifyCreditIn

type VerifyCreditIn struct {
	CreditScore int `json:"creditScore,omitzero"`
}

VerifyCreditIn are the input arguments of VerifyCredit.

type VerifyCreditOut

type VerifyCreditOut struct {
	CreditVerified bool `json:"creditVerified,omitzero"`
}

VerifyCreditOut are the output arguments of VerifyCredit.

type VerifyEmploymentIn

type VerifyEmploymentIn struct {
	ApplicantName string `json:"applicantName,omitzero"`
	EmployerName  string `json:"employerName,omitzero"`
}

VerifyEmploymentIn are the input arguments of VerifyEmployment.

type VerifyEmploymentOut

type VerifyEmploymentOut struct {
	EmploymentFailuresOut int `json:"employmentFailures,omitzero"`
}

VerifyEmploymentOut are the output arguments of VerifyEmployment.

type VerifyPhoneNumberIn

type VerifyPhoneNumberIn struct {
	Phone string `json:"phone,omitzero"`
}

VerifyPhoneNumberIn are the input arguments of VerifyPhoneNumber.

type VerifyPhoneNumberOut

type VerifyPhoneNumberOut struct {
	PhoneVerified bool `json:"phoneVerified,omitzero"`
}

VerifyPhoneNumberOut are the output arguments of VerifyPhoneNumber.

type VerifySSNIn

type VerifySSNIn struct {
	SSN string `json:"ssn,omitzero"`
}

VerifySSNIn are the input arguments of VerifySSN.

type VerifySSNOut

type VerifySSNOut struct {
	SsnVerified bool `json:"ssnVerified,omitzero"`
}

VerifySSNOut are the output arguments of VerifySSN.

type WorkflowRunner

type WorkflowRunner interface {
	Run(ctx context.Context, workflowName string, initialState any, opts *workflow.FlowOptions) (outcome *workflow.FlowOutcome, err error)
}

WorkflowRunner executes a workflow by name with initial state, blocking until termination. foremanapi.Client satisfies this interface.

Jump to

Keyboard shortcuts

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