go.uber.org/cadence@v1.2.9/internal/common/isolationgroup/service_wrapper.go (about)

     1  // Copyright (c) 2021 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 isolationgroup
    22  
    23  import (
    24  	"context"
    25  
    26  	"go.uber.org/yarpc"
    27  
    28  	"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
    29  	"go.uber.org/cadence/.gen/go/shared"
    30  )
    31  
    32  const (
    33  	isolationGroupHeader = "cadence-client-isolation-group"
    34  )
    35  
    36  type workflowServiceIsolationGroupWrapper struct {
    37  	service                  workflowserviceclient.Interface
    38  	isolationGroupIdentifier string
    39  }
    40  
    41  // NewWorkflowServiceWrapper creates
    42  func NewWorkflowServiceWrapper(service workflowserviceclient.Interface, isolationGroup string) workflowserviceclient.Interface {
    43  	return &workflowServiceIsolationGroupWrapper{
    44  		service:                  service,
    45  		isolationGroupIdentifier: isolationGroup,
    46  	}
    47  }
    48  
    49  func (w *workflowServiceIsolationGroupWrapper) getIsolationGroupIdentifier() yarpc.CallOption {
    50  	return yarpc.WithHeader(isolationGroupHeader, w.isolationGroupIdentifier)
    51  }
    52  
    53  func (w *workflowServiceIsolationGroupWrapper) DeprecateDomain(ctx context.Context, request *shared.DeprecateDomainRequest, opts ...yarpc.CallOption) error {
    54  	opts = append(opts, w.getIsolationGroupIdentifier())
    55  	return w.service.DeprecateDomain(ctx, request, opts...)
    56  }
    57  
    58  func (w *workflowServiceIsolationGroupWrapper) ListDomains(ctx context.Context, request *shared.ListDomainsRequest, opts ...yarpc.CallOption) (*shared.ListDomainsResponse, error) {
    59  	opts = append(opts, w.getIsolationGroupIdentifier())
    60  	result, err := w.service.ListDomains(ctx, request, opts...)
    61  	return result, err
    62  }
    63  
    64  func (w *workflowServiceIsolationGroupWrapper) DescribeDomain(ctx context.Context, request *shared.DescribeDomainRequest, opts ...yarpc.CallOption) (*shared.DescribeDomainResponse, error) {
    65  	opts = append(opts, w.getIsolationGroupIdentifier())
    66  	result, err := w.service.DescribeDomain(ctx, request, opts...)
    67  	return result, err
    68  }
    69  
    70  func (w *workflowServiceIsolationGroupWrapper) DescribeWorkflowExecution(ctx context.Context, request *shared.DescribeWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.DescribeWorkflowExecutionResponse, error) {
    71  	opts = append(opts, w.getIsolationGroupIdentifier())
    72  	result, err := w.service.DescribeWorkflowExecution(ctx, request, opts...)
    73  	return result, err
    74  }
    75  
    76  func (w *workflowServiceIsolationGroupWrapper) GetWorkflowExecutionHistory(ctx context.Context, request *shared.GetWorkflowExecutionHistoryRequest, opts ...yarpc.CallOption) (*shared.GetWorkflowExecutionHistoryResponse, error) {
    77  	opts = append(opts, w.getIsolationGroupIdentifier())
    78  	result, err := w.service.GetWorkflowExecutionHistory(ctx, request, opts...)
    79  	return result, err
    80  }
    81  
    82  func (w *workflowServiceIsolationGroupWrapper) ListClosedWorkflowExecutions(ctx context.Context, request *shared.ListClosedWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListClosedWorkflowExecutionsResponse, error) {
    83  	opts = append(opts, w.getIsolationGroupIdentifier())
    84  	result, err := w.service.ListClosedWorkflowExecutions(ctx, request, opts...)
    85  	return result, err
    86  }
    87  
    88  func (w *workflowServiceIsolationGroupWrapper) ListOpenWorkflowExecutions(ctx context.Context, request *shared.ListOpenWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListOpenWorkflowExecutionsResponse, error) {
    89  	opts = append(opts, w.getIsolationGroupIdentifier())
    90  	result, err := w.service.ListOpenWorkflowExecutions(ctx, request, opts...)
    91  	return result, err
    92  }
    93  
    94  func (w *workflowServiceIsolationGroupWrapper) ListWorkflowExecutions(ctx context.Context, request *shared.ListWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListWorkflowExecutionsResponse, error) {
    95  	opts = append(opts, w.getIsolationGroupIdentifier())
    96  	result, err := w.service.ListWorkflowExecutions(ctx, request, opts...)
    97  	return result, err
    98  }
    99  
   100  func (w *workflowServiceIsolationGroupWrapper) ListArchivedWorkflowExecutions(ctx context.Context, request *shared.ListArchivedWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListArchivedWorkflowExecutionsResponse, error) {
   101  	opts = append(opts, w.getIsolationGroupIdentifier())
   102  	result, err := w.service.ListArchivedWorkflowExecutions(ctx, request, opts...)
   103  	return result, err
   104  }
   105  
   106  func (w *workflowServiceIsolationGroupWrapper) ScanWorkflowExecutions(ctx context.Context, request *shared.ListWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.ListWorkflowExecutionsResponse, error) {
   107  	opts = append(opts, w.getIsolationGroupIdentifier())
   108  	result, err := w.service.ScanWorkflowExecutions(ctx, request, opts...)
   109  	return result, err
   110  }
   111  
   112  func (w *workflowServiceIsolationGroupWrapper) CountWorkflowExecutions(ctx context.Context, request *shared.CountWorkflowExecutionsRequest, opts ...yarpc.CallOption) (*shared.CountWorkflowExecutionsResponse, error) {
   113  	opts = append(opts, w.getIsolationGroupIdentifier())
   114  	result, err := w.service.CountWorkflowExecutions(ctx, request, opts...)
   115  	return result, err
   116  }
   117  
   118  func (w *workflowServiceIsolationGroupWrapper) PollForActivityTask(ctx context.Context, request *shared.PollForActivityTaskRequest, opts ...yarpc.CallOption) (*shared.PollForActivityTaskResponse, error) {
   119  	opts = append(opts, w.getIsolationGroupIdentifier())
   120  	result, err := w.service.PollForActivityTask(ctx, request, opts...)
   121  	return result, err
   122  }
   123  
   124  func (w *workflowServiceIsolationGroupWrapper) PollForDecisionTask(ctx context.Context, request *shared.PollForDecisionTaskRequest, opts ...yarpc.CallOption) (*shared.PollForDecisionTaskResponse, error) {
   125  	opts = append(opts, w.getIsolationGroupIdentifier())
   126  	result, err := w.service.PollForDecisionTask(ctx, request, opts...)
   127  	return result, err
   128  }
   129  
   130  func (w *workflowServiceIsolationGroupWrapper) RecordActivityTaskHeartbeat(ctx context.Context, request *shared.RecordActivityTaskHeartbeatRequest, opts ...yarpc.CallOption) (*shared.RecordActivityTaskHeartbeatResponse, error) {
   131  	opts = append(opts, w.getIsolationGroupIdentifier())
   132  	result, err := w.service.RecordActivityTaskHeartbeat(ctx, request, opts...)
   133  	return result, err
   134  }
   135  
   136  func (w *workflowServiceIsolationGroupWrapper) RecordActivityTaskHeartbeatByID(ctx context.Context, request *shared.RecordActivityTaskHeartbeatByIDRequest, opts ...yarpc.CallOption) (*shared.RecordActivityTaskHeartbeatResponse, error) {
   137  	opts = append(opts, w.getIsolationGroupIdentifier())
   138  	result, err := w.service.RecordActivityTaskHeartbeatByID(ctx, request, opts...)
   139  	return result, err
   140  }
   141  
   142  func (w *workflowServiceIsolationGroupWrapper) RegisterDomain(ctx context.Context, request *shared.RegisterDomainRequest, opts ...yarpc.CallOption) error {
   143  	opts = append(opts, w.getIsolationGroupIdentifier())
   144  	err := w.service.RegisterDomain(ctx, request, opts...)
   145  	return err
   146  }
   147  
   148  func (w *workflowServiceIsolationGroupWrapper) RequestCancelWorkflowExecution(ctx context.Context, request *shared.RequestCancelWorkflowExecutionRequest, opts ...yarpc.CallOption) error {
   149  	opts = append(opts, w.getIsolationGroupIdentifier())
   150  	err := w.service.RequestCancelWorkflowExecution(ctx, request, opts...)
   151  	return err
   152  }
   153  
   154  func (w *workflowServiceIsolationGroupWrapper) RespondActivityTaskCanceled(ctx context.Context, request *shared.RespondActivityTaskCanceledRequest, opts ...yarpc.CallOption) error {
   155  	opts = append(opts, w.getIsolationGroupIdentifier())
   156  	err := w.service.RespondActivityTaskCanceled(ctx, request, opts...)
   157  	return err
   158  }
   159  
   160  func (w *workflowServiceIsolationGroupWrapper) RespondActivityTaskCompleted(ctx context.Context, request *shared.RespondActivityTaskCompletedRequest, opts ...yarpc.CallOption) error {
   161  	opts = append(opts, w.getIsolationGroupIdentifier())
   162  	err := w.service.RespondActivityTaskCompleted(ctx, request, opts...)
   163  	return err
   164  }
   165  
   166  func (w *workflowServiceIsolationGroupWrapper) RespondActivityTaskFailed(ctx context.Context, request *shared.RespondActivityTaskFailedRequest, opts ...yarpc.CallOption) error {
   167  	opts = append(opts, w.getIsolationGroupIdentifier())
   168  	err := w.service.RespondActivityTaskFailed(ctx, request, opts...)
   169  	return err
   170  }
   171  
   172  func (w *workflowServiceIsolationGroupWrapper) RespondActivityTaskCanceledByID(ctx context.Context, request *shared.RespondActivityTaskCanceledByIDRequest, opts ...yarpc.CallOption) error {
   173  	opts = append(opts, w.getIsolationGroupIdentifier())
   174  	err := w.service.RespondActivityTaskCanceledByID(ctx, request, opts...)
   175  	return err
   176  }
   177  
   178  func (w *workflowServiceIsolationGroupWrapper) RespondActivityTaskCompletedByID(ctx context.Context, request *shared.RespondActivityTaskCompletedByIDRequest, opts ...yarpc.CallOption) error {
   179  	opts = append(opts, w.getIsolationGroupIdentifier())
   180  	err := w.service.RespondActivityTaskCompletedByID(ctx, request, opts...)
   181  	return err
   182  }
   183  
   184  func (w *workflowServiceIsolationGroupWrapper) RespondActivityTaskFailedByID(ctx context.Context, request *shared.RespondActivityTaskFailedByIDRequest, opts ...yarpc.CallOption) error {
   185  	opts = append(opts, w.getIsolationGroupIdentifier())
   186  	err := w.service.RespondActivityTaskFailedByID(ctx, request, opts...)
   187  	return err
   188  }
   189  
   190  func (w *workflowServiceIsolationGroupWrapper) RespondDecisionTaskCompleted(ctx context.Context, request *shared.RespondDecisionTaskCompletedRequest, opts ...yarpc.CallOption) (*shared.RespondDecisionTaskCompletedResponse, error) {
   191  	opts = append(opts, w.getIsolationGroupIdentifier())
   192  	response, err := w.service.RespondDecisionTaskCompleted(ctx, request, opts...)
   193  	return response, err
   194  }
   195  
   196  func (w *workflowServiceIsolationGroupWrapper) RespondDecisionTaskFailed(ctx context.Context, request *shared.RespondDecisionTaskFailedRequest, opts ...yarpc.CallOption) error {
   197  	opts = append(opts, w.getIsolationGroupIdentifier())
   198  	err := w.service.RespondDecisionTaskFailed(ctx, request, opts...)
   199  	return err
   200  }
   201  
   202  func (w *workflowServiceIsolationGroupWrapper) SignalWorkflowExecution(ctx context.Context, request *shared.SignalWorkflowExecutionRequest, opts ...yarpc.CallOption) error {
   203  	opts = append(opts, w.getIsolationGroupIdentifier())
   204  	err := w.service.SignalWorkflowExecution(ctx, request, opts...)
   205  	return err
   206  }
   207  
   208  func (w *workflowServiceIsolationGroupWrapper) SignalWithStartWorkflowExecution(ctx context.Context, request *shared.SignalWithStartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.StartWorkflowExecutionResponse, error) {
   209  	opts = append(opts, w.getIsolationGroupIdentifier())
   210  	result, err := w.service.SignalWithStartWorkflowExecution(ctx, request, opts...)
   211  	return result, err
   212  }
   213  
   214  func (w *workflowServiceIsolationGroupWrapper) StartWorkflowExecution(ctx context.Context, request *shared.StartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.StartWorkflowExecutionResponse, error) {
   215  	opts = append(opts, w.getIsolationGroupIdentifier())
   216  	result, err := w.service.StartWorkflowExecution(ctx, request, opts...)
   217  	return result, err
   218  }
   219  
   220  func (w *workflowServiceIsolationGroupWrapper) TerminateWorkflowExecution(ctx context.Context, request *shared.TerminateWorkflowExecutionRequest, opts ...yarpc.CallOption) error {
   221  	opts = append(opts, w.getIsolationGroupIdentifier())
   222  	err := w.service.TerminateWorkflowExecution(ctx, request, opts...)
   223  	return err
   224  }
   225  
   226  func (w *workflowServiceIsolationGroupWrapper) ResetWorkflowExecution(ctx context.Context, request *shared.ResetWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.ResetWorkflowExecutionResponse, error) {
   227  	opts = append(opts, w.getIsolationGroupIdentifier())
   228  	result, err := w.service.ResetWorkflowExecution(ctx, request, opts...)
   229  	return result, err
   230  }
   231  
   232  func (w *workflowServiceIsolationGroupWrapper) UpdateDomain(ctx context.Context, request *shared.UpdateDomainRequest, opts ...yarpc.CallOption) (*shared.UpdateDomainResponse, error) {
   233  	opts = append(opts, w.getIsolationGroupIdentifier())
   234  	result, err := w.service.UpdateDomain(ctx, request, opts...)
   235  	return result, err
   236  }
   237  
   238  func (w *workflowServiceIsolationGroupWrapper) QueryWorkflow(ctx context.Context, request *shared.QueryWorkflowRequest, opts ...yarpc.CallOption) (*shared.QueryWorkflowResponse, error) {
   239  	opts = append(opts, w.getIsolationGroupIdentifier())
   240  	result, err := w.service.QueryWorkflow(ctx, request, opts...)
   241  	return result, err
   242  }
   243  
   244  func (w *workflowServiceIsolationGroupWrapper) ResetStickyTaskList(ctx context.Context, request *shared.ResetStickyTaskListRequest, opts ...yarpc.CallOption) (*shared.ResetStickyTaskListResponse, error) {
   245  	opts = append(opts, w.getIsolationGroupIdentifier())
   246  	result, err := w.service.ResetStickyTaskList(ctx, request, opts...)
   247  	return result, err
   248  }
   249  
   250  func (w *workflowServiceIsolationGroupWrapper) DescribeTaskList(ctx context.Context, request *shared.DescribeTaskListRequest, opts ...yarpc.CallOption) (*shared.DescribeTaskListResponse, error) {
   251  	opts = append(opts, w.getIsolationGroupIdentifier())
   252  	result, err := w.service.DescribeTaskList(ctx, request, opts...)
   253  	return result, err
   254  }
   255  
   256  func (w *workflowServiceIsolationGroupWrapper) RespondQueryTaskCompleted(ctx context.Context, request *shared.RespondQueryTaskCompletedRequest, opts ...yarpc.CallOption) error {
   257  	opts = append(opts, w.getIsolationGroupIdentifier())
   258  	err := w.service.RespondQueryTaskCompleted(ctx, request, opts...)
   259  	return err
   260  }
   261  
   262  func (w *workflowServiceIsolationGroupWrapper) GetSearchAttributes(ctx context.Context, opts ...yarpc.CallOption) (*shared.GetSearchAttributesResponse, error) {
   263  	opts = append(opts, w.getIsolationGroupIdentifier())
   264  	result, err := w.service.GetSearchAttributes(ctx, opts...)
   265  	return result, err
   266  }
   267  
   268  func (w *workflowServiceIsolationGroupWrapper) ListTaskListPartitions(ctx context.Context, request *shared.ListTaskListPartitionsRequest, opts ...yarpc.CallOption) (*shared.ListTaskListPartitionsResponse, error) {
   269  	opts = append(opts, w.getIsolationGroupIdentifier())
   270  	result, err := w.service.ListTaskListPartitions(ctx, request, opts...)
   271  	return result, err
   272  }
   273  
   274  func (w *workflowServiceIsolationGroupWrapper) GetClusterInfo(ctx context.Context, opts ...yarpc.CallOption) (*shared.ClusterInfo, error) {
   275  	opts = append(opts, w.getIsolationGroupIdentifier())
   276  	result, err := w.service.GetClusterInfo(ctx, opts...)
   277  	return result, err
   278  }
   279  
   280  func (w *workflowServiceIsolationGroupWrapper) GetTaskListsByDomain(ctx context.Context, request *shared.GetTaskListsByDomainRequest, opts ...yarpc.CallOption) (*shared.GetTaskListsByDomainResponse, error) {
   281  	opts = append(opts, w.getIsolationGroupIdentifier())
   282  	result, err := w.service.GetTaskListsByDomain(ctx, request, opts...)
   283  	return result, err
   284  }
   285  
   286  func (w *workflowServiceIsolationGroupWrapper) RefreshWorkflowTasks(ctx context.Context, request *shared.RefreshWorkflowTasksRequest, opts ...yarpc.CallOption) error {
   287  	opts = append(opts, w.getIsolationGroupIdentifier())
   288  	err := w.service.RefreshWorkflowTasks(ctx, request, opts...)
   289  	return err
   290  }
   291  
   292  func (w *workflowServiceIsolationGroupWrapper) RestartWorkflowExecution(ctx context.Context, request *shared.RestartWorkflowExecutionRequest, opts ...yarpc.CallOption) (*shared.RestartWorkflowExecutionResponse, error) {
   293  	opts = append(opts, w.getIsolationGroupIdentifier())
   294  	return w.service.RestartWorkflowExecution(ctx, request, opts...)
   295  }