Skip to content

Commit

Permalink
Support for caching workflowExecutionContext in history service (cade…
Browse files Browse the repository at this point in the history
…nce-workflow#19)

Moved WorkflowExecutionContext to its own file.  It now has lock which
can be used to make sure only one operation on workflow execution is
outstanding at any given time.  It clears the state for workflow
execution if update fails with conditional update failure.  Also sets
next event ID on the history builder when it goes through.

Added implementation for LRU cache which can be used for caching
workflow execution context.  Added historyCache implementation which is
the wrapper used by history engine to initialize the LRU cache for
caching workflowExecutionContext.

Added refresh logic to update cache when it detects an event ID greater than largest event ID ever seen inside the cache.
  • Loading branch information
samarabbas authored Mar 2, 2017
1 parent d9bfa1a commit 5529342
Show file tree
Hide file tree
Showing 15 changed files with 972 additions and 407 deletions.
143 changes: 77 additions & 66 deletions .gen/go/cadence/tchan-cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ func (c *tchanWorkflowServiceClient) GetWorkflowExecutionHistory(ctx thrift.Cont
}
success, err := c.client.Call(ctx, c.thriftService, "GetWorkflowExecutionHistory", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.EntityNotExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.EntityNotExistError != nil:
err = resp.EntityNotExistError
default:
err = fmt.Errorf("received no result or unknown exception for GetWorkflowExecutionHistory")
}
}

Expand All @@ -76,11 +77,13 @@ func (c *tchanWorkflowServiceClient) PollForActivityTask(ctx thrift.Context, pol
}
success, err := c.client.Call(ctx, c.thriftService, "PollForActivityTask", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
default:
err = fmt.Errorf("received no result or unknown exception for PollForActivityTask")
}
}

Expand All @@ -94,11 +97,13 @@ func (c *tchanWorkflowServiceClient) PollForDecisionTask(ctx thrift.Context, pol
}
success, err := c.client.Call(ctx, c.thriftService, "PollForDecisionTask", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
default:
err = fmt.Errorf("received no result or unknown exception for PollForDecisionTask")
}
}

Expand All @@ -112,14 +117,15 @@ func (c *tchanWorkflowServiceClient) RecordActivityTaskHeartbeat(ctx thrift.Cont
}
success, err := c.client.Call(ctx, c.thriftService, "RecordActivityTaskHeartbeat", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.EntityNotExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.EntityNotExistError != nil:
err = resp.EntityNotExistError
default:
err = fmt.Errorf("received no result or unknown exception for RecordActivityTaskHeartbeat")
}
}

Expand All @@ -133,14 +139,15 @@ func (c *tchanWorkflowServiceClient) RespondActivityTaskCanceled(ctx thrift.Cont
}
success, err := c.client.Call(ctx, c.thriftService, "RespondActivityTaskCanceled", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.EntityNotExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.EntityNotExistError != nil:
err = resp.EntityNotExistError
default:
err = fmt.Errorf("received no result or unknown exception for RespondActivityTaskCanceled")
}
}

Expand All @@ -154,14 +161,15 @@ func (c *tchanWorkflowServiceClient) RespondActivityTaskCompleted(ctx thrift.Con
}
success, err := c.client.Call(ctx, c.thriftService, "RespondActivityTaskCompleted", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.EntityNotExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.EntityNotExistError != nil:
err = resp.EntityNotExistError
default:
err = fmt.Errorf("received no result or unknown exception for RespondActivityTaskCompleted")
}
}

Expand All @@ -175,14 +183,15 @@ func (c *tchanWorkflowServiceClient) RespondActivityTaskFailed(ctx thrift.Contex
}
success, err := c.client.Call(ctx, c.thriftService, "RespondActivityTaskFailed", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.EntityNotExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.EntityNotExistError != nil:
err = resp.EntityNotExistError
default:
err = fmt.Errorf("received no result or unknown exception for RespondActivityTaskFailed")
}
}

Expand All @@ -196,14 +205,15 @@ func (c *tchanWorkflowServiceClient) RespondDecisionTaskCompleted(ctx thrift.Con
}
success, err := c.client.Call(ctx, c.thriftService, "RespondDecisionTaskCompleted", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.EntityNotExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.EntityNotExistError != nil:
err = resp.EntityNotExistError
default:
err = fmt.Errorf("received no result or unknown exception for RespondDecisionTaskCompleted")
}
}

Expand All @@ -217,14 +227,15 @@ func (c *tchanWorkflowServiceClient) StartWorkflowExecution(ctx thrift.Context,
}
success, err := c.client.Call(ctx, c.thriftService, "StartWorkflowExecution", &args, &resp)
if err == nil && !success {
if e := resp.BadRequestError; e != nil {
err = e
}
if e := resp.InternalServiceError; e != nil {
err = e
}
if e := resp.SessionAlreadyExistError; e != nil {
err = e
switch {
case resp.BadRequestError != nil:
err = resp.BadRequestError
case resp.InternalServiceError != nil:
err = resp.InternalServiceError
case resp.SessionAlreadyExistError != nil:
err = resp.SessionAlreadyExistError
default:
err = fmt.Errorf("received no result or unknown exception for StartWorkflowExecution")
}
}

Expand Down
Loading

0 comments on commit 5529342

Please sign in to comment.