Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ go.work.sum
*~
internal/cmd/build/*.sqlite*
.claude
doclink
37 changes: 27 additions & 10 deletions internal/activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ type (
//
// Exposed as: [go.temporal.io/sdk/activity.Type]
ActivityType struct {
// Name is the name of the activity type.
Name string
}

// ActivityInfo contains information about a currently executing activity.
//
// Exposed as: [go.temporal.io/sdk/activity.Info]
ActivityInfo struct {
// TaskToken is the token that identifies the activity task.
TaskToken []byte
// WorkflowType is the type of the workflow that started this activity.
WorkflowType *WorkflowType
// Namespace of the workflow that started this activity. Empty if this activity was not started by a workflow.
// If present, the value is always the same as Namespace since workflows can only run activities in their own
Expand All @@ -36,19 +39,32 @@ type (
// Execution details of the workflow that started this activity. All fields are empty if this activity was not
// started by a workflow.
WorkflowExecution WorkflowExecution
// ActivityID is the ID of the activity.
ActivityID string
ActivityRunID string // Run ID of the activity. Empty if the activity was started by a workflow.
// ActivityRunID is the run ID of the activity. Empty if the activity was started by a workflow.
ActivityRunID string
// ActivityType is the type of the activity.
ActivityType ActivityType
// TaskQueue is the name of the task queue that the activity needs to be scheduled on.
TaskQueue string
Namespace string // Namespace of this activity.
HeartbeatTimeout time.Duration // Maximum time between heartbeats. 0 means no heartbeat needed.
ScheduleToCloseTimeout time.Duration // Schedule to close timeout set by the activity options.
StartToCloseTimeout time.Duration // Start to close timeout set by the activity options.
ScheduledTime time.Time // Time of activity scheduled by a workflow
StartedTime time.Time // Time of activity start
Deadline time.Time // Time of activity timeout
Attempt int32 // Attempt starts from 1, and increased by 1 for every retry if retry policy is specified.
IsLocalActivity bool // true if it is a local activity
// Namespace is the namespace of this activity.
Namespace string
// HeartbeatTimeout is the maximum time between heartbeats. 0 means no heartbeat needed.
HeartbeatTimeout time.Duration
// ScheduleToCloseTimeout is the schedule to close timeout set by the activity options.
ScheduleToCloseTimeout time.Duration
// StartToCloseTimeout is the start to close timeout set by the activity options.
StartToCloseTimeout time.Duration
// ScheduledTime is the time when the activity was scheduled by a workflow.
ScheduledTime time.Time
// StartedTime is the time when the activity started.
StartedTime time.Time
// Deadline is the time of activity timeout.
Deadline time.Time
// Attempt starts from 1, and increased by 1 for every retry if retry policy is specified.
Attempt int32
// IsLocalActivity is true if it is a local activity.
IsLocalActivity bool
// Priority settings that control relative ordering of task processing when activity tasks are backed up in a queue.
// If no priority is set, the default value is the zero value.
//
Expand All @@ -73,6 +89,7 @@ type (
// ambiguity between string names and function references. Also users should
// always use this string name when executing this activity.
Name string
// DisableAlreadyRegisteredCheck disables the check for already registered activities.
DisableAlreadyRegisteredCheck bool

// When registering a struct with activities, skip functions that are not valid activities. If false,
Expand Down
55 changes: 55 additions & 0 deletions internal/cmd/tools/doclink/doclink.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func run() error {
if err != nil {
return fmt.Errorf("error while parsing internal files: %v", err)
}

err = checkInternalDocs(path, file, publicToInternal)
if err != nil {
return fmt.Errorf("error while checking internal docs: %v", err)
}
}
return nil
})
Expand Down Expand Up @@ -587,3 +592,53 @@ func isValidDefinitionWithMatch(line, private string, inGroup string, insideStru
}
return false
}

func checkInternalDocs(path string, file *os.File, pairs map[string]map[string]string) error {
fs := token.NewFileSet()

// Reset file pointer to start
_, err := file.Seek(0, 0)
if err != nil {
return fmt.Errorf("failed to seek: %v", err)
}

node, err := parser.ParseFile(fs, path, file, parser.ParseComments)
if err != nil {
return fmt.Errorf("failed to parse file %s: %v", path, err)
}

exposedTypes := make(map[string]bool)
for _, pair := range pairs {
for _, private := range pair {
exposedTypes[private] = true
}
}

ast.Inspect(node, func(n ast.Node) bool {
if genDecl, ok := n.(*ast.GenDecl); ok && genDecl.Tok == token.TYPE {
for _, spec := range genDecl.Specs {
if typeSpec, ok := spec.(*ast.TypeSpec); ok {
if !exposedTypes[typeSpec.Name.Name] {
continue
}
if structType, ok := typeSpec.Type.(*ast.StructType); ok {
for _, field := range structType.Fields.List {
if len(field.Names) == 0 {
// Skip anonymous/embedded fields
continue
}
for _, name := range field.Names {
if ast.IsExported(name.Name) && field.Doc == nil {
changesNeeded = true
fmt.Printf("Missing doc for exposed struct %s field %s in %s\n", typeSpec.Name.Name, name.Name, path)
}
}
}
}
}
}
}
return true
})
return nil
}
6 changes: 6 additions & 0 deletions internal/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,17 @@ type (
// Exposed as: [go.temporal.io/sdk/workflow.ContinueAsNewError]
ContinueAsNewError struct {
// params *ExecuteWorkflowParams
// WorkflowType is the type of the workflow.
WorkflowType *WorkflowType
// Input is the arguments for the continued workflow execution.
Input *commonpb.Payloads
// Header is the header of the workflow.
Header *commonpb.Header
// TaskQueueName is the task queue that the workflow is running on.
TaskQueueName string
// WorkflowRunTimeout is the timeout for a single run of the workflow execution.
WorkflowRunTimeout time.Duration
// WorkflowTaskTimeout is the maximum execution time of a single Workflow Task.
WorkflowTaskTimeout time.Duration

// Deprecated: WorkflowExecutionTimeout is deprecated and is never set or
Expand Down
Loading