Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) CreditApproval(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) Decision(ctx context.Context, flow *workflow.Flow, creditVerified bool, ...) (approved bool, err error)
- func (svc *Mock) Demo(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Mock) HandleCreditError(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (creditVerified bool, err error)
- func (svc *Mock) IdentityDecision(ctx context.Context, flow *workflow.Flow, ssnVerified bool, ...) (identityVerified bool, err error)
- func (svc *Mock) IdentityVerification(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Mock) InitIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, ...) (err error)
- func (svc *Mock) MockCreditApproval(...) *Mock
- func (svc *Mock) MockDecision(...) *Mock
- func (svc *Mock) MockDemo(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) MockHandleCreditError(...) *Mock
- func (svc *Mock) MockIdentityDecision(...) *Mock
- func (svc *Mock) MockIdentityVerification(...) *Mock
- func (svc *Mock) MockInitIdentityVerification(...) *Mock
- func (svc *Mock) MockRequestMoreInfo(...) *Mock
- func (svc *Mock) MockReviewCredit(...) *Mock
- func (svc *Mock) MockSubmitCreditApplication(...) *Mock
- func (svc *Mock) MockVerifyAddress(...) *Mock
- func (svc *Mock) MockVerifyCredit(...) *Mock
- func (svc *Mock) MockVerifyEmployment(...) *Mock
- func (svc *Mock) MockVerifyPhoneNumber(...) *Mock
- func (svc *Mock) MockVerifySSN(...) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) RequestMoreInfo(ctx context.Context, flow *workflow.Flow, reviewAttempts int) (reviewAttemptsOut int, err error)
- func (svc *Mock) ReviewCredit(ctx context.Context, flow *workflow.Flow, creditScore int, creditVerified bool, ...) (creditVerifiedOut bool, err error)
- func (svc *Mock) SubmitCreditApplication(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (applicantName string, ssn string, address string, phone string, ...)
- func (svc *Mock) VerifyAddress(ctx context.Context, flow *workflow.Flow, address string) (addressVerified bool, err error)
- func (svc *Mock) VerifyCredit(ctx context.Context, flow *workflow.Flow, creditScore int, ...) (creditVerified bool, err error)
- func (svc *Mock) VerifyEmployment(ctx context.Context, flow *workflow.Flow, applicantName string, ...) (employmentFailures int, err error)
- func (svc *Mock) VerifyPhoneNumber(ctx context.Context, flow *workflow.Flow, phone string, faultInjection string) (phoneVerified bool, err error)
- func (svc *Mock) VerifySSN(ctx context.Context, flow *workflow.Flow, ssn string, faultInjection string) (ssnVerified bool, err error)
- type Service
- func (svc *Service) CreditApproval(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) Decision(ctx context.Context, flow *workflow.Flow, creditVerified bool, ...) (approved bool, err error)
- func (svc *Service) Demo(w http.ResponseWriter, r *http.Request) (err error)
- func (svc *Service) HandleCreditError(ctx context.Context, flow *workflow.Flow, onErr *errors.TracedError) (creditVerified bool, err error)
- func (svc *Service) IdentityDecision(ctx context.Context, flow *workflow.Flow, ssnVerified bool, ...) (identityVerified bool, err error)
- func (svc *Service) IdentityVerification(ctx context.Context) (graph *workflow.Graph, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) InitIdentityVerification(ctx context.Context, flow *workflow.Flow, applicantName string, ssn string, ...) (err error)
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) RequestMoreInfo(ctx context.Context, flow *workflow.Flow, reviewAttempts int) (reviewAttemptsOut int, err error)
- func (svc *Service) ReviewCredit(ctx context.Context, flow *workflow.Flow, creditScore int, creditVerified bool, ...) (creditVerifiedOut bool, err error)
- func (svc *Service) SubmitCreditApplication(ctx context.Context, flow *workflow.Flow, applicant creditflowapi.Applicant) (applicantName string, ssn string, address string, phone string, ...)
- func (svc *Service) VerifyAddress(ctx context.Context, flow *workflow.Flow, address string) (addressVerified bool, err error)
- func (svc *Service) VerifyCredit(ctx context.Context, flow *workflow.Flow, creditScore int, ...) (creditVerified bool, err error)
- func (svc *Service) VerifyEmployment(ctx context.Context, flow *workflow.Flow, applicantName string, ...) (employmentFailures int, err error)
- func (svc *Service) VerifyPhoneNumber(ctx context.Context, flow *workflow.Flow, phone string, faultInjection string) (phoneVerified bool, err error)
- func (svc *Service) VerifySSN(ctx context.Context, flow *workflow.Flow, ssn string, faultInjection string) (ssnVerified bool, err error)
- type ToDo
Constants ¶
const ( Hostname = creditflowapi.Hostname Version = 5 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
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 (*Mock) CreditApproval ¶
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) 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 ¶
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, faultInjection string) (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) 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, faultInjection string) (creditVerifiedOut bool, err error)) *Mock
MockReviewCredit sets up a mock handler for ReviewCredit.
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, faultInjection string) (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) (employmentFailures 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, faultInjection 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, faultInjection string) (ssnVerified bool, err error)) *Mock
MockVerifySSN sets up a mock handler for VerifySSN.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
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, faultInjection string) (creditVerifiedOut bool, err error)
ReviewCredit 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, faultInjection string) (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) (employmentFailures int, err error)
VerifyEmployment executes the mock handler.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements the creditflow example microservice.
func (*Service) CreditApproval ¶
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) 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 ¶
IdentityVerification defines the workflow graph for the identity verification process.
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 ¶
OnShutdown is called when the microservice is shut down.
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, faultInjection string) (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) 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, faultInjection string) (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) (employmentFailures int, err error)
VerifyEmployment checks the applicant's employment status.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
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, faultInjection string) (creditVerified bool, err error) // MARKER: VerifyCredit
VerifyEmployment(ctx context.Context, flow *workflow.Flow, applicantName string, employerName string) (employmentFailures 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, faultInjection 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, faultInjection 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
IdentityVerification(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: IdentityVerification
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, faultInjection string) (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
CreditApproval(ctx context.Context) (graph *workflow.Graph, err error) // MARKER: CreditApproval
Demo(w http.ResponseWriter, r *http.Request) (err error) // MARKER: Demo
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.