diff --git a/internal/activity.go b/internal/activity.go index a7789b5a1..e11fd64e4 100644 --- a/internal/activity.go +++ b/internal/activity.go @@ -39,11 +39,15 @@ import ( type ( // ActivityType identifies an activity type. + // + // Exposed as: [go.temporal.io/sdk/activity.Type] ActivityType struct { Name string } // ActivityInfo contains information about a currently executing activity. + // + // Exposed as: [go.temporal.io/sdk/activity.Info] ActivityInfo struct { TaskToken []byte WorkflowType *WorkflowType @@ -61,6 +65,8 @@ type ( } // RegisterActivityOptions consists of options for registering an activity. + // + // Exposed as: [go.temporal.io/sdk/activity.RegisterOptions] RegisterActivityOptions struct { // When an activity is a function the name is an actual activity type name. // When an activity is part of a structure then each member of the structure becomes an activity with @@ -81,6 +87,8 @@ type ( // ActivityOptions stores all activity-specific parameters that will be stored inside of a context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. + // + // Exposed as: [go.temporal.io/sdk/workflow.ActivityOptions] ActivityOptions struct { // TaskQueue - Name of the task queue that the activity needs to be scheduled on. // Optional: The default task queue with the same name as the workflow task queue. @@ -160,6 +168,8 @@ type ( } // LocalActivityOptions stores local activity specific parameters that will be stored inside of a context. + // + // Exposed as: [go.temporal.io/sdk/workflow.LocalActivityOptions] LocalActivityOptions struct { // ScheduleToCloseTimeout - The end to end timeout for the local activity, including retries. // At least one of ScheduleToCloseTimeout or StartToCloseTimeout is required. @@ -179,16 +189,22 @@ type ( ) // GetActivityInfo returns information about the currently executing activity. +// +// Exposed as: [go.temporal.io/sdk/activity.GetInfo] func GetActivityInfo(ctx context.Context) ActivityInfo { return getActivityOutboundInterceptor(ctx).GetInfo(ctx) } // HasHeartbeatDetails checks if there are heartbeat details from last attempt. +// +// Exposed as: [go.temporal.io/sdk/activity.HasHeartbeatDetails] func HasHeartbeatDetails(ctx context.Context) bool { return getActivityOutboundInterceptor(ctx).HasHeartbeatDetails(ctx) } // IsActivity checks if the context is an activity context from a normal or local activity. +// +// Exposed as: [go.temporal.io/sdk/activity.IsActivity] func IsActivity(ctx context.Context) bool { a := ctx.Value(activityInterceptorContextKey) return a != nil @@ -202,16 +218,22 @@ func IsActivity(ctx context.Context) bool { // // Note: Values should not be reused for extraction here because merging on top // of existing values may result in unexpected behavior similar to json.Unmarshal. +// +// Exposed as: [go.temporal.io/sdk/activity.GetHeartbeatDetails] func GetHeartbeatDetails(ctx context.Context, d ...interface{}) error { return getActivityOutboundInterceptor(ctx).GetHeartbeatDetails(ctx, d...) } // GetActivityLogger returns a logger that can be used in the activity. +// +// Exposed as: [go.temporal.io/sdk/activity.GetLogger] func GetActivityLogger(ctx context.Context) log.Logger { return getActivityOutboundInterceptor(ctx).GetLogger(ctx) } // GetActivityMetricsHandler returns a metrics handler that can be used in the activity. +// +// Exposed as: [go.temporal.io/sdk/activity.GetMetricsHandler] func GetActivityMetricsHandler(ctx context.Context) metrics.Handler { return getActivityOutboundInterceptor(ctx).GetMetricsHandler(ctx) } @@ -220,6 +242,8 @@ func GetActivityMetricsHandler(ctx context.Context) metrics.Handler { // When the worker is stopping, it will close this channel and wait until the worker stop timeout finishes. After the timeout // hits, the worker will cancel the activity context and then exit. The timeout can be defined by worker option: WorkerStopTimeout. // Use this channel to handle a graceful activity exit when the activity worker stops. +// +// Exposed as: [go.temporal.io/sdk/activity.GetWorkerStopChannel] func GetWorkerStopChannel(ctx context.Context) <-chan struct{} { return getActivityOutboundInterceptor(ctx).GetWorkerStopChannel(ctx) } @@ -234,6 +258,8 @@ func GetWorkerStopChannel(ctx context.Context) <-chan struct{} { // // details - The details that you provided here can be seen in the workflow when it receives TimeoutError. You // can check error TimeoutType()/Details(). +// +// Exposed as: [go.temporal.io/sdk/activity.RecordHeartbeat] func RecordActivityHeartbeat(ctx context.Context, details ...interface{}) { getActivityOutboundInterceptor(ctx).RecordHeartbeat(ctx, details...) } diff --git a/internal/client.go b/internal/client.go index 1564c282f..6a5e32833 100644 --- a/internal/client.go +++ b/internal/client.go @@ -47,14 +47,20 @@ import ( const ( // DefaultNamespace is the namespace name which is used if not passed with options. + // + // Exposed as: [go.temporal.io/sdk/client.DefaultNamespace] DefaultNamespace = "default" // QueryTypeStackTrace is the build in query type for Client.QueryWorkflow() call. Use this query type to get the call // stack of the workflow. The result will be a string encoded in the EncodedValue. + // + // Exposed as: [go.temporal.io/sdk/client.QueryTypeStackTrace] QueryTypeStackTrace string = "__stack_trace" // QueryTypeOpenSessions is the build in query type for Client.QueryWorkflow() call. Use this query type to get all open // sessions in the workflow. The result will be a list of SessionInfo encoded in the EncodedValue. + // + // Exposed as: [go.temporal.io/sdk/client.QueryTypeOpenSessions] QueryTypeOpenSessions string = "__open_sessions" // QueryTypeWorkflowMetadata is the query name for the workflow metadata. @@ -430,6 +436,8 @@ type ( } // ClientOptions are optional parameters for Client creation. + // + // Exposed as: [go.temporal.io/sdk/client.Options] ClientOptions struct { // Optional: To set the host:port for this client to connect to. // default: localhost:7233 @@ -516,6 +524,8 @@ type ( // CloudOperationsClientOptions are parameters for CloudOperationsClient creation. // // WARNING: Cloud operations client is currently experimental. + // + // Exposed as: [go.temporal.io/sdk/client.CloudOperationsClientOptions] CloudOperationsClientOptions struct { // Optional: The credentials for this client. This is essentially required. // See [go.temporal.io/sdk/client.NewAPIKeyStaticCredentials], @@ -562,6 +572,8 @@ type ( } // ConnectionOptions is provided by SDK consumers to control optional connection params. + // + // Exposed as: [go.temporal.io/sdk/client.ConnectionOptions] ConnectionOptions struct { // TLS configures connection level security credentials. TLS *tls.Config @@ -622,6 +634,8 @@ type ( // StartWorkflowOptions configuration parameters for starting a workflow execution. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. + // + // Exposed as: [go.temporal.io/sdk/client.StartWorkflowOptions] StartWorkflowOptions struct { // ID - The business identifier of the workflow execution. // Optional: defaulted to a uuid. @@ -779,6 +793,8 @@ type ( // started time. Because of that, to check an activity has started or not, you cannot rely on history events. Instead, // you can use CLI to describe the workflow to see the status of the activity: // tctl --ns wf desc -w + // + // Exposed as: [go.temporal.io/sdk/temporal.RetryPolicy] RetryPolicy struct { // Backoff interval for the first retry. If BackoffCoefficient is 1.0 then it is used for all retries. // If not set or set to 0, a default interval of 1s will be used. @@ -840,6 +856,8 @@ type ( ) // Credentials are optional credentials that can be specified in ClientOptions. +// +// Exposed as: [go.temporal.io/sdk/client.Credentials] type Credentials interface { applyToOptions(*ConnectionOptions) error // Can return nil to have no interceptor @@ -847,12 +865,16 @@ type Credentials interface { } // DialClient creates a client and attempts to connect to the server. +// +// Exposed as: [go.temporal.io/sdk/client.DialContext] func DialClient(ctx context.Context, options ClientOptions) (Client, error) { options.ConnectionOptions.disableEagerConnection = false return NewClient(ctx, options) } // NewLazyClient creates a client and does not attempt to connect to the server. +// +// Exposed as: [go.temporal.io/sdk/client.NewLazyClient] func NewLazyClient(options ClientOptions) (Client, error) { options.ConnectionOptions.disableEagerConnection = true return NewClient(context.Background(), options) @@ -861,12 +883,16 @@ func NewLazyClient(options ClientOptions) (Client, error) { // NewClient creates an instance of a workflow client // // Deprecated: Use DialClient or NewLazyClient instead. +// +// Exposed as: [go.temporal.io/sdk/client.NewClient] func NewClient(ctx context.Context, options ClientOptions) (Client, error) { return newClient(ctx, options, nil) } // NewClientFromExisting creates a new client using the same connection as the // existing client. +// +// Exposed as: [go.temporal.io/sdk/client.NewClientFromExistingWithContext] func NewClientFromExisting(ctx context.Context, existingClient Client, options ClientOptions) (Client, error) { existing, _ := existingClient.(*WorkflowClient) if existing == nil { @@ -1012,6 +1038,8 @@ func NewServiceClient(workflowServiceClient workflowservice.WorkflowServiceClien // DialCloudOperationsClient creates a cloud client to perform cloud-management // operations. +// +// Exposed as: [go.temporal.io/sdk/client.DialCloudOperationsClient] func DialCloudOperationsClient(ctx context.Context, options CloudOperationsClientOptions) (CloudOperationsClient, error) { // Set defaults if options.MetricsHandler == nil { @@ -1089,6 +1117,8 @@ func (op *withStartWorkflowOperationImpl) set(workflowRun WorkflowRun, err error } // NewNamespaceClient creates an instance of a namespace client, to manager lifecycle of namespaces. +// +// Exposed as: [go.temporal.io/sdk/client.NewNamespaceClient] func NewNamespaceClient(options ClientOptions) (NamespaceClient, error) { // Initialize root tags if options.MetricsHandler == nil { @@ -1129,6 +1159,8 @@ func newNamespaceServiceClient(workflowServiceClient workflowservice.WorkflowSer // // var result string // This need to be same type as the one passed to RecordHeartbeat // NewValue(data).Get(&result) +// +// Exposed as: [go.temporal.io/sdk/client.NewValue] func NewValue(data *commonpb.Payloads) converter.EncodedValue { return newEncodedValue(data, nil) } @@ -1141,16 +1173,20 @@ func NewValue(data *commonpb.Payloads) converter.EncodedValue { // var result1 string // var result2 int // These need to be same type as those arguments passed to RecordHeartbeat // NewValues(data).Get(&result1, &result2) +// +// Exposed as: [go.temporal.io/sdk/client.NewValues] func NewValues(data *commonpb.Payloads) converter.EncodedValues { return newEncodedValues(data, nil) } type apiKeyCredentials func(context.Context) (string, error) +// Exposed as: [go.temporal.io/sdk/client.NewAPIKeyStaticCredentials] func NewAPIKeyStaticCredentials(apiKey string) Credentials { return NewAPIKeyDynamicCredentials(func(ctx context.Context) (string, error) { return apiKey, nil }) } +// Exposed as: [go.temporal.io/sdk/client.NewAPIKeyDynamicCredentials] func NewAPIKeyDynamicCredentials(apiKeyCallback func(context.Context) (string, error)) Credentials { return apiKeyCredentials(apiKeyCallback) } @@ -1181,6 +1217,7 @@ func (a apiKeyCredentials) gRPCIntercept( type mTLSCredentials tls.Certificate +// Exposed as: [go.temporal.io/sdk/client.NewMTLSCredentials] func NewMTLSCredentials(certificate tls.Certificate) Credentials { return mTLSCredentials(certificate) } func (m mTLSCredentials) applyToOptions(opts *ConnectionOptions) error { @@ -1198,11 +1235,15 @@ func (mTLSCredentials) gRPCInterceptor() grpc.UnaryClientInterceptor { return ni // WorkflowUpdateServiceTimeoutOrCanceledError is an error that occurs when an update call times out or is cancelled. // // Note, this is not related to any general concept of timing out or cancelling a running update, this is only related to the client call itself. +// +// Exposed as: [go.temporal.io/sdk/client.WorkflowUpdateServiceTimeoutOrCanceledError] type WorkflowUpdateServiceTimeoutOrCanceledError struct { cause error } // NewWorkflowUpdateServiceTimeoutOrCanceledError creates a new WorkflowUpdateServiceTimeoutOrCanceledError. +// +// Exposed as: [go.temporal.io/sdk/client.NewWorkflowUpdateServiceTimeoutOrCanceledError] func NewWorkflowUpdateServiceTimeoutOrCanceledError(err error) *WorkflowUpdateServiceTimeoutOrCanceledError { return &WorkflowUpdateServiceTimeoutOrCanceledError{ cause: err, diff --git a/internal/cmd/build/main.go b/internal/cmd/build/main.go index 500d25ab6..6a223e1f5 100644 --- a/internal/cmd/build/main.go +++ b/internal/cmd/build/main.go @@ -108,6 +108,10 @@ func (b *builder) check() error { if err := b.runCmd(b.cmdFromRoot("go", "run", "./internal/cmd/tools/copyright/licensegen.go", "--verifyOnly")); err != nil { return fmt.Errorf("copyright check failed: %w", err) } + // Run doclink check + if err := b.runCmd(b.cmdFromRoot("go", "run", "./internal/cmd/tools/doclink/doclink.go")); err != nil { + return fmt.Errorf("copyright check failed: %w", err) + } return nil } diff --git a/internal/cmd/tools/doclink/doclink.go b/internal/cmd/tools/doclink/doclink.go new file mode 100644 index 000000000..1c5fa0078 --- /dev/null +++ b/internal/cmd/tools/doclink/doclink.go @@ -0,0 +1,509 @@ +// The MIT License +// +// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package main + +import ( + "bufio" + "flag" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "log" + "os" + "path/filepath" + "strings" +) + +type ( + // command line config params + config struct { + rootDir string + fix bool + } +) + +var missing = false + +func main() { + if err := run(); err != nil { + log.Fatal(err) + } + if missing { + log.Fatal("Missing documentation, see previous stdout for which objects. Re-run command with -fix to auto-generate missing docs.") + } +} + +func run() error { + var cfg config + flag.StringVar(&cfg.rootDir, "rootDir", ".", "project root directory") + flag.BoolVar(&cfg.fix, "fix", false, + "add links to internal types and functions that are exposed publicly") + flag.Parse() + publicToInternal := make(map[string]map[string]string) + // Go through public packages and identify wrappers to internal types/funcs + err := filepath.Walk(cfg.rootDir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return fmt.Errorf("public walking %q: %v", path, err) + } + + if info.IsDir() && (info.Name() == "internal" || info.Name() == "contrib") { + return filepath.SkipDir + } + + if strings.HasSuffix(path, "internalbindings.go") { + return nil + } + if strings.HasSuffix(path, ".go") && !strings.HasSuffix(path, "_test.go") { + file, err := os.Open(path) + if err != nil { + return fmt.Errorf("failed to read file %s: %v", path, err) + } + defer func() { + err = file.Close() + if err != nil { + log.Fatalf("failed to close file %s: %v", path, err) + } + }() + + res, err := processPublic(cfg, file) + if err != nil { + return fmt.Errorf("error while parsing public files: %v", err) + } + + if len(res) > 0 { + _, err = file.Seek(0, 0) + if err != nil { + log.Fatalf("Failed to rewind file: %v", err) + } + // TODO: remove + packageName, err := extractPackageName(file) + if err != nil { + return fmt.Errorf("failed to extract package name: %v", err) + } + if packageMap, ok := publicToInternal[packageName]; !ok { + publicToInternal[packageName] = res + } else { + for k, v := range res { + if _, exists := packageMap[k]; exists { + return fmt.Errorf("collision detected for package '%s': key '%s' exists in both maps (%s and %s)", packageName, k, packageMap[k], v) + } + packageMap[k] = v + } + publicToInternal[packageName] = packageMap + } + } + } + return nil + }) + if err != nil { + return fmt.Errorf("error walking the path %s: %v", cfg.rootDir, err) + } + + // Go through internal files and match the definitions of private/public pairings + err = filepath.Walk("internal", func(path string, info os.FileInfo, err error) error { + if strings.HasSuffix(info.Name(), ".tmp") { + return nil + } + if err != nil { + return fmt.Errorf("walking %q: %v", path, err) + } + if info.IsDir() && info.Name() != "internal" { + return filepath.SkipDir + } + if strings.HasSuffix(path, ".go") && !strings.HasSuffix(path, "_test.go") && !strings.Contains(path, "internal_") { + file, err := os.Open(path) + if err != nil { + return fmt.Errorf("failed to read file %s: %v", path, err) + } + defer func() { + err = file.Close() + if err != nil { + log.Fatalf("failed to close file %s: %v", path, err) + } + }() + + err = processInternal(cfg, file, publicToInternal) + if err != nil { + return fmt.Errorf("error while parsing internal files: %v", err) + } + } + return nil + }) + if err != nil { + return fmt.Errorf("error walking the path %s: %v", cfg.rootDir, err) + } + return nil +} + +// Traverse the AST of public packages to identify wrappers for internal objects +func processPublic(cfg config, file *os.File) (map[string]string, error) { + fs := token.NewFileSet() + node, err := parser.ParseFile(fs, "", file, parser.AllErrors) + if err != nil { + return nil, fmt.Errorf("failed to parse file : %v", err) + } + publicToInternal := make(map[string]string) + ast.Inspect(node, func(n ast.Node) bool { + if genDecl, ok := n.(*ast.GenDecl); ok { + for _, spec := range genDecl.Specs { + if typeSpec, typeOk := spec.(*ast.TypeSpec); typeOk { + name := typeSpec.Name.Name + if ast.IsExported(name) { + res := extractTypeValue(typeSpec.Type) + if len(res) > 0 { + publicToInternal[name] = res + } + } + } + if valueSpec, valueOk := spec.(*ast.ValueSpec); valueOk { + if isTypeAssertion(valueSpec) { + return true + } + name := valueSpec.Names + if ast.IsExported(name[0].Name) { + res := checkValueSpec(valueSpec) + if len(res) > 0 { + publicToInternal[name[0].Name] = res + } + } + } + } + } + if funcDecl, ok := n.(*ast.FuncDecl); ok && ast.IsExported(funcDecl.Name.Name) { + isWrapper := checkFunction(funcDecl) + if len(isWrapper) > 0 { + publicToInternal[funcDecl.Name.Name] = isWrapper + } + } + return true + }) + return publicToInternal, nil +} + +func extractTypeValue(expr ast.Expr) string { + switch t := expr.(type) { + case *ast.StructType: + for _, field := range t.Fields.List { + res := extractTypeValue(field.Type) + if len(res) > 0 { + return res + } + } + case *ast.InterfaceType: + for _, method := range t.Methods.List { + res := extractTypeValue(method.Type) + if len(res) > 0 { + return res + } + } + case *ast.Ident: + if strings.HasPrefix(t.Name, "internal.") { + return strings.TrimPrefix(t.Name, "internal.") + } + case *ast.FuncType: + for _, param := range t.Params.List { + res := extractTypeValue(param.Type) + if len(res) > 0 { + return res + } + } + if t.Results != nil { + for _, result := range t.Results.List { + res := extractTypeValue(result.Type) + if len(res) > 0 { + return res + } + } + } + case *ast.SelectorExpr: + if ident, ok := t.X.(*ast.Ident); ok && ident.Name == "internal" { + return t.Sel.Name + } + case *ast.BasicLit: + // Do nothing + default: + //fmt.Printf("[WARN] Unsupported type: %T\n", t) + } + return "" +} + +func checkValueSpec(spec *ast.ValueSpec) string { + // Check if the type of the value spec contains "internal." + if spec.Type != nil { + res := extractTypeValue(spec.Type) + if len(res) > 0 { + return res + } + } + + // Check the expressions (values assigned) for "internal." + for _, value := range spec.Values { + res := extractTypeValue(value) + if len(res) > 0 { + return res + } + } + + return "" +} + +// Check if a public function is a wrapper around an internal function +func checkFunction(funcDecl *ast.FuncDecl) string { + // Ensure the function has a body + if funcDecl.Body == nil { + return "" + } + + // Ensure the body has exactly one statement + if len(funcDecl.Body.List) != 1 { + return "" + } + + // Check if the single statement is a return statement + if retStmt, ok := funcDecl.Body.List[0].(*ast.ReturnStmt); ok { + // Ensure the return statement directly calls an internal function + for _, result := range retStmt.Results { + if callExpr, ok := result.(*ast.CallExpr); ok { + if res := isInternalFunctionCall(callExpr); len(res) > 0 { + return res + } + } + } + } + + // Functions that don't return anything + if exprStmt, ok := funcDecl.Body.List[0].(*ast.ExprStmt); ok { + if callExpr, ok := exprStmt.X.(*ast.CallExpr); ok { + if res := isInternalFunctionCall(callExpr); len(res) > 0 { + return res + } + } + } + + return "" +} + +// Check if a call expression is calling an internal function +func isInternalFunctionCall(callExpr *ast.CallExpr) string { + // Check if the function being called is a SelectorExpr (e.g., "internal.SomeFunction") + if selExpr, ok := callExpr.Fun.(*ast.SelectorExpr); ok { + if pkgIdent, ok := selExpr.X.(*ast.Ident); ok && pkgIdent.Name == "internal" { + return selExpr.Sel.Name + } + } + return "" +} + +// Check for type assertions like `var _ = internal.SomeType(nil)` +func isTypeAssertion(valueSpec *ast.ValueSpec) bool { + for _, value := range valueSpec.Values { + if callExpr, ok := value.(*ast.CallExpr); ok { + if selExpr, ok := callExpr.Fun.(*ast.SelectorExpr); ok { + if pkgIdent, ok := selExpr.X.(*ast.Ident); ok && pkgIdent.Name == "internal" { + return true + } + } + } + } + return false +} + +func extractPackageName(file *os.File) (string, error) { + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.HasPrefix(line, "package ") { + // Split the line to extract the package name + parts := strings.Fields(line) + if len(parts) > 1 { + return parts[1], nil + } + } + } + + if err := scanner.Err(); err != nil { + return "", fmt.Errorf("scanner error: %e", err) + } + + return "", fmt.Errorf("package declaration not found in %s", file.Name()) +} + +// Identify type/func definitions in the file and match to any private:public mappings. +// If mapping is identified, check if doc comment exists for such mapping. +func processInternal(cfg config, file *os.File, pairs map[string]map[string]string) error { + scanner := bufio.NewScanner(file) + newFile := "" + exposedAs := "// Exposed as: " + var inGroup, exposedLinks string + var changesMade, inStruct bool + for scanner.Scan() { + line := scanner.Text() + trimmedLine := strings.TrimSpace(line) + if isValidDefinition(trimmedLine, &inGroup, &inStruct) { + for packageName, pair := range pairs { + for public, private := range pair { + if isValidDefinitionWithMatch(trimmedLine, private, inGroup, inStruct) { + docLink := fmt.Sprintf("[go.temporal.io/sdk/%s.%s]", packageName, public) + missingDoc := true + if exposedLinks != "" { + if strings.Contains(exposedLinks, docLink) { + missingDoc = false + } + } + if missingDoc { + if cfg.fix { + changesMade = true + exposedLinks += docLink + ", " + fmt.Printf("Fixed doc in %s for internal:%s to %s:%s\n", file.Name(), private, packageName, public) + } else { + missing = true + fmt.Printf("Missing doc in %s for internal:%s to %s:%s\n", file.Name(), private, packageName, public) + } + } + } + } + } + if exposedLinks != "" { + newFile += "//\n" + exposedAs + strings.TrimSuffix(exposedLinks, ", ") + "\n" + exposedLinks = "" + } + } else if strings.HasPrefix(trimmedLine, exposedAs) { + exposedLinks = strings.TrimPrefix(trimmedLine, exposedAs) + } + newFile += line + "\n" + + } + + if changesMade { + absPath, err := filepath.Abs(file.Name()) + if err != nil { + return fmt.Errorf("error getting absolute path: %v", err) + } + tempFilePath := absPath + ".tmp" + + formattedCode, err := format.Source([]byte(newFile)) + if err != nil { + return fmt.Errorf("error formatting Go code: %v", err) + + } + err = os.WriteFile(tempFilePath, formattedCode, 0644) + if err != nil { + return fmt.Errorf("error writing to file: %v", err) + + } + err = os.Rename(tempFilePath, absPath) + if err != nil { + return fmt.Errorf("error renaming file: %v", err) + } + } + + return nil +} + +func isValidDefinition(line string, inGroup *string, insideStruct *bool) bool { + if strings.HasPrefix(line, "//") { + return false + } + if strings.HasPrefix(line, "func ") { + return true + } + + if strings.HasSuffix(line, "struct {") { + *insideStruct = true + return true + } + + if *insideStruct { + if strings.HasSuffix(line, "}") && !strings.HasSuffix(line, "{}") { + *insideStruct = false + } + return false + } + + if *inGroup != "" { + if line == ")" { + *inGroup = "" + } + if line != "" { + return true + } + return false + } + + // Check if the line starts a grouped definition + if strings.HasPrefix(line, "type (") || + strings.HasPrefix(line, "const (") || + strings.HasPrefix(line, "var (") { + *inGroup = strings.Fields(line)[0] + return false + } + + // Handle single-line struct, variable, or function definitions + if strings.HasPrefix(line, "var ") || + strings.HasPrefix(line, "const ") || + strings.HasPrefix(line, "type ") { + return true + } + return false +} + +func isValidDefinitionWithMatch(line, private string, inGroup string, insideStruct bool) bool { + tokens := strings.Fields(line) + if strings.HasPrefix(line, "func "+private+"(") { + return true + } + + if strings.HasSuffix(line, " struct {") { + for _, strToken := range tokens { + if strToken == private { + return true + } + } + return false + } + + if insideStruct { + fmt.Println("should never hit") + return false + } + + if inGroup == "const" || inGroup == "var" { + return tokens[0] == private + } else if inGroup == "type" { + return len(tokens) > 2 && tokens[2] == private + } + + // Handle single-line struct, variable, or function definitions + if strings.HasPrefix(line, "var ") || + strings.HasPrefix(line, "const ") || + strings.HasPrefix(line, "type ") { + for _, strToken := range tokens { + if strToken == private { + return true + } + } + } + return false +} diff --git a/internal/context.go b/internal/context.go index 32dde60b9..9c8b2d601 100644 --- a/internal/context.go +++ b/internal/context.go @@ -38,6 +38,8 @@ import ( // API boundaries. // // Context's methods may be called by multiple goroutines simultaneously. +// +// Exposed as: [go.temporal.io/sdk/workflow.Context] type Context interface { // Deadline returns the time when work done on behalf of this context // should be canceled. Deadline returns ok==false when no deadline is @@ -173,15 +175,21 @@ func Background() Context { } // ErrCanceled is the error returned by Context.Err when the context is canceled. +// +// Exposed as: [go.temporal.io/sdk/workflow.ErrCanceled] var ErrCanceled = NewCanceledError() // ErrDeadlineExceeded is the error returned by Context.Err when the context's // deadline passes. +// +// Exposed as: [go.temporal.io/sdk/workflow.ErrDeadlineExceeded] var ErrDeadlineExceeded = NewTimeoutError("deadline exceeded", enumspb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, nil) // A CancelFunc tells an operation to abandon its work. // A CancelFunc does not wait for the work to stop. // After the first call, subsequent calls to a CancelFunc do nothing. +// +// Exposed as: [go.temporal.io/sdk/workflow.CancelFunc] type CancelFunc func() // WithCancel returns a copy of parent with a new Done channel. The returned @@ -190,6 +198,8 @@ type CancelFunc func() // // Canceling this context releases resources associated with it, so code should // call cancel as soon as the operations running in this Context complete. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithCancel] func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { c := newCancelCtx(parent) propagateCancel(parent, c) @@ -206,6 +216,8 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { // workflow.ExecuteActivity(disconnectedCtx, handleCancellationActivity).Get(disconnectedCtx, nil) // return err // workflow return CanceledError // } +// +// Exposed as: [go.temporal.io/sdk/workflow.NewDisconnectedContext] func NewDisconnectedContext(parent Context) (ctx Context, cancel CancelFunc) { c := newCancelCtx(parent) return c, func() { c.cancel(true, ErrCanceled) } @@ -341,6 +353,8 @@ func (c *cancelCtx) cancel(removeFromParent bool, err error) { // // Use context Values only for request-scoped data that transits processes and // APIs, not for passing optional parameters to functions. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithValue] func WithValue(parent Context, key interface{}, val interface{}) Context { return &valueCtx{parent, key, val} } diff --git a/internal/error.go b/internal/error.go index bfa474318..0c72f8806 100644 --- a/internal/error.go +++ b/internal/error.go @@ -121,6 +121,8 @@ Workflow consumers will get an instance of *WorkflowExecutionError. This error w type ( // ApplicationErrorOptions represents a combination of error attributes and additional requests. // All fields are optional, providing flexibility in error customization. + // + // Exposed as: [go.temporal.io/sdk/temporal.ApplicationErrorOptions] ApplicationErrorOptions struct { // NonRetryable indicates if the error should not be retried regardless of the retry policy. NonRetryable bool @@ -137,6 +139,8 @@ type ( } // ApplicationError returned from activity implementations with message and optional details. + // + // Exposed as: [go.temporal.io/sdk/temporal.ApplicationError] ApplicationError struct { temporalError msg string @@ -148,6 +152,8 @@ type ( } // TimeoutError returned when activity or child workflow timed out. + // + // Exposed as: [go.temporal.io/sdk/temporal.TimeoutError] TimeoutError struct { temporalError msg string @@ -157,17 +163,23 @@ type ( } // CanceledError returned when operation was canceled. + // + // Exposed as: [go.temporal.io/sdk/temporal.CanceledError] CanceledError struct { temporalError details converter.EncodedValues } // TerminatedError returned when workflow was terminated. + // + // Exposed as: [go.temporal.io/sdk/temporal.TerminatedError] TerminatedError struct { temporalError } // PanicError contains information about panicked workflow/activity. + // + // Exposed as: [go.temporal.io/sdk/temporal.PanicError] PanicError struct { temporalError value interface{} @@ -182,6 +194,8 @@ type ( } // ContinueAsNewError contains information about how to continue the workflow as new. + // + // Exposed as: [go.temporal.io/sdk/workflow.ContinueAsNewError] ContinueAsNewError struct { // params *ExecuteWorkflowParams WorkflowType *WorkflowType @@ -212,6 +226,8 @@ type ( } // ContinueAsNewErrorOptions specifies optional attributes to be carried over to the next run. + // + // Exposed as: [go.temporal.io/sdk/workflow.ContinueAsNewErrorOptions] ContinueAsNewErrorOptions struct { // RetryPolicy specifies the retry policy to be used for the next run. // If nil, the current workflow's retry policy will be used. @@ -222,6 +238,8 @@ type ( UnknownExternalWorkflowExecutionError struct{} // ServerError can be returned from server. + // + // Exposed as: [go.temporal.io/sdk/temporal.ServerError] ServerError struct { temporalError msg string @@ -231,6 +249,8 @@ type ( // ActivityError is returned from workflow when activity returned an error. // Unwrap this error to get actual cause. + // + // Exposed as: [go.temporal.io/sdk/temporal.ActivityError] ActivityError struct { temporalError scheduledEventID int64 @@ -244,6 +264,8 @@ type ( // ChildWorkflowExecutionError is returned from workflow when child workflow returned an error. // Unwrap this error to get actual cause. + // + // Exposed as: [go.temporal.io/sdk/temporal.ChildWorkflowExecutionError] ChildWorkflowExecutionError struct { temporalError namespace string @@ -259,6 +281,8 @@ type ( // NexusOperationError is an error returned when a Nexus Operation has failed. // // NOTE: Experimental + // + // Exposed as: [go.temporal.io/sdk/temporal.NexusOperationError] NexusOperationError struct { // The raw proto failure object this error was created from. Failure *failurepb.Failure @@ -288,6 +312,8 @@ type ( // WorkflowExecutionError is returned from workflow. // Unwrap this error to get actual cause. + // + // Exposed as: [go.temporal.io/sdk/temporal.WorkflowExecutionError] WorkflowExecutionError struct { workflowID string runID string @@ -321,6 +347,8 @@ var ( goErrType = reflect.TypeOf(errors.New("")).Elem().Name() // ErrNoData is returned when trying to extract strong typed data while there is no data available. + // + // Exposed as: [go.temporal.io/sdk/temporal.ErrNoData] ErrNoData = errors.New("no data available") // ErrTooManyArg is returned when trying to extract strong typed data with more arguments than available data. @@ -331,12 +359,18 @@ var ( // activity require human interaction (like approve an expense report), the activity could return activity.ErrResultPending // which indicate the activity is not done yet. Then, when the waited human action happened, it needs to trigger something // that could report the activity completed event to temporal server via Client.CompleteActivity() API. + // + // Exposed as: [go.temporal.io/sdk/activity.ErrResultPending] ErrActivityResultPending = errors.New("not error: do not autocomplete, using Client.CompleteActivity() to complete") // ErrScheduleAlreadyRunning is returned if there's already a running (not deleted) Schedule with the same ID + // + // Exposed as: [go.temporal.io/sdk/temporal.ErrScheduleAlreadyRunning] ErrScheduleAlreadyRunning = errors.New("schedule with this ID is already registered") // ErrSkipScheduleUpdate is used by a user if they want to skip updating a schedule. + // + // Exposed as: [go.temporal.io/sdk/temporal.ErrSkipScheduleUpdate] ErrSkipScheduleUpdate = errors.New("skip schedule update") // ErrMissingWorkflowID is returned when trying to start an async Nexus operation but no workflow ID is set on the request. @@ -352,6 +386,7 @@ func NewApplicationError(msg string, errType string, nonRetryable bool, cause er ) } +// Exposed as: [go.temporal.io/sdk/temporal.NewApplicationErrorWithOptions], [go.temporal.io/sdk/temporal.NewApplicationErrorWithCause], [go.temporal.io/sdk/temporal.NewApplicationError], [go.temporal.io/sdk/temporal.NewNonRetryableApplicationError] func NewApplicationErrorWithOptions(msg string, errType string, options ApplicationErrorOptions) error { applicationErr := &ApplicationError{ msg: msg, @@ -376,6 +411,8 @@ func NewApplicationErrorWithOptions(msg string, errType string, options Applicat // NewTimeoutError creates TimeoutError instance. // Use NewHeartbeatTimeoutError to create heartbeat TimeoutError. +// +// Exposed as: [go.temporal.io/sdk/temporal.NewTimeoutError] func NewTimeoutError(msg string, timeoutType enumspb.TimeoutType, cause error, lastHeartbeatDetails ...interface{}) error { timeoutErr := &TimeoutError{ msg: msg, @@ -394,11 +431,15 @@ func NewTimeoutError(msg string, timeoutType enumspb.TimeoutType, cause error, l } // NewHeartbeatTimeoutError creates TimeoutError instance. +// +// Exposed as: [go.temporal.io/sdk/temporal.NewHeartbeatTimeoutError] func NewHeartbeatTimeoutError(details ...interface{}) error { return NewTimeoutError("heartbeat timeout", enumspb.TIMEOUT_TYPE_HEARTBEAT, nil, details...) } // NewCanceledError creates CanceledError instance. +// +// Exposed as: [go.temporal.io/sdk/temporal.NewCanceledError] func NewCanceledError(details ...interface{}) error { if len(details) == 1 { if d, ok := details[0].(*EncodedValues); ok { @@ -498,6 +539,8 @@ func IsCanceledError(err error) bool { // ctx := WithWorkflowTaskQueue(ctx, "example-group") // wfn - workflow function. for new execution it can be different from the currently running. // args - arguments for the new workflow. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewContinueAsNewError] func NewContinueAsNewError(ctx Context, wfn interface{}, args ...interface{}) error { i := getWorkflowOutboundInterceptor(ctx) // Put header on context before executing @@ -506,6 +549,8 @@ func NewContinueAsNewError(ctx Context, wfn interface{}, args ...interface{}) er } // NewContinueAsNewErrorWithOptions creates ContinueAsNewError instance with additional options. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewContinueAsNewErrorWithOptions] func NewContinueAsNewErrorWithOptions(ctx Context, options ContinueAsNewErrorOptions, wfn interface{}, args ...interface{}) error { err := NewContinueAsNewError(ctx, wfn, args...) diff --git a/internal/failure_converter.go b/internal/failure_converter.go index c306f1cc3..3f47de489 100644 --- a/internal/failure_converter.go +++ b/internal/failure_converter.go @@ -38,11 +38,15 @@ import ( var defaultFailureConverter = NewDefaultFailureConverter(DefaultFailureConverterOptions{}) // GetDefaultFailureConverter returns the default failure converter used by Temporal. +// +// Exposed as: [go.temporal.io/sdk/temporal.GetDefaultFailureConverter] func GetDefaultFailureConverter() converter.FailureConverter { return defaultFailureConverter } // DefaultFailureConverterOptions are optional parameters for DefaultFailureConverter creation. +// +// Exposed as: [go.temporal.io/sdk/temporal.DefaultFailureConverterOptions] type DefaultFailureConverterOptions struct { // Optional: Sets DataConverter to customize serialization/deserialization of fields. // default: Default data converter @@ -54,12 +58,16 @@ type DefaultFailureConverterOptions struct { } // DefaultFailureConverter seralizes errors with the option to encode common parameters under Failure.EncodedAttributes +// +// Exposed as: [go.temporal.io/sdk/temporal.DefaultFailureConverter] type DefaultFailureConverter struct { dataConverter converter.DataConverter encodeCommonAttributes bool } // NewDefaultFailureConverter creates new instance of DefaultFailureConverter. +// +// Exposed as: [go.temporal.io/sdk/temporal.NewDefaultFailureConverter] func NewDefaultFailureConverter(opt DefaultFailureConverterOptions) *DefaultFailureConverter { if opt.DataConverter == nil { opt.DataConverter = converter.GetDefaultDataConverter() @@ -163,10 +171,10 @@ func (dfc *DefaultFailureConverter) ErrorToFailure(err error) *failurepb.Failure case *NexusOperationError: failureInfo := &failurepb.NexusOperationFailureInfo{ ScheduledEventId: err.ScheduledEventID, - Endpoint: err.Endpoint, - Service: err.Service, - Operation: err.Operation, - OperationId: err.OperationID, + Endpoint: err.Endpoint, + Service: err.Service, + Operation: err.Operation, + OperationId: err.OperationID, } failure.FailureInfo = &failurepb.Failure_NexusOperationExecutionFailureInfo{NexusOperationExecutionFailureInfo: failureInfo} default: // All unknown errors are considered to be retryable ApplicationFailureInfo. diff --git a/internal/grpc_dialer.go b/internal/grpc_dialer.go index c0d44702d..618efab98 100644 --- a/internal/grpc_dialer.go +++ b/internal/grpc_dialer.go @@ -54,6 +54,8 @@ type ( const ( // LocalHostPort is a default host:port for worker and client to connect to. + // + // Exposed as: [go.temporal.io/sdk/client.DefaultHostPort] LocalHostPort = "localhost:7233" // defaultServiceConfig is a default gRPC connection service config which enables DNS round-robin between IPs. diff --git a/internal/interceptor.go b/internal/interceptor.go index 914cfd764..510060cf2 100644 --- a/internal/interceptor.go +++ b/internal/interceptor.go @@ -37,6 +37,10 @@ import ( // Interceptor is a common interface for all interceptors. See documentation in // the interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.Interceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.Interceptor] type Interceptor interface { ClientInterceptor WorkerInterceptor @@ -44,6 +48,10 @@ type Interceptor interface { // WorkerInterceptor is a common interface for all interceptors. See // documentation in the interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkerInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkerInterceptor] type WorkerInterceptor interface { // InterceptActivity is called before each activity interception needed with // the next interceptor in the chain. @@ -59,6 +67,10 @@ type WorkerInterceptor interface { // ActivityInboundInterceptor is an interface for all activity calls originating // from the server. See documentation in the interceptor package for more // details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityInboundInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityInboundInterceptor] type ActivityInboundInterceptor interface { // Init is the first call of this interceptor. Implementations can change/wrap // the outbound interceptor before calling Init on the next interceptor. @@ -72,6 +84,10 @@ type ActivityInboundInterceptor interface { } // ExecuteActivityInput is the input to ActivityInboundInterceptor.ExecuteActivity. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ExecuteActivityInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ExecuteActivityInput] type ExecuteActivityInput struct { Args []interface{} } @@ -79,6 +95,10 @@ type ExecuteActivityInput struct { // ActivityOutboundInterceptor is an interface for all activity calls // originating from the SDK. See documentation in the interceptor package for // more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityOutboundInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityOutboundInterceptor] type ActivityOutboundInterceptor interface { // GetInfo intercepts activity.GetInfo. GetInfo(ctx context.Context) ActivityInfo @@ -107,6 +127,10 @@ type ActivityOutboundInterceptor interface { // WorkflowInboundInterceptor is an interface for all workflow calls originating // from the server. See documentation in the interceptor package for more // details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowInboundInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowInboundInterceptor] type WorkflowInboundInterceptor interface { // Init is the first call of this interceptor. Implementations can change/wrap // the outbound interceptor before calling Init on the next interceptor. @@ -146,11 +170,19 @@ type WorkflowInboundInterceptor interface { // ExecuteWorkflowInput is the input to // WorkflowInboundInterceptor.ExecuteWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ExecuteWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ExecuteWorkflowInput] type ExecuteWorkflowInput struct { Args []interface{} } // HandleSignalInput is the input to WorkflowInboundInterceptor.HandleSignal. +// +// Exposed as: [go.temporal.io/sdk/interceptor.HandleSignalInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.HandleSignalInput] type HandleSignalInput struct { SignalName string // Arg is the signal argument. It is presented as a primitive payload since @@ -159,12 +191,20 @@ type HandleSignalInput struct { } // UpdateInput carries the name and arguments of a workflow update invocation. +// +// Exposed as: [go.temporal.io/sdk/interceptor.UpdateInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.UpdateInput] type UpdateInput struct { Name string Args []interface{} } // HandleQueryInput is the input to WorkflowInboundInterceptor.HandleQuery. +// +// Exposed as: [go.temporal.io/sdk/interceptor.HandleQueryInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.HandleQueryInput] type HandleQueryInput struct { QueryType string Args []interface{} @@ -173,6 +213,10 @@ type HandleQueryInput struct { // ExecuteNexusOperationInput is the input to WorkflowOutboundInterceptor.ExecuteNexusOperation. // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/interceptor.ExecuteNexusOperationInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ExecuteNexusOperationInput] type ExecuteNexusOperationInput struct { // Client to start the operation with. Client NexusClient @@ -189,6 +233,10 @@ type ExecuteNexusOperationInput struct { // RequestCancelNexusOperationInput is the input to WorkflowOutboundInterceptor.RequestCancelNexusOperation. // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/interceptor.RequestCancelNexusOperationInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.RequestCancelNexusOperationInput] type RequestCancelNexusOperationInput struct { // Client that was used to start the operation. Client NexusClient @@ -203,6 +251,10 @@ type RequestCancelNexusOperationInput struct { // WorkflowOutboundInterceptor is an interface for all workflow calls // originating from the SDK. See documentation in the interceptor package for // more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowOutboundInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowOutboundInterceptor] type WorkflowOutboundInterceptor interface { // Go intercepts workflow.Go. Go(ctx Context, name string, f func(ctx Context)) Context @@ -350,6 +402,10 @@ type WorkflowOutboundInterceptor interface { // ClientInterceptor for providing a ClientOutboundInterceptor to intercept // certain workflow-specific client calls from the SDK. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientInterceptor] type ClientInterceptor interface { // This is called on client creation if set via client options InterceptClient(next ClientOutboundInterceptor) ClientOutboundInterceptor @@ -360,6 +416,10 @@ type ClientInterceptor interface { // ClientOutboundInterceptor is an interface for certain workflow-specific calls // originating from the SDK. See documentation in the interceptor package for // more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientOutboundInterceptor] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientOutboundInterceptor] type ClientOutboundInterceptor interface { // ExecuteWorkflow intercepts client.Client.ExecuteWorkflow. // interceptor.Header will return a non-nil map for this context. @@ -411,6 +471,10 @@ type ClientOutboundInterceptor interface { // ClientOutboundInterceptor.UpdateWorkflow // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientUpdateWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientUpdateWorkflowInput] type ClientUpdateWorkflowInput struct { UpdateID string WorkflowID string @@ -421,6 +485,7 @@ type ClientUpdateWorkflowInput struct { WaitForStage WorkflowUpdateStage } +// Exposed as: [go.temporal.io/sdk/interceptor.ClientUpdateWithStartWorkflowInput] type ClientUpdateWithStartWorkflowInput struct { UpdateOptions *UpdateWorkflowOptions StartWorkflowOperation WithStartWorkflowOperation @@ -443,12 +508,20 @@ type ClientPollWorkflowUpdateOutput struct { // ScheduleClientCreateInput is the input to // ClientOutboundInterceptor.CreateSchedule. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ScheduleClientCreateInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ScheduleClientCreateInput] type ScheduleClientCreateInput struct { Options *ScheduleOptions } // ClientExecuteWorkflowInput is the input to // ClientOutboundInterceptor.ExecuteWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientExecuteWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientExecuteWorkflowInput] type ClientExecuteWorkflowInput struct { Options *StartWorkflowOptions WorkflowType string @@ -457,6 +530,10 @@ type ClientExecuteWorkflowInput struct { // ClientSignalWorkflowInput is the input to // ClientOutboundInterceptor.SignalWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientSignalWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientSignalWorkflowInput] type ClientSignalWorkflowInput struct { WorkflowID string RunID string @@ -466,6 +543,10 @@ type ClientSignalWorkflowInput struct { // ClientSignalWithStartWorkflowInput is the input to // ClientOutboundInterceptor.SignalWithStartWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientSignalWithStartWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientSignalWithStartWorkflowInput] type ClientSignalWithStartWorkflowInput struct { SignalName string SignalArg interface{} @@ -476,6 +557,10 @@ type ClientSignalWithStartWorkflowInput struct { // ClientCancelWorkflowInput is the input to // ClientOutboundInterceptor.CancelWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientCancelWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientCancelWorkflowInput] type ClientCancelWorkflowInput struct { WorkflowID string RunID string @@ -483,6 +568,10 @@ type ClientCancelWorkflowInput struct { // ClientTerminateWorkflowInput is the input to // ClientOutboundInterceptor.TerminateWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientTerminateWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientTerminateWorkflowInput] type ClientTerminateWorkflowInput struct { WorkflowID string RunID string @@ -492,6 +581,10 @@ type ClientTerminateWorkflowInput struct { // ClientQueryWorkflowInput is the input to // ClientOutboundInterceptor.QueryWorkflow. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientQueryWorkflowInput] +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientQueryWorkflowInput] type ClientQueryWorkflowInput struct { WorkflowID string RunID string diff --git a/internal/interceptor_base.go b/internal/interceptor_base.go index ff00e89e6..72c1bdbf5 100644 --- a/internal/interceptor_base.go +++ b/internal/interceptor_base.go @@ -33,6 +33,8 @@ import ( // InterceptorBase is a default implementation of Interceptor meant for // embedding. See documentation in the interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.InterceptorBase] type InterceptorBase struct { ClientInterceptorBase WorkerInterceptorBase @@ -40,8 +42,11 @@ type InterceptorBase struct { // WorkerInterceptorBase is a default implementation of WorkerInterceptor meant // for embedding. See documentation in the interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkerInterceptorBase] type WorkerInterceptorBase struct{} +// Exposed as: [go.temporal.io/sdk/interceptor.WorkerInterceptor] var _ WorkerInterceptor = &WorkerInterceptorBase{} // InterceptActivity implements WorkerInterceptor.InterceptActivity. @@ -65,10 +70,13 @@ func (*WorkerInterceptorBase) mustEmbedWorkerInterceptorBase() {} // ActivityInboundInterceptorBase is a default implementation of // ActivityInboundInterceptor meant for embedding. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityInboundInterceptorBase] type ActivityInboundInterceptorBase struct { Next ActivityInboundInterceptor } +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityInboundInterceptor] var _ ActivityInboundInterceptor = &ActivityInboundInterceptorBase{} // Init implements ActivityInboundInterceptor.Init. @@ -89,10 +97,13 @@ func (*ActivityInboundInterceptorBase) mustEmbedActivityInboundInterceptorBase() // ActivityOutboundInterceptorBase is a default implementation of // ActivityOutboundInterceptor meant for embedding. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityOutboundInterceptorBase] type ActivityOutboundInterceptorBase struct { Next ActivityOutboundInterceptor } +// Exposed as: [go.temporal.io/sdk/interceptor.ActivityOutboundInterceptor] var _ ActivityOutboundInterceptor = &ActivityOutboundInterceptorBase{} // GetInfo implements ActivityOutboundInterceptor.GetInfo. @@ -138,10 +149,13 @@ func (*ActivityOutboundInterceptorBase) mustEmbedActivityOutboundInterceptorBase // WorkflowInboundInterceptorBase is a default implementation of // WorkflowInboundInterceptor meant for embedding. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowInboundInterceptorBase] type WorkflowInboundInterceptorBase struct { Next WorkflowInboundInterceptor } +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowInboundInterceptor] var _ WorkflowInboundInterceptor = &WorkflowInboundInterceptorBase{} // Init implements WorkflowInboundInterceptor.Init. @@ -179,10 +193,13 @@ func (*WorkflowInboundInterceptorBase) mustEmbedWorkflowInboundInterceptorBase() // WorkflowOutboundInterceptorBase is a default implementation of // WorkflowOutboundInterceptor meant for embedding. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowOutboundInterceptorBase] type WorkflowOutboundInterceptorBase struct { Next WorkflowOutboundInterceptor } +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowOutboundInterceptor] var _ WorkflowOutboundInterceptor = &WorkflowOutboundInterceptorBase{} // Go implements WorkflowOutboundInterceptor.Go. @@ -449,8 +466,11 @@ func (*WorkflowOutboundInterceptorBase) mustEmbedWorkflowOutboundInterceptorBase // ClientInterceptorBase is a default implementation of ClientInterceptor meant // for embedding. See documentation in the interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientInterceptorBase] type ClientInterceptorBase struct{} +// Exposed as: [go.temporal.io/sdk/interceptor.ClientInterceptor] var _ ClientInterceptor = &ClientInterceptorBase{} // InterceptClient implements ClientInterceptor.InterceptClient. @@ -465,10 +485,13 @@ func (*ClientInterceptorBase) mustEmbedClientInterceptorBase() {} // ClientOutboundInterceptorBase is a default implementation of // ClientOutboundInterceptor meant for embedding. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.ClientOutboundInterceptorBase] type ClientOutboundInterceptorBase struct { Next ClientOutboundInterceptor } +// Exposed as: [go.temporal.io/sdk/interceptor.ClientOutboundInterceptor] var _ ClientOutboundInterceptor = &ClientOutboundInterceptorBase{} func (c *ClientOutboundInterceptorBase) UpdateWorkflow( diff --git a/internal/interceptor_header.go b/internal/interceptor_header.go index b0a379816..a96f2db40 100644 --- a/internal/interceptor_header.go +++ b/internal/interceptor_header.go @@ -34,6 +34,8 @@ type headerKey struct{} // Header provides Temporal header information from the context for reading or // writing during specific interceptor calls. See documentation in the // interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.Header] func Header(ctx context.Context) map[string]*commonpb.Payload { m, _ := ctx.Value(headerKey{}).(map[string]*commonpb.Payload) return m @@ -85,6 +87,8 @@ func headerPropagated(ctx context.Context, ctxProps []ContextPropagator) (*commo // WorkflowHeader provides Temporal header information from the workflow context // for reading or writing during specific interceptor calls. See documentation // in the interceptor package for more details. +// +// Exposed as: [go.temporal.io/sdk/interceptor.WorkflowHeader] func WorkflowHeader(ctx Context) map[string]*commonpb.Payload { m, _ := ctx.Value(headerKey{}).(map[string]*commonpb.Payload) return m diff --git a/internal/nexus_operations.go b/internal/nexus_operations.go index 6a73e6fc8..7d480f614 100644 --- a/internal/nexus_operations.go +++ b/internal/nexus_operations.go @@ -431,4 +431,5 @@ func (t *testEnvWorkflowRunForNexusOperations) GetWithOptions(ctx context.Contex panic("not implemented in the test environment") } +// Exposed as: [go.temporal.io/sdk/client.WorkflowRun] var _ WorkflowRun = &testEnvWorkflowRunForNexusOperations{} diff --git a/internal/schedule_client.go b/internal/schedule_client.go index c6ea706b2..3d48859f7 100644 --- a/internal/schedule_client.go +++ b/internal/schedule_client.go @@ -35,6 +35,8 @@ type ( // time in StructuredCalendarSpec. If end < start, then end is interpreted as // equal to start. This means you can use a Range with start set to a value, and // end and step unset (defaulting to 0) to represent a single value. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleRange] ScheduleRange struct { // Start of the range (inclusive) Start int @@ -52,6 +54,8 @@ type ( // A timestamp matches if at least one range of each field matches the // corresponding fields of the timestamp, except for year: if year is missing, // that means all years match. For all fields besides year, at least one Range must be present to match anything. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleCalendarSpec] ScheduleCalendarSpec struct { // Second range to match (0-59). // @@ -93,6 +97,8 @@ type ( } // ScheduleBackfill desribes a time periods and policy and takes Actions as if that time passed by right now, all at once. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleBackfill] ScheduleBackfill struct { // Start - start of the range to evaluate schedule in. Start time.Time @@ -114,6 +120,8 @@ type ( // of 19 minutes would match every `xx:19:00`. An `every` of 28 days with `offset` zero would match `2022-02-17T00:00:00Z` // (among other times). The same `every` with `offset` of 3 days, 5 hours, and 23 minutes would match `2022-02-20T05:23:00Z` // instead. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleIntervalSpec] ScheduleIntervalSpec struct { // Every - describes the period to repeat the interval. Every time.Duration @@ -127,6 +135,8 @@ type ( // The times are the union of Calendars, Intervals, and CronExpressions, minus the Skip times. These times // never change, except that the definition of a time zone can change over time (most commonly, when daylight saving // time policy changes for an area). To create a totally self-contained ScheduleSpec, use UTC. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleSpec] ScheduleSpec struct { // Calendars - Calendar-based specifications of times Calendars []ScheduleCalendarSpec @@ -231,6 +241,8 @@ type ( } // ScheduleWorkflowAction implements ScheduleAction to launch a workflow. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleWorkflowAction] ScheduleWorkflowAction struct { // ID - The business identifier of the workflow execution. // The workflow ID of the started workflow may not match this exactly, @@ -288,6 +300,8 @@ type ( } // ScheduleOptions configure the parameters for creating a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleOptions] ScheduleOptions struct { // ID - The business identifier of the schedule. ID string @@ -370,6 +384,8 @@ type ( } // ScheduleWorkflowExecution contains details on a workflows execution stared by a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleWorkflowExecution] ScheduleWorkflowExecution struct { // WorkflowID - The ID of the workflow execution WorkflowID string @@ -380,6 +396,8 @@ type ( } // ScheduleInfo describes other information about a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleInfo] ScheduleInfo struct { // NumActions - Number of actions taken by this schedule. NumActions int @@ -410,6 +428,8 @@ type ( } // ScheduleDescription describes the current Schedule details from ScheduleHandle.Describe. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleDescription] ScheduleDescription struct { // Schedule - Describes the modifiable fields of a schedule. Schedule Schedule @@ -436,6 +456,8 @@ type ( } // SchedulePolicies describes the current polcies of a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.SchedulePolicies] SchedulePolicies struct { // Overlap - Controls what happens when an Action would be started by a Schedule at the same time that an older Action is still // running. @@ -450,6 +472,8 @@ type ( } // ScheduleState describes the current state of a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleState] ScheduleState struct { // Note - Informative human-readable message with contextual notes, e.g. the reason // a Schedule is paused. The system may overwrite this message on certain @@ -469,6 +493,8 @@ type ( } // Schedule describes a created schedule. + // + // Exposed as: [go.temporal.io/sdk/client.Schedule] Schedule struct { // Action - Which Action to take Action ScheduleAction @@ -484,6 +510,8 @@ type ( } // ScheduleUpdate describes the desired new schedule from ScheduleHandle.Update. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleUpdate] ScheduleUpdate struct { // Schedule - New schedule to replace the existing schedule with Schedule *Schedule @@ -499,12 +527,16 @@ type ( } // ScheduleUpdateInput describes the current state of the schedule to be updated. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleUpdateInput] ScheduleUpdateInput struct { // Description - current description of the schedule Description ScheduleDescription } // ScheduleUpdateOptions configure the parameters for updating a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleUpdateOptions] ScheduleUpdateOptions struct { // DoUpdate - Takes a description of the schedule and returns the new desired schedule. // If update returns ErrSkipScheduleUpdate response and no update will occur. @@ -513,12 +545,16 @@ type ( } // ScheduleTriggerOptions configure the parameters for triggering a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleTriggerOptions] ScheduleTriggerOptions struct { // Overlap - If specified, policy to override the schedules default overlap policy. Overlap enumspb.ScheduleOverlapPolicy } // SchedulePauseOptions configure the parameters for pausing a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.SchedulePauseOptions] SchedulePauseOptions struct { // Note - Informative human-readable message with contextual notes. // Optional: defaulted to 'Paused via Go SDK' @@ -526,6 +562,8 @@ type ( } // ScheduleUnpauseOptions configure the parameters for unpausing a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleUnpauseOptions] ScheduleUnpauseOptions struct { // Note - Informative human-readable message with contextual notes. // Optional: defaulted to 'Unpaused via Go SDK' @@ -533,6 +571,8 @@ type ( } // ScheduleBackfillOptions configure the parameters for backfilling a schedule. + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleBackfillOptions] ScheduleBackfillOptions struct { // Backfill - Time periods to backfill the schedule. Backfill []ScheduleBackfill @@ -571,6 +611,8 @@ type ( } // ScheduleActionResult describes when a schedule action took place + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleActionResult] ScheduleActionResult struct { // ScheduleTime - Time that the Action was scheduled for, including jitter. ScheduleTime time.Time @@ -584,6 +626,8 @@ type ( } // ScheduleListEntry + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleListEntry] ScheduleListEntry struct { // ID - The business identifier of the schedule. ID string @@ -623,6 +667,8 @@ type ( } // ScheduleListOptions are the parameters for configuring listing schedules + // + // Exposed as: [go.temporal.io/sdk/client.ScheduleListOptions] ScheduleListOptions struct { // PageSize - How many results to fetch from the Server at a time. // Optional: defaulted to 1000 diff --git a/internal/session.go b/internal/session.go index 67c112f10..6c2d7da99 100644 --- a/internal/session.go +++ b/internal/session.go @@ -43,6 +43,8 @@ type ( // SessionID is a uuid generated when CreateSession() or RecreateSession() // is called and can be used to uniquely identify a session. // HostName specifies which host is executing the session + // + // Exposed as: [go.temporal.io/sdk/workflow.SessionInfo] SessionInfo struct { SessionID string HostName string @@ -61,6 +63,8 @@ type ( // HeartbeatTimeout: optional, default 20s // Specifies the heartbeat timeout. If heartbeat is not received by server // within the timeout, the session will be declared as failed + // + // Exposed as: [go.temporal.io/sdk/workflow.SessionOptions] SessionOptions struct { ExecutionTimeout time.Duration CreationTimeout time.Duration @@ -104,8 +108,14 @@ type ( // Session State enum const ( + // + // Exposed as: [go.temporal.io/sdk/workflow.SessionStateOpen] SessionStateOpen SessionState = iota + // + // Exposed as: [go.temporal.io/sdk/workflow.SessionStateFailed] SessionStateFailed + // + // Exposed as: [go.temporal.io/sdk/workflow.SessionStateClosed] SessionStateClosed ) @@ -125,6 +135,8 @@ const ( var ( // ErrSessionFailed is the error returned when user tries to execute an activity but the // session it belongs to has already failed + // + // Exposed as: [go.temporal.io/sdk/workflow.ErrSessionFailed] ErrSessionFailed = errors.New("session has failed") errFoundExistingOpenSession = errors.New("found exisiting open session in the context") ) @@ -181,6 +193,8 @@ var ( // // Handle activity error // } // ... // execute more activities using sessionCtx +// +// Exposed as: [go.temporal.io/sdk/workflow.CreateSession] func CreateSession(ctx Context, sessionOptions *SessionOptions) (Context, error) { options := getActivityOptions(ctx) baseTaskqueue := options.TaskQueueName @@ -198,6 +212,8 @@ func CreateSession(ctx Context, sessionOptions *SessionOptions) (Context, error) // The main usage of RecreateSession is for long sessions that are split into multiple runs. At the end of // one run, complete the current session, get recreateToken from sessionInfo by calling SessionInfo.GetRecreateToken() // and pass the token to the next run. In the new run, session can be recreated using that token. +// +// Exposed as: [go.temporal.io/sdk/workflow.RecreateSession] func RecreateSession(ctx Context, recreateToken []byte, sessionOptions *SessionOptions) (Context, error) { recreateParams, err := deserializeRecreateToken(recreateToken) if err != nil { @@ -213,6 +229,8 @@ func RecreateSession(ctx Context, recreateToken []byte, sessionOptions *SessionO // After a session has completed, user can continue to use the context, but the activities will be scheduled // on the normal taskQueue (as user specified in ActivityOptions) and may be picked up by another worker since // it's not in a session. +// +// Exposed as: [go.temporal.io/sdk/workflow.CompleteSession] func CompleteSession(ctx Context) { sessionInfo := getSessionInfo(ctx) if sessionInfo == nil || sessionInfo.SessionState != SessionStateOpen { @@ -248,6 +266,8 @@ func CompleteSession(ctx Context) { // session has failed, and created a new one on it), the most recent sessionInfo will be returned. // // This API will return nil if there's no sessionInfo in the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetSessionInfo] func GetSessionInfo(ctx Context) *SessionInfo { info := getSessionInfo(ctx) if info == nil { diff --git a/internal/tuning.go b/internal/tuning.go index 3a36efe62..c6ea6428a 100644 --- a/internal/tuning.go +++ b/internal/tuning.go @@ -37,6 +37,8 @@ import ( // WorkerTuner allows for the dynamic customization of some aspects of worker behavior. // // WARNING: Custom implementations of SlotSupplier are currently experimental. +// +// Exposed as: [go.temporal.io/sdk/worker.WorkerTuner] type WorkerTuner interface { // GetWorkflowTaskSlotSupplier returns the SlotSupplier used for workflow tasks. GetWorkflowTaskSlotSupplier() SlotSupplier @@ -53,6 +55,8 @@ type WorkerTuner interface { // SlotPermit is a permit to use a slot. // // WARNING: Custom implementations of SlotSupplier are currently experimental. +// +// Exposed as: [go.temporal.io/sdk/worker.SlotPermit] type SlotPermit struct { // UserData is a field that can be used to store arbitrary on a permit by SlotSupplier // implementations. @@ -64,6 +68,8 @@ type SlotPermit struct { // SlotReservationInfo contains information that SlotSupplier instances can use during // reservation calls. It embeds a standard Context. +// +// Exposed as: [go.temporal.io/sdk/worker.SlotReservationInfo] type SlotReservationInfo interface { // TaskQueue returns the task queue for which a slot is being reserved. In the case of local // activities, this is the same as the workflow's task queue. @@ -83,6 +89,8 @@ type SlotReservationInfo interface { // SlotMarkUsedInfo contains information that SlotSupplier instances can use during // SlotSupplier.MarkSlotUsed calls. +// +// Exposed as: [go.temporal.io/sdk/worker.SlotMarkUsedInfo] type SlotMarkUsedInfo interface { // Permit returns the permit that is being marked as used. Permit() *SlotPermit @@ -103,6 +111,8 @@ const ( // SlotReleaseInfo contains information that SlotSupplier instances can use during // SlotSupplier.ReleaseSlot calls. +// +// Exposed as: [go.temporal.io/sdk/worker.SlotReleaseInfo] type SlotReleaseInfo interface { // Permit returns the permit that is being released. Permit() *SlotPermit @@ -119,6 +129,8 @@ type SlotReleaseInfo interface { // local activities when used in conjunction with a WorkerTuner. // // WARNING: Custom implementations of SlotSupplier are currently experimental. +// +// Exposed as: [go.temporal.io/sdk/worker.SlotSupplier] type SlotSupplier interface { // ReserveSlot is called before polling for new tasks. The implementation should block until // a slot is available, then return a permit to use that slot. Implementations must be @@ -176,6 +188,8 @@ func (c *CompositeTuner) GetSessionActivitySlotSupplier() SlotSupplier { } // CompositeTunerOptions are the options used by NewCompositeTuner. +// +// Exposed as: [go.temporal.io/sdk/worker.CompositeTunerOptions] type CompositeTunerOptions struct { // WorkflowSlotSupplier is the SlotSupplier used for workflow tasks. WorkflowSlotSupplier SlotSupplier @@ -192,6 +206,8 @@ type CompositeTunerOptions struct { // NewCompositeTuner creates a WorkerTuner that uses a combination of slot suppliers. // // WARNING: Custom implementations of SlotSupplier are currently experimental. +// +// Exposed as: [go.temporal.io/sdk/worker.NewCompositeTuner] func NewCompositeTuner(options CompositeTunerOptions) (WorkerTuner, error) { return &CompositeTuner{ workflowSlotSupplier: options.WorkflowSlotSupplier, @@ -203,6 +219,8 @@ func NewCompositeTuner(options CompositeTunerOptions) (WorkerTuner, error) { } // FixedSizeTunerOptions are the options used by NewFixedSizeTuner. +// +// Exposed as: [go.temporal.io/sdk/worker.FixedSizeTunerOptions] type FixedSizeTunerOptions struct { // NumWorkflowSlots is the number of slots available for workflow tasks. NumWorkflowSlots int @@ -215,6 +233,8 @@ type FixedSizeTunerOptions struct { } // NewFixedSizeTuner creates a WorkerTuner that uses fixed size slot suppliers. +// +// Exposed as: [go.temporal.io/sdk/worker.NewFixedSizeTuner] func NewFixedSizeTuner(options FixedSizeTunerOptions) (WorkerTuner, error) { if options.NumWorkflowSlots <= 0 { options.NumWorkflowSlots = defaultMaxConcurrentTaskExecutionSize @@ -265,6 +285,8 @@ type FixedSizeSlotSupplier struct { } // NewFixedSizeSlotSupplier creates a new FixedSizeSlotSupplier with the given number of slots. +// +// Exposed as: [go.temporal.io/sdk/worker.NewFixedSizeSlotSupplier] func NewFixedSizeSlotSupplier(numSlots int) (*FixedSizeSlotSupplier, error) { if numSlots <= 0 { return nil, fmt.Errorf("NumSlots must be positive") diff --git a/internal/version.go b/internal/version.go index 5bffe0b7c..6a358f836 100644 --- a/internal/version.go +++ b/internal/version.go @@ -30,6 +30,8 @@ package internal const ( // SDKVersion is a semver (https://semver.org/) that represents the version of this Temporal GoSDK. // Server validates if SDKVersion fits its supported range and rejects request if it doesn't. + // + // Exposed as: [go.temporal.io/sdk/temporal.SDKVersion] SDKVersion = "1.30.1" // SDKName represents the name of the SDK. diff --git a/internal/worker.go b/internal/worker.go index f0ec4c91b..348ccb26a 100644 --- a/internal/worker.go +++ b/internal/worker.go @@ -33,6 +33,8 @@ type ( // WorkerOptions is used to configure a worker instance. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. + // + // Exposed as: [go.temporal.io/sdk/worker.Options] WorkerOptions struct { // Optional: To set the maximum concurrent activity executions this worker can have. // The zero value of this uses the default value. @@ -263,6 +265,8 @@ type ( // code panicking which includes non backwards compatible changes to the workflow code without appropriate // versioning (see workflow.GetVersion). // The default behavior is to block workflow execution until the problem is fixed. +// +// Exposed as: [go.temporal.io/sdk/worker.WorkflowPanicPolicy] type WorkflowPanicPolicy int const ( @@ -270,10 +274,14 @@ const ( // This option causes workflow to get stuck in the workflow task retry loop. // It is expected that after the problem is discovered and fixed the workflows are going to continue // without any additional manual intervention. + // + // Exposed as: [go.temporal.io/sdk/worker.BlockWorkflow] BlockWorkflow WorkflowPanicPolicy = iota // FailWorkflow immediately fails workflow execution if workflow code throws panic or detects non-determinism. // This feature is convenient during development. // WARNING: enabling this in production can cause all open workflows to fail on a single bug or bad deployment. + // + // Exposed as: [go.temporal.io/sdk/worker.FailWorkflow] FailWorkflow ) @@ -292,6 +300,8 @@ func IsReplayNamespace(dn string) bool { // hosted by a single worker process. // // options - configure any worker specific options. +// +// Exposed as: [go.temporal.io/sdk/worker.New] func NewWorker( client Client, taskQueue string, diff --git a/internal/worker_version_sets.go b/internal/worker_version_sets.go index a4e2f6b2a..5040db205 100644 --- a/internal/worker_version_sets.go +++ b/internal/worker_version_sets.go @@ -31,59 +31,87 @@ import ( ) // A stand-in for a Build Id for unversioned Workers. +// +// Exposed as: [go.temporal.io/sdk/client.UnversionedBuildID] const UnversionedBuildID = "" // VersioningIntent indicates whether the user intends certain commands to be run on // a compatible worker build ID version or not. +// +// Exposed as: [go.temporal.io/sdk/temporal.VersioningIntent] type VersioningIntent int const ( // VersioningIntentUnspecified indicates that the SDK should choose the most sensible default // behavior for the type of command, accounting for whether the command will be run on the same // task queue as the current worker. + // + // Exposed as: [go.temporal.io/sdk/temporal.VersioningIntentUnspecified] VersioningIntentUnspecified VersioningIntent = iota // VersioningIntentCompatible indicates that the command should run on a worker with compatible // version if possible. It may not be possible if the target task queue does not also have // knowledge of the current worker's build ID. // // Deprecated: This has the same effect as [VersioningIntentInheritBuildID], use that instead. + // + // Exposed as: [go.temporal.io/sdk/temporal.VersioningIntentCompatible] VersioningIntentCompatible // VersioningIntentDefault indicates that the command should run on the target task queue's // current overall-default build ID. // // Deprecated: This has the same effect as [VersioningIntentUseAssignmentRules], use that instead. + // + // Exposed as: [go.temporal.io/sdk/temporal.VersioningIntentDefault] VersioningIntentDefault // VersioningIntentInheritBuildID indicates the command should inherit the current Build ID of the // Workflow triggering it, and not use Assignment Rules. (Redirect Rules are still applicable) // This is the default behavior for commands running on the same Task Queue as the current worker. + // + // Exposed as: [go.temporal.io/sdk/temporal.VersioningIntentInheritBuildID] VersioningIntentInheritBuildID // VersioningIntentUseAssignmentRules indicates the command should use the latest Assignment Rules // to select a Build ID independently of the workflow triggering it. // This is the default behavior for commands not running on the same Task Queue as the current worker. + // + // Exposed as: [go.temporal.io/sdk/temporal.VersioningIntentUseAssignmentRules] VersioningIntentUseAssignmentRules ) // TaskReachability specifies which category of tasks may reach a worker on a versioned task queue. // Used both in a reachability query and its response. +// +// Exposed as: [go.temporal.io/sdk/client.TaskReachability] type TaskReachability int const ( // TaskReachabilityUnspecified indicates the reachability was not specified + // + // Exposed as: [go.temporal.io/sdk/client.TaskReachabilityUnspecified] TaskReachabilityUnspecified = iota // TaskReachabilityNewWorkflows indicates the Build Id might be used by new workflows + // + // Exposed as: [go.temporal.io/sdk/client.TaskReachabilityNewWorkflows] TaskReachabilityNewWorkflows // TaskReachabilityExistingWorkflows indicates the Build Id might be used by open workflows // and/or closed workflows. + // + // Exposed as: [go.temporal.io/sdk/client.TaskReachabilityExistingWorkflows] TaskReachabilityExistingWorkflows // TaskReachabilityOpenWorkflows indicates the Build Id might be used by open workflows. + // + // Exposed as: [go.temporal.io/sdk/client.TaskReachabilityOpenWorkflows] TaskReachabilityOpenWorkflows // TaskReachabilityClosedWorkflows indicates the Build Id might be used by closed workflows + // + // Exposed as: [go.temporal.io/sdk/client.TaskReachabilityClosedWorkflows] TaskReachabilityClosedWorkflows ) type ( // UpdateWorkerBuildIdCompatibilityOptions is the input to // Client.UpdateWorkerBuildIdCompatibility. + // + // Exposed as: [go.temporal.io/sdk/client.UpdateWorkerBuildIdCompatibilityOptions] UpdateWorkerBuildIdCompatibilityOptions struct { // The task queue to update the version sets of. TaskQueue string @@ -101,17 +129,25 @@ type ( UpdateBuildIDOp interface { targetedBuildId() string } + // + // Exposed as: [go.temporal.io/sdk/client.BuildIDOpAddNewIDInNewDefaultSet] BuildIDOpAddNewIDInNewDefaultSet struct { BuildID string } + // + // Exposed as: [go.temporal.io/sdk/client.BuildIDOpAddNewCompatibleVersion] BuildIDOpAddNewCompatibleVersion struct { BuildID string ExistingCompatibleBuildID string MakeSetDefault bool } + // + // Exposed as: [go.temporal.io/sdk/client.BuildIDOpPromoteSet] BuildIDOpPromoteSet struct { BuildID string } + // + // Exposed as: [go.temporal.io/sdk/client.BuildIDOpPromoteIDWithinSet] BuildIDOpPromoteIDWithinSet struct { BuildID string } @@ -159,11 +195,13 @@ func (uw *UpdateWorkerBuildIdCompatibilityOptions) validateAndConvertToProto() ( return req, nil } +// Exposed as: [go.temporal.io/sdk/client.GetWorkerBuildIdCompatibilityOptions] type GetWorkerBuildIdCompatibilityOptions struct { TaskQueue string MaxSets int } +// Exposed as: [go.temporal.io/sdk/client.GetWorkerTaskReachabilityOptions] type GetWorkerTaskReachabilityOptions struct { // BuildIDs - The build IDs to query the reachability of. At least one build ID must be provided. BuildIDs []string @@ -176,12 +214,14 @@ type GetWorkerTaskReachabilityOptions struct { Reachability TaskReachability } +// Exposed as: [go.temporal.io/sdk/client.WorkerTaskReachability] type WorkerTaskReachability struct { // BuildIDReachability - map of build IDs and their reachability information // May contain an entry with UnversionedBuildID for an unversioned worker BuildIDReachability map[string]*BuildIDReachability } +// Exposed as: [go.temporal.io/sdk/client.BuildIDReachability] type BuildIDReachability struct { // TaskQueueReachable map of task queues and their reachability information. TaskQueueReachable map[string]*TaskQueueReachability @@ -190,6 +230,7 @@ type BuildIDReachability struct { UnretrievedTaskQueues []string } +// Exposed as: [go.temporal.io/sdk/client.TaskQueueReachability] type TaskQueueReachability struct { // TaskQueueReachability for a worker in a single task queue. // If TaskQueueReachability is empty, this worker is considered unreachable in this task queue. @@ -198,6 +239,8 @@ type TaskQueueReachability struct { // WorkerBuildIDVersionSets is the response for Client.GetWorkerBuildIdCompatibility and represents the sets // of worker build id based versions. +// +// Exposed as: [go.temporal.io/sdk/client.WorkerBuildIDVersionSets] type WorkerBuildIDVersionSets struct { Sets []*CompatibleVersionSet } diff --git a/internal/worker_versioning_rules.go b/internal/worker_versioning_rules.go index 80a2b11cb..b561bcc50 100644 --- a/internal/worker_versioning_rules.go +++ b/internal/worker_versioning_rules.go @@ -39,6 +39,8 @@ type ( // VersioningRampByPercentage sends a proportion of the traffic to the target Build ID. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningRampByPercentage] VersioningRampByPercentage struct { // Percentage of traffic with a value in [0,100) Percentage float32 @@ -47,6 +49,8 @@ type ( // VersioningAssignmentRule is a BuildID assigment rule for a task queue. // Assignment rules only affect new workflows. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningAssignmentRule] VersioningAssignmentRule struct { // The BuildID of new workflows affected by this rule. TargetBuildID string @@ -57,6 +61,8 @@ type ( // VersioningAssignmentRuleWithTimestamp contains an assignment rule annotated // by the server with its creation time. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningAssignmentRuleWithTimestamp] VersioningAssignmentRuleWithTimestamp struct { Rule VersioningAssignmentRule // The time when the server created this rule. @@ -66,6 +72,8 @@ type ( // VersioningAssignmentRule is a BuildID redirect rule for a task queue. // It changes the behavior of currently running workflows and new ones. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningRedirectRule] VersioningRedirectRule struct { SourceBuildID string TargetBuildID string @@ -74,6 +82,8 @@ type ( // VersioningRedirectRuleWithTimestamp contains a redirect rule annotated // by the server with its creation time. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningRedirectRuleWithTimestamp] VersioningRedirectRuleWithTimestamp struct { Rule VersioningRedirectRule // The time when the server created this rule. @@ -84,12 +94,16 @@ type ( // An update with an old token fails with `serviceerror.FailedPrecondition`. // The current token can be obtained with [GetWorkerVersioningRules], or returned by a successful [UpdateWorkerVersioningRules]. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningConflictToken] VersioningConflictToken struct { token []byte } // UpdateWorkerVersioningRulesOptions is the input to [Client.UpdateWorkerVersioningRules]. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.UpdateWorkerVersioningRulesOptions] UpdateWorkerVersioningRulesOptions struct { // The task queue to update the versioning rules of. TaskQueue string @@ -121,6 +135,8 @@ type ( // (index 0). If the given index is too larger the rule will be // inserted at the end of the list. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationInsertAssignmentRule] VersioningOperationInsertAssignmentRule struct { RuleIndex int32 Rule VersioningAssignmentRule @@ -132,6 +148,8 @@ type ( // the delete operation will be rejected. Set `force` to true to // bypass this validation. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationReplaceAssignmentRule] VersioningOperationReplaceAssignmentRule struct { RuleIndex int32 Rule VersioningAssignmentRule @@ -144,6 +162,8 @@ type ( // the delete operation will be rejected. Set `force` to true to // bypass this validation. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationDeleteAssignmentRule] VersioningOperationDeleteAssignmentRule struct { RuleIndex int32 Force bool @@ -153,6 +173,8 @@ type ( // that adds the rule to the list of redirect rules for this Task Queue. There // can be at most one redirect rule for each distinct Source BuildID. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationAddRedirectRule] VersioningOperationAddRedirectRule struct { Rule VersioningRedirectRule } @@ -160,6 +182,8 @@ type ( // VersioningOperationReplaceRedirectRule is an operation for UpdateWorkerVersioningRulesOptions // that replaces the routing rule with the given source BuildID. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationReplaceRedirectRule] VersioningOperationReplaceRedirectRule struct { Rule VersioningRedirectRule } @@ -167,6 +191,8 @@ type ( // VersioningOperationDeleteRedirectRule is an operation for UpdateWorkerVersioningRulesOptions // that deletes the routing rule with the given source Build ID. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationDeleteRedirectRule] VersioningOperationDeleteRedirectRule struct { SourceBuildID string } @@ -185,6 +211,8 @@ type ( // pollers have been seen recently for this Build ID. Use the `force` // option to disable this validation. // WARNING: Worker versioning is currently experimental + // + // Exposed as: [go.temporal.io/sdk/client.VersioningOperationCommitBuildID] VersioningOperationCommitBuildID struct { TargetBuildID string Force bool @@ -271,6 +299,8 @@ func (uw *UpdateWorkerVersioningRulesOptions) validateAndConvertToProto(namespac // GetWorkerVersioningOptions is the input to [Client.GetWorkerVersioningRules]. // WARNING: Worker versioning is currently experimental +// +// Exposed as: [go.temporal.io/sdk/client.GetWorkerVersioningOptions] type GetWorkerVersioningOptions struct { // The task queue to get the versioning rules from. TaskQueue string @@ -294,6 +324,8 @@ func (gw *GetWorkerVersioningOptions) validateAndConvertToProto(namespace string // WorkerVersioningRules is the response for [Client.GetWorkerVersioningRules]. // WARNING: Worker versioning is currently experimental +// +// Exposed as: [go.temporal.io/sdk/client.WorkerVersioningRules] type WorkerVersioningRules struct { AssignmentRules []*VersioningAssignmentRuleWithTimestamp RedirectRules []*VersioningRedirectRuleWithTimestamp diff --git a/internal/workflow.go b/internal/workflow.go index 39bff603e..0ed8ef1f0 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -50,12 +50,18 @@ import ( // // Policy defining actions taken when a workflow exits while update or signal handlers are running. // The workflow exit may be due to successful return, cancellation, or continue-as-new +// +// Exposed as: [go.temporal.io/sdk/workflow.HandlerUnfinishedPolicy] type HandlerUnfinishedPolicy int const ( // WarnAndAbandon issues a warning in addition to abandoning. + // + // Exposed as: [go.temporal.io/sdk/workflow.HandlerUnfinishedPolicyWarnAndAbandon] HandlerUnfinishedPolicyWarnAndAbandon HandlerUnfinishedPolicy = iota // ABANDON abandons the handler. + // + // Exposed as: [go.temporal.io/sdk/workflow.HandlerUnfinishedPolicyAbandon] HandlerUnfinishedPolicyAbandon ) @@ -268,11 +274,15 @@ type ( } // WorkflowType identifies a workflow type. + // + // Exposed as: [go.temporal.io/sdk/workflow.Type] WorkflowType struct { Name string } // WorkflowExecution details. + // + // Exposed as: [go.temporal.io/sdk/workflow.Execution] WorkflowExecution struct { ID string RunID string @@ -289,6 +299,8 @@ type ( // ChildWorkflowOptions stores all child workflow specific parameters that will be stored inside of a Context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. + // + // Exposed as: [go.temporal.io/sdk/workflow.ChildWorkflowOptions] ChildWorkflowOptions struct { // Namespace of the child workflow. // Optional: the current workflow (parent)'s namespace will be used if this is not provided. @@ -399,6 +411,8 @@ type ( } // RegisterWorkflowOptions consists of options for registering a workflow + // + // Exposed as: [go.temporal.io/sdk/workflow.RegisterOptions] RegisterWorkflowOptions struct { // Custom name for this workflow instead of the function name. // @@ -419,6 +433,8 @@ type ( // SignalChannelOptions consists of options for a signal channel. // // NOTE: Experimental + // + // Exposed as: [go.temporal.io/sdk/workflow.SignalChannelOptions] SignalChannelOptions struct { // Description is a short description for this signal. // @@ -429,6 +445,8 @@ type ( // QueryHandlerOptions consists of options for a query handler. // // NOTE: Experimental + // + // Exposed as: [go.temporal.io/sdk/workflow.QueryHandlerOptions] QueryHandlerOptions struct { // Description is a short description for this query. // @@ -439,6 +457,8 @@ type ( // UpdateHandlerOptions consists of options for executing a named workflow update. // // NOTE: Experimental + // + // Exposed as: [go.temporal.io/sdk/workflow.UpdateHandlerOptions] UpdateHandlerOptions struct { // Validator is an optional (i.e. can be left nil) func with exactly the // same type signature as the required update handler func but returning @@ -463,6 +483,8 @@ type ( // TimerOptions are options set when creating a timer. // // NOTE: Experimental + // + // Exposed as: [go.temporal.io/sdk/workflow.TimerOptions] TimerOptions struct { // Summary is a simple string identifying this timer. While it can be // normal text, it is best to treat as a timer ID. This value will be @@ -475,6 +497,8 @@ type ( // AwaitOptions are options set when creating an await. // // NOTE: Experimental + // + // Exposed as: [go.temporal.io/sdk/workflow.AwaitOptions] AwaitOptions struct { // Timeout is the await timeout if the await condition is not met. // @@ -489,6 +513,8 @@ type ( // Await blocks the calling thread until condition() returns true // Returns CanceledError if the ctx is canceled. +// +// Exposed as: [go.temporal.io/sdk/workflow.Await] func Await(ctx Context, condition func() bool) error { assertNotInReadOnlyState(ctx) state := getState(ctx) @@ -534,6 +560,8 @@ func (wc *workflowEnvironmentInterceptor) awaitWithOptions(ctx Context, options // AwaitWithTimeout blocks the calling thread until condition() returns true // Returns ok equals to false if timed out and err equals to CanceledError if the ctx is canceled. +// +// Exposed as: [go.temporal.io/sdk/workflow.AwaitWithTimeout] func AwaitWithTimeout(ctx Context, timeout time.Duration, condition func() bool) (ok bool, err error) { assertNotInReadOnlyState(ctx) state := getState(ctx) @@ -547,6 +575,8 @@ func (wc *workflowEnvironmentInterceptor) AwaitWithTimeout(ctx Context, timeout // AwaitWithOptions blocks the calling thread until condition() returns true // Returns ok equals to false if timed out and err equals to CanceledError if the ctx is canceled. +// +// Exposed as: [go.temporal.io/sdk/workflow.AwaitWithOptions] func AwaitWithOptions(ctx Context, options AwaitOptions, condition func() bool) (ok bool, err error) { assertNotInReadOnlyState(ctx) state := getState(ctx) @@ -558,6 +588,8 @@ func (wc *workflowEnvironmentInterceptor) AwaitWithOptions(ctx Context, options } // NewChannel create new Channel instance +// +// Exposed as: [go.temporal.io/sdk/workflow.NewChannel] func NewChannel(ctx Context) Channel { state := getState(ctx) state.dispatcher.channelSequence++ @@ -566,12 +598,16 @@ func NewChannel(ctx Context) Channel { // NewNamedChannel create new Channel instance with a given human readable name. // Name appears in stack traces that are blocked on this channel. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewNamedChannel] func NewNamedChannel(ctx Context, name string) Channel { env := getWorkflowEnvironment(ctx) return &channelImpl{name: name, dataConverter: getDataConverterFromWorkflowContext(ctx), env: env} } // NewBufferedChannel create new buffered Channel instance +// +// Exposed as: [go.temporal.io/sdk/workflow.NewBufferedChannel] func NewBufferedChannel(ctx Context, size int) Channel { env := getWorkflowEnvironment(ctx) return &channelImpl{size: size, dataConverter: getDataConverterFromWorkflowContext(ctx), env: env} @@ -579,12 +615,16 @@ func NewBufferedChannel(ctx Context, size int) Channel { // NewNamedBufferedChannel create new BufferedChannel instance with a given human readable name. // Name appears in stack traces that are blocked on this Channel. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewNamedBufferedChannel] func NewNamedBufferedChannel(ctx Context, name string, size int) Channel { env := getWorkflowEnvironment(ctx) return &channelImpl{name: name, size: size, dataConverter: getDataConverterFromWorkflowContext(ctx), env: env} } // NewSelector creates a new Selector instance. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewSelector] func NewSelector(ctx Context) Selector { state := getState(ctx) state.dispatcher.selectorSequence++ @@ -593,12 +633,16 @@ func NewSelector(ctx Context) Selector { // NewNamedSelector creates a new Selector instance with a given human readable name. // Name appears in stack traces that are blocked on this Selector. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewNamedSelector] func NewNamedSelector(ctx Context, name string) Selector { assertNotInReadOnlyState(ctx) return &selectorImpl{name: name} } // NewWaitGroup creates a new WaitGroup instance. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewWaitGroup] func NewWaitGroup(ctx Context) WaitGroup { assertNotInReadOnlyState(ctx) f, s := NewFuture(ctx) @@ -606,18 +650,24 @@ func NewWaitGroup(ctx Context) WaitGroup { } // NewMutex creates a new Mutex instance. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewMutex] func NewMutex(ctx Context) Mutex { assertNotInReadOnlyState(ctx) return &mutexImpl{} } // NewSemaphore creates a new Semaphore instance with an initial weight. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewSemaphore] func NewSemaphore(ctx Context, n int64) Semaphore { assertNotInReadOnlyState(ctx) return &semaphoreImpl{size: n} } // Go creates a new coroutine. It has similar semantic to goroutine in a context of the workflow. +// +// Exposed as: [go.temporal.io/sdk/workflow.Go] func Go(ctx Context, f func(ctx Context)) { assertNotInReadOnlyState(ctx) state := getState(ctx) @@ -627,6 +677,8 @@ func Go(ctx Context, f func(ctx Context)) { // GoNamed creates a new coroutine with a given human readable name. // It has similar semantic to goroutine in a context of the workflow. // Name appears in stack traces that are blocked on this Channel. +// +// Exposed as: [go.temporal.io/sdk/workflow.GoNamed] func GoNamed(ctx Context, name string, f func(ctx Context)) { assertNotInReadOnlyState(ctx) state := getState(ctx) @@ -634,6 +686,8 @@ func GoNamed(ctx Context, name string, f func(ctx Context)) { } // NewFuture creates a new future as well as associated Settable that is used to set its value. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewFuture] func NewFuture(ctx Context) (Future, Settable) { assertNotInReadOnlyState(ctx) impl := &futureImpl{channel: NewChannel(ctx).(*channelImpl)} @@ -739,6 +793,8 @@ func (wc *workflowEnvironmentInterceptor) Init(outbound WorkflowOutboundIntercep // *CanceledError set as cause for *ActivityError. // // ExecuteActivity returns Future with activity result or failure. +// +// Exposed as: [go.temporal.io/sdk/workflow.ExecuteActivity] func ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -861,6 +917,8 @@ func (wc *workflowEnvironmentInterceptor) ExecuteActivity(ctx Context, typeName // *CanceledError set as cause for *ActivityError. // // ExecuteLocalActivity returns Future with local activity result or failure. +// +// Exposed as: [go.temporal.io/sdk/workflow.ExecuteLocalActivity] func ExecuteLocalActivity(ctx Context, activity interface{}, args ...interface{}) Future { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1051,6 +1109,8 @@ func (wc *workflowEnvironmentInterceptor) scheduleLocalActivity(ctx Context, par // *CanceledError set as cause for *ChildWorkflowExecutionError. // // ExecuteChildWorkflow returns ChildWorkflowFuture. +// +// Exposed as: [go.temporal.io/sdk/workflow.ExecuteChildWorkflow] func ExecuteChildWorkflow(ctx Context, childWorkflow interface{}, args ...interface{}) ChildWorkflowFuture { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1150,6 +1210,8 @@ func (wc *workflowEnvironmentInterceptor) ExecuteChildWorkflow(ctx Context, chil } // WorkflowInfo information about currently executing workflow +// +// Exposed as: [go.temporal.io/sdk/workflow.Info] type WorkflowInfo struct { WorkflowExecution WorkflowExecution // The original runID before resetting. Using it instead of current runID can make workflow decision deterministic after reset. See also FirstRunId @@ -1192,6 +1254,8 @@ type WorkflowInfo struct { } // UpdateInfo information about a currently running update +// +// Exposed as: [go.temporal.io/sdk/workflow.UpdateInfo] type UpdateInfo struct { // ID of the update ID string @@ -1237,6 +1301,8 @@ func (wInfo *WorkflowInfo) GetContinueAsNewSuggested() bool { } // GetWorkflowInfo extracts info of a current workflow from a context. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetInfo] func GetWorkflowInfo(ctx Context) *WorkflowInfo { i := getWorkflowOutboundInterceptor(ctx) return i.GetInfo(ctx) @@ -1246,6 +1312,7 @@ func (wc *workflowEnvironmentInterceptor) GetInfo(ctx Context) *WorkflowInfo { return wc.env.WorkflowInfo() } +// Exposed as: [go.temporal.io/sdk/workflow.GetTypedSearchAttributes] func GetTypedSearchAttributes(ctx Context) SearchAttributes { i := getWorkflowOutboundInterceptor(ctx) return i.GetTypedSearchAttributes(ctx) @@ -1256,6 +1323,8 @@ func (wc *workflowEnvironmentInterceptor) GetTypedSearchAttributes(ctx Context) } // GetUpdateInfo extracts info of a currently running update from a context. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetCurrentUpdateInfo] func GetCurrentUpdateInfo(ctx Context) *UpdateInfo { i := getWorkflowOutboundInterceptor(ctx) return i.GetCurrentUpdateInfo(ctx) @@ -1270,6 +1339,8 @@ func (wc *workflowEnvironmentInterceptor) GetCurrentUpdateInfo(ctx Context) *Upd } // GetLogger returns a logger to be used in workflow's context +// +// Exposed as: [go.temporal.io/sdk/workflow.GetLogger] func GetLogger(ctx Context) log.Logger { i := getWorkflowOutboundInterceptor(ctx) return i.GetLogger(ctx) @@ -1287,6 +1358,8 @@ func (wc *workflowEnvironmentInterceptor) GetLogger(ctx Context) log.Logger { } // GetMetricsHandler returns a metrics handler to be used in workflow's context +// +// Exposed as: [go.temporal.io/sdk/workflow.GetMetricsHandler] func GetMetricsHandler(ctx Context) metrics.Handler { i := getWorkflowOutboundInterceptor(ctx) return i.GetMetricsHandler(ctx) @@ -1298,6 +1371,8 @@ func (wc *workflowEnvironmentInterceptor) GetMetricsHandler(ctx Context) metrics // Now returns the current time in UTC. It corresponds to the time when the workflow task is started or replayed. // Workflow needs to use this method to get the wall clock time instead of the one from the golang library. +// +// Exposed as: [go.temporal.io/sdk/workflow.Now] func Now(ctx Context) time.Time { i := getWorkflowOutboundInterceptor(ctx) return i.Now(ctx).UTC() @@ -1313,6 +1388,8 @@ func (wc *workflowEnvironmentInterceptor) Now(ctx Context) time.Time { // is canceled, the returned Future become ready, and Future.Get() will return *CanceledError. // // To be able to set options like timer summary, use [NewTimerWithOptions]. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewTimer] func NewTimer(ctx Context, d time.Duration) Future { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1323,6 +1400,8 @@ func NewTimer(ctx Context, d time.Duration) Future { // needs to use this NewTimerWithOptions() to get the timer instead of the Go lang library one(timer.NewTimer()). You // can cancel the pending timer by cancel the Context (using context from workflow.WithCancel(ctx)) and that will cancel // the timer. After timer is canceled, the returned Future become ready, and Future.Get() will return *CanceledError. +// +// Exposed as: [go.temporal.io/sdk/workflow.NewTimerWithOptions] func NewTimerWithOptions(ctx Context, d time.Duration, options TimerOptions) Future { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1376,6 +1455,8 @@ func (wc *workflowEnvironmentInterceptor) NewTimerWithOptions( // Sleep() returns nil if the duration d is passed, or it returns *CanceledError if the ctx is canceled. There are 2 // reasons the ctx could be canceled: 1) your workflow code cancel the ctx (with workflow.WithCancel(ctx)); // 2) your workflow itself is canceled by external request. +// +// Exposed as: [go.temporal.io/sdk/workflow.Sleep] func Sleep(ctx Context, d time.Duration) (err error) { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1398,6 +1479,8 @@ func (wc *workflowEnvironmentInterceptor) Sleep(ctx Context, d time.Duration) (e // ctx := WithWorkflowNamespace(ctx, "namespace") // // RequestCancelExternalWorkflow return Future with failure or empty success result. +// +// Exposed as: [go.temporal.io/sdk/workflow.RequestCancelExternalWorkflow] func RequestCancelExternalWorkflow(ctx Context, workflowID, runID string) Future { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1438,6 +1521,8 @@ func (wc *workflowEnvironmentInterceptor) RequestCancelExternalWorkflow(ctx Cont // ctx := WithWorkflowNamespace(ctx, "namespace") // // SignalExternalWorkflow return Future with failure or empty success result. +// +// Exposed as: [go.temporal.io/sdk/workflow.SignalExternalWorkflow] func SignalExternalWorkflow(ctx Context, workflowID, runID, signalName string, arg interface{}) Future { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1532,6 +1617,8 @@ func signalExternalWorkflow(ctx Context, workflowID, runID, signalName string, a // // Deprecated: Use [UpsertTypedSearchAttributes] instead. // +// Exposed as: [go.temporal.io/sdk/workflow.UpsertSearchAttributes] +// // [Visibility]: https://docs.temporal.io/visibility func UpsertSearchAttributes(ctx Context, attributes map[string]interface{}) error { assertNotInReadOnlyState(ctx) @@ -1546,6 +1633,7 @@ func (wc *workflowEnvironmentInterceptor) UpsertSearchAttributes(ctx Context, at return wc.env.UpsertSearchAttributes(attributes) } +// Exposed as: [go.temporal.io/sdk/workflow.UpsertTypedSearchAttributes] func UpsertTypedSearchAttributes(ctx Context, attributes ...SearchAttributeUpdate) error { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1588,6 +1676,8 @@ func (wc *workflowEnvironmentInterceptor) UpsertTypedSearchAttributes(ctx Contex // } // // This is only supported with Temporal Server 1.18+ +// +// Exposed as: [go.temporal.io/sdk/workflow.UpsertMemo] func UpsertMemo(ctx Context, memo map[string]interface{}) error { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1601,6 +1691,8 @@ func (wc *workflowEnvironmentInterceptor) UpsertMemo(ctx Context, memo map[strin // WithChildWorkflowOptions adds all workflow options to the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithChildOptions] func WithChildWorkflowOptions(ctx Context, cwo ChildWorkflowOptions) Context { ctx1 := setWorkflowEnvOptionsIfNotExist(ctx) wfOptions := getWorkflowEnvOptions(ctx1) @@ -1630,6 +1722,8 @@ func WithChildWorkflowOptions(ctx Context, cwo ChildWorkflowOptions) Context { } // GetChildWorkflowOptions returns all workflow options present on the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetChildWorkflowOptions] func GetChildWorkflowOptions(ctx Context) ChildWorkflowOptions { opts := getWorkflowEnvOptions(ctx) if opts == nil { @@ -1657,6 +1751,8 @@ func GetChildWorkflowOptions(ctx Context) ChildWorkflowOptions { } // WithWorkflowNamespace adds a namespace to the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWorkflowNamespace] func WithWorkflowNamespace(ctx Context, name string) Context { ctx1 := setWorkflowEnvOptionsIfNotExist(ctx) getWorkflowEnvOptions(ctx1).Namespace = name @@ -1664,6 +1760,8 @@ func WithWorkflowNamespace(ctx Context, name string) Context { } // WithWorkflowTaskQueue adds a task queue to the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWorkflowTaskQueue] func WithWorkflowTaskQueue(ctx Context, name string) Context { if name == "" { panic("empty task queue name") @@ -1674,6 +1772,8 @@ func WithWorkflowTaskQueue(ctx Context, name string) Context { } // WithWorkflowID adds a workflowID to the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWorkflowID] func WithWorkflowID(ctx Context, workflowID string) Context { ctx1 := setWorkflowEnvOptionsIfNotExist(ctx) getWorkflowEnvOptions(ctx1).WorkflowID = workflowID @@ -1690,6 +1790,8 @@ func WithTypedSearchAttributes(ctx Context, searchAttributes SearchAttributes) C // WithWorkflowRunTimeout adds a run timeout to the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWorkflowRunTimeout] func WithWorkflowRunTimeout(ctx Context, d time.Duration) Context { ctx1 := setWorkflowEnvOptionsIfNotExist(ctx) getWorkflowEnvOptions(ctx1).WorkflowRunTimeout = d @@ -1699,6 +1801,8 @@ func WithWorkflowRunTimeout(ctx Context, d time.Duration) Context { // WithWorkflowTaskTimeout adds a workflow task timeout to the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWorkflowTaskTimeout] func WithWorkflowTaskTimeout(ctx Context, d time.Duration) Context { ctx1 := setWorkflowEnvOptionsIfNotExist(ctx) getWorkflowEnvOptions(ctx1).WorkflowTaskTimeout = d @@ -1706,6 +1810,8 @@ func WithWorkflowTaskTimeout(ctx Context, d time.Duration) Context { } // WithDataConverter adds DataConverter to the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithDataConverter] func WithDataConverter(ctx Context, dc converter.DataConverter) Context { if dc == nil { panic("data converter is nil for WithDataConverter") @@ -1718,6 +1824,8 @@ func WithDataConverter(ctx Context, dc converter.DataConverter) Context { // WithWorkflowVersioningIntent is used to set the VersioningIntent before constructing a // ContinueAsNewError with NewContinueAsNewError. // WARNING: Worker versioning is currently experimental +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWorkflowVersioningIntent] func WithWorkflowVersioningIntent(ctx Context, intent VersioningIntent) Context { ctx1 := setWorkflowEnvOptionsIfNotExist(ctx) getWorkflowEnvOptions(ctx1).VersioningIntent = intent @@ -1732,6 +1840,8 @@ func withContextPropagators(ctx Context, contextPropagators []ContextPropagator) } // GetSignalChannel returns channel corresponding to the signal name. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetSignalChannel] func GetSignalChannel(ctx Context, signalName string) ReceiveChannel { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1741,6 +1851,8 @@ func GetSignalChannel(ctx Context, signalName string) ReceiveChannel { // GetSignalChannelWithOptions returns channel corresponding to the signal name. // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/workflow.GetSignalChannelWithOptions] func GetSignalChannelWithOptions(ctx Context, signalName string, options SignalChannelOptions) ReceiveChannel { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1824,6 +1936,8 @@ func (b EncodedValue) HasValue() bool { // } else { // .... // } +// +// Exposed as: [go.temporal.io/sdk/workflow.SideEffect] func SideEffect(ctx Context, f func(ctx Context) interface{}) converter.EncodedValue { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1867,6 +1981,8 @@ func (wc *workflowEnvironmentInterceptor) SideEffect(ctx Context, f func(ctx Con // value as it was returning during the non-replay run. // // One good use case of MutableSideEffect() is to access dynamically changing config without breaking determinism. +// +// Exposed as: [go.temporal.io/sdk/workflow.MutableSideEffect] func MutableSideEffect(ctx Context, id string, f func(ctx Context) interface{}, equals func(a, b interface{}) bool) converter.EncodedValue { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -1884,6 +2000,8 @@ func (wc *workflowEnvironmentInterceptor) MutableSideEffect(ctx Context, id stri } // DefaultVersion is a version returned by GetVersion for code that wasn't versioned before +// +// Exposed as: [go.temporal.io/sdk/workflow.Version], [go.temporal.io/sdk/workflow.DefaultVersion] const DefaultVersion Version = -1 // TemporalChangeVersion is used as search attributes key to find workflows with specific change version. @@ -1954,6 +2072,8 @@ const TemporalChangeVersion = "TemporalChangeVersion" // } else { // err = workflow.ExecuteActivity(ctx, qux, data).Get(ctx, nil) // } +// +// Exposed as: [go.temporal.io/sdk/workflow.GetVersion] func GetVersion(ctx Context, changeID string, minSupported, maxSupported Version) Version { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -2005,6 +2125,8 @@ func (wc *workflowEnvironmentInterceptor) GetVersion(ctx Context, changeID strin // } // // See [SetQueryHandlerWithOptions] to set additional options. +// +// Exposed as: [go.temporal.io/sdk/workflow.SetQueryHandler] func SetQueryHandler(ctx Context, queryType string, handler interface{}) error { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -2015,6 +2137,8 @@ func SetQueryHandler(ctx Context, queryType string, handler interface{}) error { // [SetQueryHandler] documentation for details. // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/workflow.SetQueryHandlerWithOptions] func SetQueryHandlerWithOptions(ctx Context, queryType string, handler interface{}, options QueryHandlerOptions) error { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -2061,6 +2185,8 @@ func (wc *workflowEnvironmentInterceptor) SetQueryHandlerWithOptions( // mutate workflow state in any way. // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/workflow.SetUpdateHandlerWithOptions] func SetUpdateHandler(ctx Context, updateName string, handler interface{}, opts UpdateHandlerOptions) error { assertNotInReadOnlyState(ctx) i := getWorkflowOutboundInterceptor(ctx) @@ -2088,6 +2214,8 @@ func (wc *workflowEnvironmentInterceptor) SetUpdateHandler(ctx Context, name str // on the failure. If workflow don't want to be blocked on those failure, it should ignore those failure; if workflow do // want to make sure it proceed only when that action succeed then it should panic on that failure. Panic raised from a // workflow causes workflow task to fail and temporal server will rescheduled later to retry. +// +// Exposed as: [go.temporal.io/sdk/workflow.IsReplaying] func IsReplaying(ctx Context) bool { i := getWorkflowOutboundInterceptor(ctx) return i.IsReplaying(ctx) @@ -2102,6 +2230,8 @@ func (wc *workflowEnvironmentInterceptor) IsReplaying(ctx Context) bool { // If a cron workflow wants to pass some data to next schedule, it can return any data and that data will become // available when next run starts. // This HasLastCompletionResult() checks if there is such data available passing down from previous successful run. +// +// Exposed as: [go.temporal.io/sdk/workflow.HasLastCompletionResult] func HasLastCompletionResult(ctx Context) bool { i := getWorkflowOutboundInterceptor(ctx) return i.HasLastCompletionResult(ctx) @@ -2121,6 +2251,8 @@ func (wc *workflowEnvironmentInterceptor) HasLastCompletionResult(ctx Context) b // Note, values should not be reused for extraction here because merging on top // of existing values may result in unexpected behavior similar to // json.Unmarshal. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetLastCompletionResult] func GetLastCompletionResult(ctx Context, d ...interface{}) error { i := getWorkflowOutboundInterceptor(ctx) return i.GetLastCompletionResult(ctx, d...) @@ -2140,6 +2272,8 @@ func (wc *workflowEnvironmentInterceptor) GetLastCompletionResult(ctx Context, d // have failed, nil is returned. // // See TestWorkflowEnvironment.SetLastError() for unit test support. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetLastError] func GetLastError(ctx Context) error { i := getWorkflowOutboundInterceptor(ctx) return i.GetLastError(ctx) @@ -2159,6 +2293,8 @@ func (*workflowEnvironmentInterceptor) mustEmbedWorkflowOutboundInterceptorBase( // WithActivityOptions adds all options to the copy of the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithActivityOptions] func WithActivityOptions(ctx Context, options ActivityOptions) Context { ctx1 := setActivityParametersIfNotExist(ctx) eap := getActivityOptions(ctx1) @@ -2182,6 +2318,8 @@ func WithActivityOptions(ctx Context, options ActivityOptions) Context { // WithLocalActivityOptions adds local activity options to the copy of the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithLocalActivityOptions] func WithLocalActivityOptions(ctx Context, options LocalActivityOptions) Context { ctx1 := setLocalActivityParametersIfNotExist(ctx) opts := getLocalActivityOptions(ctx1) @@ -2209,6 +2347,8 @@ func applyRetryPolicyDefaultsForLocalActivity(policy *RetryPolicy) *RetryPolicy } // WithTaskQueue adds a task queue to the copy of the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithTaskQueue] func WithTaskQueue(ctx Context, name string) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).TaskQueueName = name @@ -2216,6 +2356,8 @@ func WithTaskQueue(ctx Context, name string) Context { } // GetActivityOptions returns all activity options present on the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetActivityOptions] func GetActivityOptions(ctx Context) ActivityOptions { opts := getActivityOptions(ctx) if opts == nil { @@ -2237,6 +2379,8 @@ func GetActivityOptions(ctx Context) ActivityOptions { } // GetLocalActivityOptions returns all local activity options present on the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.GetLocalActivityOptions] func GetLocalActivityOptions(ctx Context) LocalActivityOptions { opts := getLocalActivityOptions(ctx) if opts == nil { @@ -2252,6 +2396,8 @@ func GetLocalActivityOptions(ctx Context) LocalActivityOptions { // WithScheduleToCloseTimeout adds a timeout to the copy of the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithScheduleToCloseTimeout] func WithScheduleToCloseTimeout(ctx Context, d time.Duration) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).ScheduleToCloseTimeout = d @@ -2261,6 +2407,8 @@ func WithScheduleToCloseTimeout(ctx Context, d time.Duration) Context { // WithScheduleToStartTimeout adds a timeout to the copy of the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithScheduleToStartTimeout] func WithScheduleToStartTimeout(ctx Context, d time.Duration) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).ScheduleToStartTimeout = d @@ -2270,6 +2418,8 @@ func WithScheduleToStartTimeout(ctx Context, d time.Duration) Context { // WithStartToCloseTimeout adds a timeout to the copy of the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithStartToCloseTimeout] func WithStartToCloseTimeout(ctx Context, d time.Duration) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).StartToCloseTimeout = d @@ -2279,6 +2429,8 @@ func WithStartToCloseTimeout(ctx Context, d time.Duration) Context { // WithHeartbeatTimeout adds a timeout to the copy of the context. // The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is // subjected to change in the future. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithHeartbeatTimeout] func WithHeartbeatTimeout(ctx Context, d time.Duration) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).HeartbeatTimeout = d @@ -2286,6 +2438,8 @@ func WithHeartbeatTimeout(ctx Context, d time.Duration) Context { } // WithWaitForCancellation adds wait for the cacellation to the copy of the context. +// +// Exposed as: [go.temporal.io/sdk/workflow.WithWaitForCancellation] func WithWaitForCancellation(ctx Context, wait bool) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).WaitForCancellation = wait @@ -2293,6 +2447,8 @@ func WithWaitForCancellation(ctx Context, wait bool) Context { } // WithRetryPolicy adds retry policy to the copy of the context +// +// Exposed as: [go.temporal.io/sdk/workflow.WithRetryPolicy] func WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context { ctx1 := setActivityParametersIfNotExist(ctx) getActivityOptions(ctx1).RetryPolicy = convertToPBRetryPolicy(&retryPolicy) @@ -2359,16 +2515,21 @@ func DeterministicKeysFunc[K comparable, V any](m map[K]V, cmp func(a K, b K) in return r } +// Exposed as: [go.temporal.io/sdk/workflow.AllHandlersFinished] func AllHandlersFinished(ctx Context) bool { return len(getWorkflowEnvOptions(ctx).getRunningUpdateHandles()) == 0 } // NexusOperationOptions are options for starting a Nexus Operation from a Workflow. +// +// Exposed as: [go.temporal.io/sdk/workflow.NexusOperationOptions] type NexusOperationOptions struct { ScheduleToCloseTimeout time.Duration } // NexusOperationExecution is the result of NexusOperationFuture.GetNexusOperationExecution. +// +// Exposed as: [go.temporal.io/sdk/workflow.NexusOperationExecution] type NexusOperationExecution struct { // Operation ID as set by the Operation's handler. May be empty if the operation hasn't started yet or completed // synchronously. @@ -2376,6 +2537,8 @@ type NexusOperationExecution struct { } // NexusOperationFuture represents the result of a Nexus Operation. +// +// Exposed as: [go.temporal.io/sdk/workflow.NexusOperationFuture] type NexusOperationFuture interface { Future // GetNexusOperationExecution returns a future that is resolved when the operation reaches the STARTED state. @@ -2421,6 +2584,8 @@ type nexusClient struct { // Create a [NexusClient] from an endpoint name and a service name. // // NOTE: Experimental +// +// Exposed as: [go.temporal.io/sdk/workflow.NewNexusClient] func NewNexusClient(endpoint, service string) NexusClient { if endpoint == "" { panic("endpoint must not be empty") diff --git a/internal/workflow_deadlock.go b/internal/workflow_deadlock.go index 6f3a16d85..4bc969a86 100644 --- a/internal/workflow_deadlock.go +++ b/internal/workflow_deadlock.go @@ -66,6 +66,8 @@ func ResumeDeadlockDetector(ctx Context) { // be used for advanced data converters that may perform remote calls or // otherwise intentionally execute longer than the default deadlock detection // timeout. +// +// Exposed as: [go.temporal.io/sdk/workflow.DataConverterWithoutDeadlockDetection] func DataConverterWithoutDeadlockDetection(c converter.DataConverter) converter.DataConverter { return &dataConverterWithoutDeadlock{underlying: c} } @@ -172,6 +174,7 @@ type dataConverterWithoutDeadlock struct { underlying converter.DataConverter } +// Exposed as: [go.temporal.io/sdk/workflow.ContextAware] var _ ContextAware = &dataConverterWithoutDeadlock{} func (d *dataConverterWithoutDeadlock) ToPayload(value interface{}) (*commonpb.Payload, error) { diff --git a/internal/workflow_testsuite.go b/internal/workflow_testsuite.go index 806c708ac..0d161f453 100644 --- a/internal/workflow_testsuite.go +++ b/internal/workflow_testsuite.go @@ -55,6 +55,8 @@ type ( ErrorDetailsValues []interface{} // WorkflowTestSuite is the test suite to run unit tests for workflow/activity. + // + // Exposed as: [go.temporal.io/sdk/testsuite.WorkflowTestSuite] WorkflowTestSuite struct { logger log.Logger metricsHandler metrics.Handler @@ -64,6 +66,8 @@ type ( } // TestWorkflowEnvironment is the environment that you use to test workflow + // + // Exposed as: [go.temporal.io/sdk/testsuite.TestWorkflowEnvironment] TestWorkflowEnvironment struct { workflowMock mock.Mock activityMock mock.Mock @@ -72,11 +76,15 @@ type ( } // TestActivityEnvironment is the environment that you use to test activity + // + // Exposed as: [go.temporal.io/sdk/testsuite.TestActivityEnvironment] TestActivityEnvironment struct { impl *testWorkflowEnvironmentImpl } // MockCallWrapper is a wrapper to mock.Call. It offers the ability to wait on workflow's clock instead of wall clock. + // + // Exposed as: [go.temporal.io/sdk/testsuite.MockCallWrapper] MockCallWrapper struct { call *mock.Call env *TestWorkflowEnvironment @@ -88,6 +96,8 @@ type ( // TestUpdateCallback is a basic implementation of the UpdateCallbacks interface for testing purposes. // Tests are welcome to implement their own version of this interface if they need to test more complex // update logic. This is a simple implementation to make testing basic Workflow Updates easier. + // + // Exposed as: [go.temporal.io/sdk/testsuite.TestUpdateCallback] TestUpdateCallback struct { OnAccept func() OnReject func(error) @@ -416,6 +426,8 @@ func (e *TestWorkflowEnvironment) OnActivity(activity interface{}, args ...inter // ErrMockStartChildWorkflowFailed is special error used to indicate the mocked child workflow should fail to start. // This error is also exposed as public as testsuite.ErrMockStartChildWorkflowFailed +// +// Exposed as: [go.temporal.io/sdk/testsuite.ErrMockStartChildWorkflowFailed] var ErrMockStartChildWorkflowFailed = fmt.Errorf("start child workflow failed: %v", enumspb.START_CHILD_WORKFLOW_EXECUTION_FAILED_CAUSE_WORKFLOW_ALREADY_EXISTS) // OnWorkflow setup a mock call for workflow. Parameter workflow must be workflow function (func) or workflow name (string).