Skip to content

Commit 7828e06

Browse files
authoredDec 6, 2024··
Update Godoc for internal structs/funcs to clarify the package they are exposed under (#1735)
* identify public fields and map to internal fields * Implemented doclink, added check to CI. Once CI fails, will run with -fix flag * fix check errors, run -fix with doclink tool * use doclink's to make objects clickable, fix whitespace issue * handle windows backwards slash * Use ast.IsExported
1 parent 1f35a5b commit 7828e06

22 files changed

+1129
-4
lines changed
 

‎internal/activity.go

+26
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ import (
3939

4040
type (
4141
// ActivityType identifies an activity type.
42+
//
43+
// Exposed as: [go.temporal.io/sdk/activity.Type]
4244
ActivityType struct {
4345
Name string
4446
}
4547

4648
// ActivityInfo contains information about a currently executing activity.
49+
//
50+
// Exposed as: [go.temporal.io/sdk/activity.Info]
4751
ActivityInfo struct {
4852
TaskToken []byte
4953
WorkflowType *WorkflowType
@@ -61,6 +65,8 @@ type (
6165
}
6266

6367
// RegisterActivityOptions consists of options for registering an activity.
68+
//
69+
// Exposed as: [go.temporal.io/sdk/activity.RegisterOptions]
6470
RegisterActivityOptions struct {
6571
// When an activity is a function the name is an actual activity type name.
6672
// When an activity is part of a structure then each member of the structure becomes an activity with
@@ -81,6 +87,8 @@ type (
8187
// ActivityOptions stores all activity-specific parameters that will be stored inside of a context.
8288
// The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is
8389
// subjected to change in the future.
90+
//
91+
// Exposed as: [go.temporal.io/sdk/workflow.ActivityOptions]
8492
ActivityOptions struct {
8593
// TaskQueue - Name of the task queue that the activity needs to be scheduled on.
8694
// Optional: The default task queue with the same name as the workflow task queue.
@@ -160,6 +168,8 @@ type (
160168
}
161169

162170
// LocalActivityOptions stores local activity specific parameters that will be stored inside of a context.
171+
//
172+
// Exposed as: [go.temporal.io/sdk/workflow.LocalActivityOptions]
163173
LocalActivityOptions struct {
164174
// ScheduleToCloseTimeout - The end to end timeout for the local activity, including retries.
165175
// At least one of ScheduleToCloseTimeout or StartToCloseTimeout is required.
@@ -179,16 +189,22 @@ type (
179189
)
180190

181191
// GetActivityInfo returns information about the currently executing activity.
192+
//
193+
// Exposed as: [go.temporal.io/sdk/activity.GetInfo]
182194
func GetActivityInfo(ctx context.Context) ActivityInfo {
183195
return getActivityOutboundInterceptor(ctx).GetInfo(ctx)
184196
}
185197

186198
// HasHeartbeatDetails checks if there are heartbeat details from last attempt.
199+
//
200+
// Exposed as: [go.temporal.io/sdk/activity.HasHeartbeatDetails]
187201
func HasHeartbeatDetails(ctx context.Context) bool {
188202
return getActivityOutboundInterceptor(ctx).HasHeartbeatDetails(ctx)
189203
}
190204

191205
// IsActivity checks if the context is an activity context from a normal or local activity.
206+
//
207+
// Exposed as: [go.temporal.io/sdk/activity.IsActivity]
192208
func IsActivity(ctx context.Context) bool {
193209
a := ctx.Value(activityInterceptorContextKey)
194210
return a != nil
@@ -202,16 +218,22 @@ func IsActivity(ctx context.Context) bool {
202218
//
203219
// Note: Values should not be reused for extraction here because merging on top
204220
// of existing values may result in unexpected behavior similar to json.Unmarshal.
221+
//
222+
// Exposed as: [go.temporal.io/sdk/activity.GetHeartbeatDetails]
205223
func GetHeartbeatDetails(ctx context.Context, d ...interface{}) error {
206224
return getActivityOutboundInterceptor(ctx).GetHeartbeatDetails(ctx, d...)
207225
}
208226

209227
// GetActivityLogger returns a logger that can be used in the activity.
228+
//
229+
// Exposed as: [go.temporal.io/sdk/activity.GetLogger]
210230
func GetActivityLogger(ctx context.Context) log.Logger {
211231
return getActivityOutboundInterceptor(ctx).GetLogger(ctx)
212232
}
213233

214234
// GetActivityMetricsHandler returns a metrics handler that can be used in the activity.
235+
//
236+
// Exposed as: [go.temporal.io/sdk/activity.GetMetricsHandler]
215237
func GetActivityMetricsHandler(ctx context.Context) metrics.Handler {
216238
return getActivityOutboundInterceptor(ctx).GetMetricsHandler(ctx)
217239
}
@@ -220,6 +242,8 @@ func GetActivityMetricsHandler(ctx context.Context) metrics.Handler {
220242
// When the worker is stopping, it will close this channel and wait until the worker stop timeout finishes. After the timeout
221243
// hits, the worker will cancel the activity context and then exit. The timeout can be defined by worker option: WorkerStopTimeout.
222244
// Use this channel to handle a graceful activity exit when the activity worker stops.
245+
//
246+
// Exposed as: [go.temporal.io/sdk/activity.GetWorkerStopChannel]
223247
func GetWorkerStopChannel(ctx context.Context) <-chan struct{} {
224248
return getActivityOutboundInterceptor(ctx).GetWorkerStopChannel(ctx)
225249
}
@@ -234,6 +258,8 @@ func GetWorkerStopChannel(ctx context.Context) <-chan struct{} {
234258
//
235259
// details - The details that you provided here can be seen in the workflow when it receives TimeoutError. You
236260
// can check error TimeoutType()/Details().
261+
//
262+
// Exposed as: [go.temporal.io/sdk/activity.RecordHeartbeat]
237263
func RecordActivityHeartbeat(ctx context.Context, details ...interface{}) {
238264
getActivityOutboundInterceptor(ctx).RecordHeartbeat(ctx, details...)
239265
}

‎internal/client.go

+41
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,20 @@ import (
4747

4848
const (
4949
// DefaultNamespace is the namespace name which is used if not passed with options.
50+
//
51+
// Exposed as: [go.temporal.io/sdk/client.DefaultNamespace]
5052
DefaultNamespace = "default"
5153

5254
// QueryTypeStackTrace is the build in query type for Client.QueryWorkflow() call. Use this query type to get the call
5355
// stack of the workflow. The result will be a string encoded in the EncodedValue.
56+
//
57+
// Exposed as: [go.temporal.io/sdk/client.QueryTypeStackTrace]
5458
QueryTypeStackTrace string = "__stack_trace"
5559

5660
// QueryTypeOpenSessions is the build in query type for Client.QueryWorkflow() call. Use this query type to get all open
5761
// sessions in the workflow. The result will be a list of SessionInfo encoded in the EncodedValue.
62+
//
63+
// Exposed as: [go.temporal.io/sdk/client.QueryTypeOpenSessions]
5864
QueryTypeOpenSessions string = "__open_sessions"
5965

6066
// QueryTypeWorkflowMetadata is the query name for the workflow metadata.
@@ -430,6 +436,8 @@ type (
430436
}
431437

432438
// ClientOptions are optional parameters for Client creation.
439+
//
440+
// Exposed as: [go.temporal.io/sdk/client.Options]
433441
ClientOptions struct {
434442
// Optional: To set the host:port for this client to connect to.
435443
// default: localhost:7233
@@ -516,6 +524,8 @@ type (
516524
// CloudOperationsClientOptions are parameters for CloudOperationsClient creation.
517525
//
518526
// WARNING: Cloud operations client is currently experimental.
527+
//
528+
// Exposed as: [go.temporal.io/sdk/client.CloudOperationsClientOptions]
519529
CloudOperationsClientOptions struct {
520530
// Optional: The credentials for this client. This is essentially required.
521531
// See [go.temporal.io/sdk/client.NewAPIKeyStaticCredentials],
@@ -562,6 +572,8 @@ type (
562572
}
563573

564574
// ConnectionOptions is provided by SDK consumers to control optional connection params.
575+
//
576+
// Exposed as: [go.temporal.io/sdk/client.ConnectionOptions]
565577
ConnectionOptions struct {
566578
// TLS configures connection level security credentials.
567579
TLS *tls.Config
@@ -622,6 +634,8 @@ type (
622634
// StartWorkflowOptions configuration parameters for starting a workflow execution.
623635
// The current timeout resolution implementation is in seconds and uses math.Ceil(d.Seconds()) as the duration. But is
624636
// subjected to change in the future.
637+
//
638+
// Exposed as: [go.temporal.io/sdk/client.StartWorkflowOptions]
625639
StartWorkflowOptions struct {
626640
// ID - The business identifier of the workflow execution.
627641
// Optional: defaulted to a uuid.
@@ -779,6 +793,8 @@ type (
779793
// started time. Because of that, to check an activity has started or not, you cannot rely on history events. Instead,
780794
// you can use CLI to describe the workflow to see the status of the activity:
781795
// tctl --ns <namespace> wf desc -w <wf-id>
796+
//
797+
// Exposed as: [go.temporal.io/sdk/temporal.RetryPolicy]
782798
RetryPolicy struct {
783799
// Backoff interval for the first retry. If BackoffCoefficient is 1.0 then it is used for all retries.
784800
// If not set or set to 0, a default interval of 1s will be used.
@@ -840,19 +856,25 @@ type (
840856
)
841857

842858
// Credentials are optional credentials that can be specified in ClientOptions.
859+
//
860+
// Exposed as: [go.temporal.io/sdk/client.Credentials]
843861
type Credentials interface {
844862
applyToOptions(*ConnectionOptions) error
845863
// Can return nil to have no interceptor
846864
gRPCInterceptor() grpc.UnaryClientInterceptor
847865
}
848866

849867
// DialClient creates a client and attempts to connect to the server.
868+
//
869+
// Exposed as: [go.temporal.io/sdk/client.DialContext]
850870
func DialClient(ctx context.Context, options ClientOptions) (Client, error) {
851871
options.ConnectionOptions.disableEagerConnection = false
852872
return NewClient(ctx, options)
853873
}
854874

855875
// NewLazyClient creates a client and does not attempt to connect to the server.
876+
//
877+
// Exposed as: [go.temporal.io/sdk/client.NewLazyClient]
856878
func NewLazyClient(options ClientOptions) (Client, error) {
857879
options.ConnectionOptions.disableEagerConnection = true
858880
return NewClient(context.Background(), options)
@@ -861,12 +883,16 @@ func NewLazyClient(options ClientOptions) (Client, error) {
861883
// NewClient creates an instance of a workflow client
862884
//
863885
// Deprecated: Use DialClient or NewLazyClient instead.
886+
//
887+
// Exposed as: [go.temporal.io/sdk/client.NewClient]
864888
func NewClient(ctx context.Context, options ClientOptions) (Client, error) {
865889
return newClient(ctx, options, nil)
866890
}
867891

868892
// NewClientFromExisting creates a new client using the same connection as the
869893
// existing client.
894+
//
895+
// Exposed as: [go.temporal.io/sdk/client.NewClientFromExistingWithContext]
870896
func NewClientFromExisting(ctx context.Context, existingClient Client, options ClientOptions) (Client, error) {
871897
existing, _ := existingClient.(*WorkflowClient)
872898
if existing == nil {
@@ -1012,6 +1038,8 @@ func NewServiceClient(workflowServiceClient workflowservice.WorkflowServiceClien
10121038

10131039
// DialCloudOperationsClient creates a cloud client to perform cloud-management
10141040
// operations.
1041+
//
1042+
// Exposed as: [go.temporal.io/sdk/client.DialCloudOperationsClient]
10151043
func DialCloudOperationsClient(ctx context.Context, options CloudOperationsClientOptions) (CloudOperationsClient, error) {
10161044
// Set defaults
10171045
if options.MetricsHandler == nil {
@@ -1089,6 +1117,8 @@ func (op *withStartWorkflowOperationImpl) set(workflowRun WorkflowRun, err error
10891117
}
10901118

10911119
// NewNamespaceClient creates an instance of a namespace client, to manager lifecycle of namespaces.
1120+
//
1121+
// Exposed as: [go.temporal.io/sdk/client.NewNamespaceClient]
10921122
func NewNamespaceClient(options ClientOptions) (NamespaceClient, error) {
10931123
// Initialize root tags
10941124
if options.MetricsHandler == nil {
@@ -1129,6 +1159,8 @@ func newNamespaceServiceClient(workflowServiceClient workflowservice.WorkflowSer
11291159
//
11301160
// var result string // This need to be same type as the one passed to RecordHeartbeat
11311161
// NewValue(data).Get(&result)
1162+
//
1163+
// Exposed as: [go.temporal.io/sdk/client.NewValue]
11321164
func NewValue(data *commonpb.Payloads) converter.EncodedValue {
11331165
return newEncodedValue(data, nil)
11341166
}
@@ -1141,16 +1173,20 @@ func NewValue(data *commonpb.Payloads) converter.EncodedValue {
11411173
// var result1 string
11421174
// var result2 int // These need to be same type as those arguments passed to RecordHeartbeat
11431175
// NewValues(data).Get(&result1, &result2)
1176+
//
1177+
// Exposed as: [go.temporal.io/sdk/client.NewValues]
11441178
func NewValues(data *commonpb.Payloads) converter.EncodedValues {
11451179
return newEncodedValues(data, nil)
11461180
}
11471181

11481182
type apiKeyCredentials func(context.Context) (string, error)
11491183

1184+
// Exposed as: [go.temporal.io/sdk/client.NewAPIKeyStaticCredentials]
11501185
func NewAPIKeyStaticCredentials(apiKey string) Credentials {
11511186
return NewAPIKeyDynamicCredentials(func(ctx context.Context) (string, error) { return apiKey, nil })
11521187
}
11531188

1189+
// Exposed as: [go.temporal.io/sdk/client.NewAPIKeyDynamicCredentials]
11541190
func NewAPIKeyDynamicCredentials(apiKeyCallback func(context.Context) (string, error)) Credentials {
11551191
return apiKeyCredentials(apiKeyCallback)
11561192
}
@@ -1181,6 +1217,7 @@ func (a apiKeyCredentials) gRPCIntercept(
11811217

11821218
type mTLSCredentials tls.Certificate
11831219

1220+
// Exposed as: [go.temporal.io/sdk/client.NewMTLSCredentials]
11841221
func NewMTLSCredentials(certificate tls.Certificate) Credentials { return mTLSCredentials(certificate) }
11851222

11861223
func (m mTLSCredentials) applyToOptions(opts *ConnectionOptions) error {
@@ -1198,11 +1235,15 @@ func (mTLSCredentials) gRPCInterceptor() grpc.UnaryClientInterceptor { return ni
11981235
// WorkflowUpdateServiceTimeoutOrCanceledError is an error that occurs when an update call times out or is cancelled.
11991236
//
12001237
// 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.
1238+
//
1239+
// Exposed as: [go.temporal.io/sdk/client.WorkflowUpdateServiceTimeoutOrCanceledError]
12011240
type WorkflowUpdateServiceTimeoutOrCanceledError struct {
12021241
cause error
12031242
}
12041243

12051244
// NewWorkflowUpdateServiceTimeoutOrCanceledError creates a new WorkflowUpdateServiceTimeoutOrCanceledError.
1245+
//
1246+
// Exposed as: [go.temporal.io/sdk/client.NewWorkflowUpdateServiceTimeoutOrCanceledError]
12061247
func NewWorkflowUpdateServiceTimeoutOrCanceledError(err error) *WorkflowUpdateServiceTimeoutOrCanceledError {
12071248
return &WorkflowUpdateServiceTimeoutOrCanceledError{
12081249
cause: err,

‎internal/cmd/build/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func (b *builder) check() error {
108108
if err := b.runCmd(b.cmdFromRoot("go", "run", "./internal/cmd/tools/copyright/licensegen.go", "--verifyOnly")); err != nil {
109109
return fmt.Errorf("copyright check failed: %w", err)
110110
}
111+
// Run doclink check
112+
if err := b.runCmd(b.cmdFromRoot("go", "run", "./internal/cmd/tools/doclink/doclink.go")); err != nil {
113+
return fmt.Errorf("copyright check failed: %w", err)
114+
}
111115
return nil
112116
}
113117

0 commit comments

Comments
 (0)
Please sign in to comment.