Documentation
¶
Index ¶
- Constants
- Variables
- type Applicant
- type Client
- type CreditApprovalIn
- type CreditApprovalOut
- type DecisionIn
- type DecisionOut
- type Def
- type Executor
- func (_c Executor) CreditApproval(ctx context.Context, applicant Applicant, faultInjection string) (approved bool, creditVerified bool, employmentFailures int, ...)
- func (_c Executor) Decision(ctx context.Context, creditVerified bool, employmentFailures int, ...) (approved bool, err error)
- func (_c Executor) ForHost(host string) Executor
- func (_c Executor) HandleCreditError(ctx context.Context, onErr *errors.TracedError) (creditVerified bool, err error)
- func (_c Executor) IdentityDecision(ctx context.Context, ssnVerified bool, addressVerified bool, ...) (identityVerified bool, err error)
- func (_c Executor) IdentityVerification(ctx context.Context, applicantName string, ssn string, address string, ...) (identityVerified bool, status string, err error)
- func (_c Executor) InitIdentityVerification(ctx context.Context, applicantName string, ssn string, address string, ...) (err error)
- func (_c Executor) RequestMoreInfo(ctx context.Context, reviewAttempts int) (reviewAttemptsOut int, err error)
- func (_c Executor) ReviewCredit(ctx context.Context, creditScore int, creditVerified bool, reviewAttempts int, ...) (creditVerifiedOut bool, err error)
- func (_c Executor) SubmitCreditApplication(ctx context.Context, applicant Applicant) (applicantName string, ssn string, address string, phone string, ...)
- func (_c Executor) VerifyAddress(ctx context.Context, address string) (addressVerified bool, err error)
- func (_c Executor) VerifyCredit(ctx context.Context, creditScore int, faultInjection string) (creditVerified bool, err error)
- func (_c Executor) VerifyEmployment(ctx context.Context, applicantName string, employerName string) (employmentFailures int, err error)
- func (_c Executor) VerifyPhoneNumber(ctx context.Context, phone string, faultInjection string) (phoneVerified bool, err error)
- func (_c Executor) VerifySSN(ctx context.Context, ssn string, faultInjection string) (ssnVerified bool, err error)
- func (_c Executor) WithInputFlow(flow *workflow.Flow) Executor
- func (_c Executor) WithOptions(opts ...pub.Option) Executor
- func (_c Executor) WithOutputFlow(flow *workflow.Flow) Executor
- func (_c Executor) WithWorkflowRunner(runner WorkflowRunner) Executor
- type HandleCreditErrorIn
- type HandleCreditErrorOut
- type Hook
- type IdentityDecisionIn
- type IdentityDecisionOut
- type IdentityVerificationIn
- type IdentityVerificationOut
- type InitIdentityVerificationIn
- type InitIdentityVerificationOut
- type MulticastClient
- type MulticastTrigger
- type RequestMoreInfoIn
- type RequestMoreInfoOut
- type ReviewCreditIn
- type ReviewCreditOut
- type SubmitCreditApplicationIn
- type SubmitCreditApplicationOut
- type VerifyAddressIn
- type VerifyAddressOut
- type VerifyCreditIn
- type VerifyCreditOut
- type VerifyEmploymentIn
- type VerifyEmploymentOut
- type VerifyPhoneNumberIn
- type VerifyPhoneNumberOut
- type VerifySSNIn
- type VerifySSNOut
- type WorkflowRunner
Constants ¶
const Hostname = "creditflow.example"
Hostname is the default hostname of the microservice.
Variables ¶
var ( // HINT: Insert endpoint definitions here SubmitCreditApplication = Def{Method: "POST", Route: ":428/submit-credit-application"} // MARKER: SubmitCreditApplication VerifyCredit = Def{Method: "POST", Route: ":428/verify-credit"} // MARKER: VerifyCredit VerifyEmployment = Def{Method: "POST", Route: ":428/verify-employment"} // MARKER: VerifyEmployment InitIdentityVerification = Def{Method: "POST", Route: ":428/init-identity-verification"} // MARKER: InitIdentityVerification VerifySSN = Def{Method: "POST", Route: ":428/verify-ssn"} // MARKER: VerifySSN VerifyAddress = Def{Method: "POST", Route: ":428/verify-address"} // MARKER: VerifyAddress VerifyPhoneNumber = Def{Method: "POST", Route: ":428/verify-phone-number"} // MARKER: VerifyPhoneNumber IdentityDecision = Def{Method: "POST", Route: ":428/identity-decision"} // MARKER: IdentityDecision IdentityVerification = Def{Method: "GET", Route: ":428/identity-verification"} // MARKER: IdentityVerification RequestMoreInfo = Def{Method: "POST", Route: ":428/request-more-info"} // MARKER: RequestMoreInfo ReviewCredit = Def{Method: "POST", Route: ":428/review-credit"} // MARKER: ReviewCredit HandleCreditError = Def{Method: "POST", Route: ":428/handle-credit-error"} // MARKER: HandleCreditError Decision = Def{Method: "POST", Route: ":428/decision"} // MARKER: Decision CreditApproval = Def{Method: "GET", Route: ":428/credit-approval"} // MARKER: CreditApproval Demo = Def{Method: "ANY", Route: "/demo"} // MARKER: Demo )
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 (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.
If a URL is provided, it is resolved relative to the URL of the endpoint. If the body is of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON.
type CreditApprovalIn ¶
type CreditApprovalIn struct {
Applicant Applicant `json:"applicant,omitzero"`
FaultInjection string `json:"faultInjection,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 ¶
NewExecutor creates a new executor proxy to the microservice.
func (Executor) CreditApproval ¶
func (_c Executor) CreditApproval(ctx context.Context, applicant Applicant, faultInjection string) (approved bool, creditVerified bool, employmentFailures int, identityVerified bool, status string, err error)
CreditApproval creates and runs the credit approval workflow, blocking until termination.
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 ¶
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 creates and runs the identity verification workflow, blocking until termination.
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, faultInjection string) (creditVerifiedOut bool, err error)
ReviewCredit performs a manual review of borderline credit scores.
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, faultInjection string) (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) (employmentFailures int, err error)
VerifyEmployment checks the applicant's employment status.
func (Executor) VerifyPhoneNumber ¶
func (_c Executor) VerifyPhoneNumber(ctx context.Context, phone string, faultInjection string) (phoneVerified bool, err error)
VerifyPhoneNumber checks the applicant's phone number.
func (Executor) VerifySSN ¶
func (_c Executor) VerifySSN(ctx context.Context, ssn string, faultInjection string) (ssnVerified bool, err error)
VerifySSN checks the applicant's SSN.
func (Executor) WithInputFlow ¶
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 ¶
WithOptions returns a copy of the executor with options to be applied to requests.
func (Executor) WithOutputFlow ¶
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 Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook assists in the subscription to the events of the microservice.
func NewHook ¶
func NewHook(listener service.Subscriber) Hook
NewHook creates a new hook to the events of the microservice.
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.
If a URL is provided, it is resolved relative to the URL of the endpoint. If the body is of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON.
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 MulticastTrigger ¶
type MulticastTrigger struct {
// contains filtered or unexported fields
}
MulticastTrigger is a lightweight proxy for triggering the events of the microservice.
func NewMulticastTrigger ¶
func NewMulticastTrigger(caller service.Publisher) MulticastTrigger
NewMulticastTrigger creates a new multicast trigger of events of the microservice.
func (MulticastTrigger) ForHost ¶
func (_c MulticastTrigger) ForHost(host string) MulticastTrigger
ForHost returns a copy of the trigger with a different hostname to be applied to requests.
func (MulticastTrigger) WithOptions ¶
func (_c MulticastTrigger) WithOptions(opts ...pub.Option) MulticastTrigger
WithOptions returns a copy of the trigger 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"`
FaultInjection string `json:"faultInjection,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 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"`
FaultInjection string `json:"faultInjection,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 {
EmploymentFailures int `json:"employmentFailures,omitzero"`
}
VerifyEmploymentOut are the output arguments of VerifyEmployment.
type VerifyPhoneNumberIn ¶
type VerifyPhoneNumberIn struct {
Phone string `json:"phone,omitzero"`
FaultInjection string `json:"faultInjection,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"`
FaultInjection string `json:"faultInjection,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) (status string, state map[string]any, err error)
}
WorkflowRunner executes a workflow by name with initial state, blocking until termination. foremanapi.Client satisfies this interface.