-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP][history] refactor history client with redirect wrapper #5762
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,14 @@ | |
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package history | ||
package peerresolver | ||
|
||
import ( | ||
"fmt" | ||
"github.com/uber/cadence/common" | ||
"github.com/uber/cadence/common/membership" | ||
"github.com/uber/cadence/common/service" | ||
"github.com/uber/cadence/common/types" | ||
) | ||
|
||
// PeerResolver is used to resolve history peers. | ||
|
@@ -100,3 +102,20 @@ | |
} | ||
return peers, nil | ||
} | ||
|
||
// FromRedirectKey resolve the peer from types.RedirectKey by a specific order | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's document the "specific order" so it's more explicit in documentation |
||
func (pr PeerResolver) FromRedirectKey(key types.RedirectKey) (string, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the other There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that's a good suggestion |
||
if key.ShardID != nil { | ||
return pr.FromShardID(*key.ShardID) | ||
} | ||
if key.WorkflowID != "" { | ||
return pr.FromWorkflowID(key.WorkflowID) | ||
} | ||
if key.DomainID != "" { | ||
return pr.FromDomainID(key.DomainID) | ||
} | ||
if key.HostAddress != "" { | ||
return pr.FromHostAddress(key.HostAddress) | ||
} | ||
return "", fmt.Errorf("RedirectKey is not valid: %v", key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add unit tests |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ | |
|
||
package types | ||
|
||
var ( | ||
_ RedirectRequest = (*HistoryStartWorkflowExecutionRequest)(nil) | ||
) | ||
|
||
// DescribeMutableStateRequest is an internal type (TBD...) | ||
type DescribeMutableStateRequest struct { | ||
DomainUUID string `json:"domainUUID,omitempty"` | ||
|
@@ -950,6 +954,11 @@ | |
return | ||
} | ||
|
||
// ToRedirectKey convert request to redirect key | ||
func (v *HistoryStartWorkflowExecutionRequest) ToRedirectKey() RedirectKey { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unit test please :) |
||
return RedirectKey{WorkflowID: v.StartRequest.WorkflowID} | ||
} | ||
|
||
// SyncActivityRequest is an internal type (TBD...) | ||
type SyncActivityRequest struct { | ||
DomainID string `json:"domainId,omitempty"` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package types | ||
|
||
// RedirectRequest interface for a redirect-able request | ||
type RedirectRequest interface { | ||
ToRedirectKey() RedirectKey | ||
} | ||
|
||
// RedirectKey entity of keys used for redirect | ||
type RedirectKey struct { | ||
ShardID *int | ||
WorkflowID string | ||
DomainID string | ||
HostAddress string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make fmt