Files
zeekay 7d727874d5 chore: rebrand Formance Payments -> Hanzo Payments (hanzo-fi)
- go.mod module path + all self-imports: github.com/formancehq/payments -> github.com/hanzo-fi/payments
  (1590 .go files / 3152 refs; 20 modules: root, pkg/client, pkg/domain, 18 ce/plugins).
  External dep kept: formancehq/go-libs.
- plugins: each ce/plugins/* consumed a *published* pkg/domain; added local
  'replace .../pkg/domain => ../../../pkg/domain' (consistent with root) so every
  standalone plugin module builds in-monorepo. compile-plugin.sh MOD var rebranded too.
- branding: README, LICENSE (dual MIT+EE; upstream copyright retained + Hanzo added),
  goreleaser (release images -> registry.hanzo.ai/hanzo-fi, OCI labels, homepage),
  proto go_package, renovate, speakeasy gen.yaml, connector-template *.gotpl.
- CI: removed Numary/Formance workflows + composite action; added canonical hanzo.yml +
  cicd.yml (hanzoai/ci, gated HANZO_CI_ENABLED) + secretless ci.yml (go build/vet).
- kept as data/compat keys: wire capability enums ALLOW_FORMANCE_*, generated SDK type
  client.Formance, domain field FormanceRedirectURL, OTEL_SERVICE_NAME, upstream base image.
- verified: go build ./... (default + -tags ee) + all 20 nested modules green.
2026-07-05 13:08:55 -07:00

70 lines
2.3 KiB
Go

package workflow
import (
"fmt"
"github.com/hanzo-fi/payments/pkg/domain/models"
"github.com/pkg/errors"
"go.temporal.io/api/enums/v1"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)
type BootstrapTaskRequest struct {
ConnectorID models.ConnectorID `json:"connectorID"`
TaskType models.TaskType `json:"taskType"`
NextTasks []models.ConnectorTaskTree `json:"nextTasks"`
}
// runBootstrapTask delegates each bootstrap task to the existing periodic
// fetch workflow, run synchronously as a child workflow. This reuses the
// full pagination loop — per-page state persistence, per-account fan-out,
// ContinueAsNew on large histories, and connector_instances tracking —
// rather than maintaining a parallel implementation.
//
// Bootstrap semantics vs. periodic:
// - `Periodically: false` so no new schedule is created from within
// the loop (RunBootstrapTasks starts the periodic scheduler itself,
// post-bootstrap); plugins that read the flag can distinguish the
// install-time pass from a scheduled tick.
// - `FromPayload: nil` so the state key matches the periodic scheduler's
// (`CAPABILITY_FETCH_ACCOUNTS`) and the next periodic tick picks up
// from the cursor this run stored.
func (w Workflow) runBootstrapTask(
ctx workflow.Context,
req BootstrapTaskRequest,
) error {
switch req.TaskType {
case models.TASK_FETCH_ACCOUNTS:
if err := workflow.ExecuteChildWorkflow(
workflow.WithChildOptions(
ctx,
workflow.ChildWorkflowOptions{
WorkflowID: fmt.Sprintf("bootstrap-fetch-accounts-%s-%s", w.stack, req.ConnectorID.String()),
TaskQueue: w.getDefaultTaskQueue(),
ParentClosePolicy: enums.PARENT_CLOSE_POLICY_TERMINATE,
SearchAttributes: w.SearchAttributes(ctx, &req.ConnectorID),
},
),
RunFetchNextAccounts,
FetchNextAccounts{
ConnectorID: req.ConnectorID,
FromPayload: nil,
Periodically: false,
},
req.NextTasks,
).Get(ctx, nil); err != nil {
return errors.Wrap(err, "bootstrap fetching accounts")
}
return nil
default:
return temporal.NewNonRetryableApplicationError(
fmt.Sprintf("bootstrap does not support task type %d", req.TaskType),
ErrValidation,
nil,
)
}
}
const RunBootstrapTask = "RunBootstrapTask"