creditflow

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname    = creditflowapi.Hostname
	Version     = creditflowapi.Version
	Description = creditflowapi.Description
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate

type Intermediate struct {
	*connector.Connector
	ToDo
}

Intermediate extends and customizes the generic base connector.

func NewIntermediate

func NewIntermediate(impl ToDo) *Intermediate

NewIntermediate creates a new instance of the intermediate.

type Mock

type Mock struct {
	*Intermediate
	// contains filtered or unexported fields
}

Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.

func NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

func (*Mock) CreditApproval

func (svc *Mock) CreditApproval(ctx context.Context) (graph *workflow.Graph, err error)

CreditApproval returns the workflow graph, or a mocked graph if MockCreditApproval was called.

func (*Mock) Decision

func (svc *Mock) Decision(ctx context.Context, flow *workflow.Flow, creditVerified bool, employmentFailures int, identityVerified bool) (approved bool, err error)

Decision executes the mock handler.

func (*Mock) Demo

func (svc *Mock) Demo(w http.ResponseWriter, r *http.Request) (err error)

Demo executes the mock handler.

func (*Mock) HandleCreditError

func (svc *Mock) HandleCreditError(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (creditVerified bool, err error)

HandleCreditError executes the mock handler.

func (*Mock) IdentityDecision

func (svc *Mock) IdentityDecision(ctx context.Context, flow *workflow.Flow, ssnVerified bool, addressVerified bool, phoneVerified bool) (identityVerified bool, err error)

IdentityDecision executes the mock handler.

func (*Mock) IdentityVerification

func (svc *Mock) IdentityVerification(ctx context.Context) (graph *workflow.Graph, err error)

IdentityVerification returns the workflow graph, or a mocked graph if MockIdentityVerification was called.

func (*Mock) InitIdentityVerification

func (svc *Mock) InitIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (err error)

InitIdentityVerification executes the mock handler.

func (*Mock) MockCreditApproval

func (svc *Mock) MockCreditApproval(handler func(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (approved bool, creditVerified bool, employmentFailures int, identityVerified bool, err error)) *Mock

MockCreditApproval sets up a mock handler for the CreditApproval workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.

func (*Mock) MockDecision

func (svc *Mock) MockDecision(handler func(ctx context.Context, flow *workflow.Flow, creditVerified bool, employmentFailures int, identityVerified bool) (approved bool, err error)) *Mock

MockDecision sets up a mock handler for Decision.

func (*Mock) MockDemo

func (svc *Mock) MockDemo(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock

MockDemo sets up a mock handler for Demo.

func (*Mock) MockHandleCreditError

func (svc *Mock) MockHandleCreditError(handler func(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (creditVerified bool, err error)) *Mock

MockHandleCreditError sets up a mock handler for HandleCreditError.

func (*Mock) MockIdentityDecision

func (svc *Mock) MockIdentityDecision(handler func(ctx context.Context, flow *workflow.Flow, ssnVerified bool, addressVerified bool, phoneVerified bool) (identityVerified bool, err error)) *Mock

MockIdentityDecision sets up a mock handler for IdentityDecision.

func (*Mock) MockIdentityVerification

func (svc *Mock) MockIdentityVerification(handler func(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (identityVerified bool, err error)) *Mock

MockIdentityVerification sets up a mock handler for the IdentityVerification workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.

func (*Mock) MockInitIdentityVerification

func (svc *Mock) MockInitIdentityVerification(handler func(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (err error)) *Mock

MockInitIdentityVerification sets up a mock handler for InitIdentityVerification.

func (*Mock) MockRequestMoreInfo

func (svc *Mock) MockRequestMoreInfo(handler func(ctx context.Context, flow *workflow.Flow, reviewAttempts int) (reviewAttemptsOut int, err error)) *Mock

MockRequestMoreInfo sets up a mock handler for RequestMoreInfo.

func (*Mock) MockReviewCredit

func (svc *Mock) MockReviewCredit(handler func(ctx context.Context, flow *workflow.Flow, creditScore int, creditVerified bool, reviewAttempts int) (creditVerifiedOut bool, err error)) *Mock

MockReviewCredit sets up a mock handler for ReviewCredit.

func (*Mock) MockRunIdentityVerification added in v1.37.0

func (svc *Mock) MockRunIdentityVerification(handler func(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (identityVerified bool, err error)) *Mock

MockRunIdentityVerification sets up a mock handler for RunIdentityVerification.

func (*Mock) MockSubmitCreditApplication

func (svc *Mock) MockSubmitCreditApplication(handler func(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (applicantName string, ssn string, address string, phone string, employers []string, creditScore int, err error)) *Mock

MockSubmitCreditApplication sets up a mock handler for SubmitCreditApplication.

func (*Mock) MockVerifyAddress

func (svc *Mock) MockVerifyAddress(handler func(ctx context.Context, flow *workflow.Flow, address string) (addressVerified bool, err error)) *Mock

MockVerifyAddress sets up a mock handler for VerifyAddress.

func (*Mock) MockVerifyCredit

func (svc *Mock) MockVerifyCredit(handler func(ctx context.Context, flow *workflow.Flow, creditScore int) (creditVerified bool, err error)) *Mock

MockVerifyCredit sets up a mock handler for VerifyCredit.

func (*Mock) MockVerifyEmployment

func (svc *Mock) MockVerifyEmployment(handler func(ctx context.Context, flow *workflow.Flow, applicantName string, employerName string) (employmentFailuresOut int, err error)) *Mock

MockVerifyEmployment sets up a mock handler for VerifyEmployment.

func (*Mock) MockVerifyPhoneNumber

func (svc *Mock) MockVerifyPhoneNumber(handler func(ctx context.Context, flow *workflow.Flow, phone string) (phoneVerified bool, err error)) *Mock

MockVerifyPhoneNumber sets up a mock handler for VerifyPhoneNumber.

func (*Mock) MockVerifySSN

func (svc *Mock) MockVerifySSN(handler func(ctx context.Context, flow *workflow.Flow, ssn string) (ssnVerified bool, err error)) *Mock

MockVerifySSN sets up a mock handler for VerifySSN.

func (*Mock) OnShutdown

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Mock) OnStartup

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Mock) RequestMoreInfo

func (svc *Mock) RequestMoreInfo(ctx context.Context, flow *workflow.Flow, reviewAttempts int) (reviewAttemptsOut int, err error)

RequestMoreInfo executes the mock handler.

func (*Mock) ReviewCredit

func (svc *Mock) ReviewCredit(ctx context.Context, flow *workflow.Flow, creditScore int, creditVerified bool, reviewAttempts int) (creditVerifiedOut bool, err error)

ReviewCredit executes the mock handler.

func (*Mock) RunIdentityVerification added in v1.37.0

func (svc *Mock) RunIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (identityVerified bool, err error)

RunIdentityVerification executes the mock handler.

func (*Mock) SubmitCreditApplication

func (svc *Mock) SubmitCreditApplication(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (applicantName string, ssn string, address string, phone string, employers []string, creditScore int, err error)

SubmitCreditApplication executes the mock handler.

func (*Mock) VerifyAddress

func (svc *Mock) VerifyAddress(ctx context.Context, flow *workflow.Flow, address string) (addressVerified bool, err error)

VerifyAddress executes the mock handler.

func (*Mock) VerifyCredit

func (svc *Mock) VerifyCredit(ctx context.Context, flow *workflow.Flow, creditScore int) (creditVerified bool, err error)

VerifyCredit executes the mock handler.

func (*Mock) VerifyEmployment

func (svc *Mock) VerifyEmployment(ctx context.Context, flow *workflow.Flow, applicantName string, employerName string) (employmentFailuresOut int, err error)

VerifyEmployment executes the mock handler.

func (*Mock) VerifyPhoneNumber

func (svc *Mock) VerifyPhoneNumber(ctx context.Context, flow *workflow.Flow, phone string) (phoneVerified bool, err error)

VerifyPhoneNumber executes the mock handler.

func (*Mock) VerifySSN

func (svc *Mock) VerifySSN(ctx context.Context, flow *workflow.Flow, ssn string) (ssnVerified bool, err error)

VerifySSN executes the mock handler.

type Service

type Service struct {
	*Intermediate // IMPORTANT: Do not remove

}

Service implements the creditflow example microservice.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) CreditApproval

func (svc *Service) CreditApproval(ctx context.Context) (graph *workflow.Graph, err error)

CreditApproval defines the workflow graph for the credit approval process.

func (*Service) Decision

func (svc *Service) Decision(ctx context.Context, flow *workflow.Flow, creditVerified bool, employmentFailures int, identityVerified bool) (approved bool, err error)

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

func (*Service) Demo

func (svc *Service) Demo(w http.ResponseWriter, r *http.Request) (err error)

Demo serves the demo page for the credit approval workflow.

func (*Service) HandleCreditError

func (svc *Service) HandleCreditError(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (creditVerified bool, err error)

HandleCreditError handles a credit verification error by setting creditVerified to false. The error is received via the onErr state field from an error transition.

func (*Service) IdentityDecision

func (svc *Service) IdentityDecision(ctx context.Context, flow *workflow.Flow, 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 (*Service) IdentityVerification

func (svc *Service) IdentityVerification(ctx context.Context) (graph *workflow.Graph, err error)

IdentityVerification defines the workflow graph for the identity verification process.

func (*Service) Init

func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service

Init enables a single-statement pattern for initializing the microservice.

func (*Service) InitIdentityVerification

func (svc *Service) InitIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (err error)

InitIdentityVerification is the entry point for the identity verification subgraph. It passes through the applicant name.

func (*Service) OnShutdown

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

func (*Service) RequestMoreInfo

func (svc *Service) RequestMoreInfo(ctx context.Context, flow *workflow.Flow, reviewAttempts int) (reviewAttemptsOut int, err error)

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

func (*Service) ReviewCredit

func (svc *Service) ReviewCredit(ctx context.Context, flow *workflow.Flow, creditScore int, creditVerified bool, reviewAttempts int) (creditVerifiedOut bool, err error)

ReviewCredit performs a manual review of borderline credit scores. For very borderline scores (550-579), it requests more info up to 2 times before deciding. Scores of 580+ are approved. Below 550 are rejected.

func (*Service) RunIdentityVerification added in v1.37.0

func (svc *Service) RunIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (identityVerified bool, err error)

RunIdentityVerification invokes the IdentityVerification subgraph via flow.Subgraph and adopts its identityVerified output. It is one branch of the credit-application fan-out, converging at the review join.

func (*Service) SubmitCreditApplication

func (svc *Service) SubmitCreditApplication(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (applicantName string, ssn string, address string, phone string, employers []string, creditScore int, err error)

SubmitCreditApplication receives a credit application and unpacks the applicant into individual state fields.

func (*Service) VerifyAddress

func (svc *Service) VerifyAddress(ctx context.Context, flow *workflow.Flow, address string) (addressVerified bool, err error)

VerifyAddress checks the applicant's address.

func (*Service) VerifyCredit

func (svc *Service) VerifyCredit(ctx context.Context, flow *workflow.Flow, creditScore int) (creditVerified bool, err error)

VerifyCredit checks the applicant's credit score.

func (*Service) VerifyEmployment

func (svc *Service) VerifyEmployment(ctx context.Context, flow *workflow.Flow, applicantName string, employerName string) (employmentFailuresOut int, err error)

VerifyEmployment checks the applicant's employment status.

func (*Service) VerifyPhoneNumber

func (svc *Service) VerifyPhoneNumber(ctx context.Context, flow *workflow.Flow, phone string) (phoneVerified bool, err error)

VerifyPhoneNumber checks the applicant's phone number.

func (*Service) VerifySSN

func (svc *Service) VerifySSN(ctx context.Context, flow *workflow.Flow, ssn string) (ssnVerified bool, err error)

VerifySSN checks the applicant's SSN.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	Demo(w http.ResponseWriter, r *http.Request) (err error)                                                                                                                                                              // MARKER: Demo
	SubmitCreditApplication(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (applicantName string, ssn string, address string, phone string, employers []string, creditScore int, err error) // MARKER: SubmitCreditApplication
	VerifyCredit(ctx context.Context, flow *workflow.Flow, creditScore int) (creditVerified bool, err error)                                                                                                              // MARKER: VerifyCredit
	VerifyEmployment(ctx context.Context, flow *workflow.Flow, applicantName string, employerName string) (employmentFailuresOut int, err error)                                                                          // MARKER: VerifyEmployment
	InitIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (err error)                                                                        // MARKER: InitIdentityVerification
	VerifySSN(ctx context.Context, flow *workflow.Flow, ssn string) (ssnVerified bool, err error)                                                                                                                         // MARKER: VerifySSN
	VerifyAddress(ctx context.Context, flow *workflow.Flow, address string) (addressVerified bool, err error)                                                                                                             // MARKER: VerifyAddress
	VerifyPhoneNumber(ctx context.Context, flow *workflow.Flow, phone string) (phoneVerified bool, err error)                                                                                                             // MARKER: VerifyPhoneNumber
	IdentityDecision(ctx context.Context, flow *workflow.Flow, ssnVerified bool, addressVerified bool, phoneVerified bool) (identityVerified bool, err error)                                                             // MARKER: IdentityDecision
	RunIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, address string, phone string) (identityVerified bool, err error)                                                  // MARKER: RunIdentityVerification
	RequestMoreInfo(ctx context.Context, flow *workflow.Flow, reviewAttempts int) (reviewAttemptsOut int, err error)                                                                                                      // MARKER: RequestMoreInfo
	ReviewCredit(ctx context.Context, flow *workflow.Flow, creditScore int, creditVerified bool, reviewAttempts int) (creditVerifiedOut bool, err error)                                                                  // MARKER: ReviewCredit
	HandleCreditError(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (creditVerified bool, err error)                                                                                               // MARKER: HandleCreditError
	Decision(ctx context.Context, flow *workflow.Flow, creditVerified bool, employmentFailures int, identityVerified bool) (approved bool, err error)                                                                     // MARKER: Decision
	IdentityVerification(ctx context.Context) (graph *workflow.Graph, err error)                                                                                                                                          // MARKER: IdentityVerification
	CreditApproval(ctx context.Context) (graph *workflow.Graph, err error)                                                                                                                                                // MARKER: CreditApproval
}

ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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