Files
cgalo5758 6dbce6140f Type the ConfigSpec seam and move the connect target to core
Register bool and duration ConfigSpec keys from the Default's type, move
fedwiki's four sync knobs and discourse's two into their integrations'
ConfigSpecs, and replace core's read of fedwiki-custom-domain-target
with a core domains-connect-target key resolved once and threaded
through server and worker config.

Generate init's optional-integration scaffold sections from each
registered ConfigSpec instead of the hand-maintained list, and reword
the Temporal boot warning generically.

Archives the integration-config-parity change; status bookkeeping and
the verify-skill doc follow with the test-stack commit.
2026-08-01 04:13:48 -05:00
..
2026-03-24 17:35:14 -05:00
2025-12-19 15:47:32 -06:00

Temporal Workflows

This directory contains the Temporal workflow definitions, activity implementations, and worker configuration for the member-console application.

Structure: Domain-Based

We use a Domain-Based (or Feature-Based) structure. Instead of grouping all workflows in one folder and all activities in another, we group them by business domain.

internal/workflows/
├── client.go           # Temporal client factory
├── worker.go           # Central worker setup & registration
├── queues/
│   └── queues.go       # Task Queue constants
├── common/             # Shared utilities & generic activities
│   └── options.go      # Standard ActivityOptions (retries, timeouts)
├── example/            # "Example" Domain
│   ├── workflow.go     # Workflow definition
│   └── activities.go   # Domain-specific activities
├── fedwiki/            # "FedWiki" Domain - Site provisioning
│   ├── README.md       # Domain documentation
│   ├── FARMMANAGER.md  # FarmManager API documentation
│   ├── workflow.go     # Create/Delete site workflows
│   ├── activities.go   # Site management activities
│   └── farmmanager_client.go  # HTTP client for FarmManager API
└── onboarding/         # (Future) "Onboarding" Domain
    ├── workflow.go
    └── activities.go

Adding a New Domain

  1. Create a directory: internal/workflows/<domain_name>/
  2. Define the Workflow: Create workflow.go in that directory.
  3. Define Activities: Create activities.go in that directory.
    • Define a struct (e.g., Activities) to hold dependencies (DB, Logger).
    • Implement a NewActivities constructor.
  4. Register: Go to internal/workflows/worker.go and add your new domain to the NewWorker function:
// internal/workflows/worker.go

// ... inside NewWorker ...
w.RegisterWorkflow(yourdomain.Workflow)
w.RegisterActivity(yourdomain.NewActivities(cfg.DB, cfg.Logger))

Usage

Starting the Worker

The worker is embedded in the main application but can be extracted later.

import "git.coopcloud.tech/wiki-cafe/member-console/internal/workflows"

// ... in your main setup ...
workerCfg := workflows.DefaultWorkerConfig(database, logger)
worker, err := workflows.NewWorker(temporalClient, workerCfg)
if err := worker.Start(); err != nil {
    // handle error
}
defer worker.Stop()

Starting a Workflow

import (
    "git.coopcloud.tech/wiki-cafe/member-console/internal/workflows"
    "git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/queues"
    "git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/example"
)

// ... inside an HTTP handler ...
workflowOpts := client.StartWorkflowOptions{
    ID:        "example-" + uuid.New().String(),
    TaskQueue: queues.Main,
}

we, err := temporalClient.ExecuteWorkflow(
    ctx,
    workflowOpts,
    example.Workflow, // Pass the function reference
    example.Input{Message: "hello"},
)