go.uber.org/cadence@v1.2.9/internal/internal_public.go (about)

     1  // Copyright (c) 2017 Uber Technologies, Inc.
     2  //
     3  // Permission is hereby granted, free of charge, to any person obtaining a copy
     4  // of this software and associated documentation files (the "Software"), to deal
     5  // in the Software without restriction, including without limitation the rights
     6  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     7  // copies of the Software, and to permit persons to whom the Software is
     8  // furnished to do so, subject to the following conditions:
     9  //
    10  // The above copyright notice and this permission notice shall be included in
    11  // all copies or substantial portions of the Software.
    12  //
    13  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19  // THE SOFTWARE.
    20  
    21  package internal
    22  
    23  // WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
    24  // Any of the APIs in this file are not supported for application level developers
    25  // and are subject to change without any notice.
    26  //
    27  // APIs that are internal to Cadence system developers and are public from the Go
    28  // point of view only to access them from other packages.
    29  
    30  import (
    31  	"time"
    32  
    33  	s "go.uber.org/cadence/.gen/go/shared"
    34  )
    35  
    36  type (
    37  	decisionHeartbeatFunc func(response interface{}, startTime time.Time) (*workflowTask, error)
    38  
    39  	// HistoryIterator iterator through history events
    40  	HistoryIterator interface {
    41  		// GetNextPage returns next page of history events
    42  		GetNextPage() (*s.History, error)
    43  		// Reset resets the internal state so next GetNextPage() call will return first page of events from beginning.
    44  		Reset()
    45  		// HasNextPage returns if there are more page of events
    46  		HasNextPage() bool
    47  	}
    48  
    49  	// WorkflowExecutionContext represents one instance of workflow execution state in memory. Lock must be obtained before
    50  	// calling into any methods.
    51  	WorkflowExecutionContext interface {
    52  		Lock()
    53  		Unlock(err error)
    54  		ProcessWorkflowTask(workflowTask *workflowTask) (completeRequest interface{}, err error)
    55  		ProcessLocalActivityResult(workflowTask *workflowTask, lar *localActivityResult) (interface{}, error)
    56  		// CompleteDecisionTask try to complete current decision task and get response that needs to be sent back to server.
    57  		// The waitLocalActivity is used to control if we should wait for outstanding local activities.
    58  		// If there is no outstanding local activities or if waitLocalActivity is false, the complete will return response
    59  		// which will be one of following:
    60  		// - RespondDecisionTaskCompletedRequest
    61  		// - RespondDecisionTaskFailedRequest
    62  		// - RespondQueryTaskCompletedRequest
    63  		// If waitLocalActivity is true, and there is outstanding local activities, this call will return nil.
    64  		CompleteDecisionTask(workflowTask *workflowTask, waitLocalActivity bool) interface{}
    65  		// GetDecisionTimeout returns the TaskStartToCloseTimeout
    66  		GetDecisionTimeout() time.Duration
    67  		GetCurrentDecisionTask() *s.PollForDecisionTaskResponse
    68  		IsDestroyed() bool
    69  		StackTrace() string
    70  	}
    71  
    72  	// WorkflowTaskHandler represents decision task handlers.
    73  	WorkflowTaskHandler interface {
    74  		// Processes the workflow task
    75  		// The response could be:
    76  		// - RespondDecisionTaskCompletedRequest
    77  		// - RespondDecisionTaskFailedRequest
    78  		// - RespondQueryTaskCompletedRequest
    79  		ProcessWorkflowTask(
    80  			task *workflowTask,
    81  			f decisionHeartbeatFunc,
    82  		) (response interface{}, err error)
    83  	}
    84  
    85  	// ActivityTaskHandler represents activity task handlers.
    86  	ActivityTaskHandler interface {
    87  		// Executes the activity task
    88  		// The response is one of the types:
    89  		// - RespondActivityTaskCompletedRequest
    90  		// - RespondActivityTaskFailedRequest
    91  		// - RespondActivityTaskCanceledRequest
    92  		Execute(taskList string, task *s.PollForActivityTaskResponse) (interface{}, error)
    93  	}
    94  )
    95  
    96  var enableVerboseLogging = false
    97  
    98  // EnableVerboseLogging enable or disable verbose logging. This is for internal use only.
    99  func EnableVerboseLogging(enable bool) {
   100  	enableVerboseLogging = enable
   101  }