- action/ → activity/ (Temporal activities) - statemachine/ → workflow/ (Temporal workflows) - Removed internal/api/ and cmd/server/ (api-gw handles HTTP, Temporal is the API) - Created pkg/types/types.go as single source of truth for all shared types - Extracted CallRoleLLM helper (DRY: implementer/planner/judge shared pattern) - Fixed circular import: workflow_graph_query uses string activity names - Fixed logger.logf → logger.Info/Warn (method didn't exist) - Fixed routing types: added Branches, Activity, BackoffSeconds, TaskActivity - Fixed db.Canvas.Name, db.Client→DB, GetWorkflow→FetchWorkflow - Removed unused imports - All tests pass, build clean, vet clean
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package activity
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"go.temporal.io/sdk/activity"
|
|
)
|
|
|
|
// activityLogger provides logging that works both in and outside Temporal context
|
|
type activityLogger struct {
|
|
ctx context.Context
|
|
}
|
|
|
|
func newActivityLogger(ctx context.Context) *activityLogger {
|
|
return &activityLogger{ctx: ctx}
|
|
}
|
|
|
|
func (l *activityLogger) Info(msg string, args ...interface{}) {
|
|
if activity.IsActivity(l.ctx) {
|
|
activity.GetLogger(l.ctx).Info(msg, args...)
|
|
} else {
|
|
log.Printf("INFO: "+msg+" %v", args)
|
|
}
|
|
}
|
|
|
|
func (l *activityLogger) Warn(msg string, args ...interface{}) {
|
|
if activity.IsActivity(l.ctx) {
|
|
activity.GetLogger(l.ctx).Warn(msg, args...)
|
|
} else {
|
|
log.Printf("WARN: "+msg+" %v", args)
|
|
}
|
|
}
|
|
|
|
func (l *activityLogger) Error(msg string, args ...interface{}) {
|
|
if activity.IsActivity(l.ctx) {
|
|
activity.GetLogger(l.ctx).Error(msg, args...)
|
|
} else {
|
|
log.Printf("ERROR: "+msg+" %v", args)
|
|
}
|
|
}
|
|
|
|
func (l *activityLogger) Debug(msg string, args ...interface{}) {
|
|
if activity.IsActivity(l.ctx) {
|
|
activity.GetLogger(l.ctx).Debug(msg, args...)
|
|
} else {
|
|
log.Printf("DEBUG: "+msg+" %v", args)
|
|
}
|
|
}
|