Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

upon coordinator failover, now it does refresh metadata and retry #220

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
upon coordinator failover, now it does refresh metadata and retry
  • Loading branch information
Michael Liao committed Apr 12, 2018
commit 675819a0a57412d240f5631d89a8c44b73926d3f
31 changes: 17 additions & 14 deletions src/kafunk/Kafka.fs
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,17 @@ type private RetryAction =

with

static member errorRetryAction (ec:ErrorCode) =
static member errorRetryAction (ec:ErrorCode) (topicNames:TopicName[]) =
match ec with
| ErrorCode.NoError -> None

| ErrorCode.NotCoordinatorForGroupCode | ErrorCode.GroupCoordinatorNotAvailableCode when topicNames.Length > 0 ->
Some (RefreshMetadataAndRetry topicNames)

| ErrorCode.LeaderNotAvailable | ErrorCode.RequestTimedOut | ErrorCode.GroupLoadInProgressCode | ErrorCode.GroupCoordinatorNotAvailableCode
| ErrorCode.NotEnoughReplicasAfterAppendCode | ErrorCode.NotEnoughReplicasCode ->
Some (RetryAction.WaitAndRetry)

| ErrorCode.NotCoordinatorForGroupCode | ErrorCode.IllegalGenerationCode | ErrorCode.OffsetOutOfRange | ErrorCode.UnknownMemberIdCode ->
Some (RetryAction.PassThru)

Expand All @@ -360,7 +363,7 @@ type private RetryAction =
| ErrorCode.UnknownTopicOrPartition ->
Some (x.topicErrorCode,RetryAction.RefreshMetadataAndRetry [|x.topicName|])
| _ ->
RetryAction.errorRetryAction x.topicErrorCode
RetryAction.errorRetryAction x.topicErrorCode [|x.topicName|]
|> Option.map (fun action -> x.topicErrorCode,action))

| ResponseMessage.OffsetResponse r ->
Expand All @@ -385,19 +388,19 @@ type private RetryAction =
| ErrorCode.NotLeaderForPartition | ErrorCode.UnknownTopicOrPartition ->
Some (ec, RetryAction.RefreshMetadataAndRetry [|topicName|])
| ec ->
RetryAction.errorRetryAction ec
RetryAction.errorRetryAction ec [|topicName|]
|> Option.map (fun action -> ec, action)))

| ResponseMessage.GroupCoordinatorResponse r ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun action -> r.errorCode,action)

| ResponseMessage.HeartbeatResponse r ->
match r.errorCode with
| ErrorCode.UnknownMemberIdCode | ErrorCode.IllegalGenerationCode | ErrorCode.RebalanceInProgressCode ->
Some (r.errorCode,RetryAction.PassThru)
| _ ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun action -> r.errorCode,action)

| ResponseMessage.OffsetFetchResponse r ->
Expand All @@ -412,7 +415,7 @@ type private RetryAction =
| ErrorCode.UnknownMemberIdCode | ErrorCode.IllegalGenerationCode | ErrorCode.RebalanceInProgressCode ->
Some (ec,RetryAction.PassThru)
| _ ->
RetryAction.errorRetryAction ec
RetryAction.errorRetryAction ec [|_t|]
|> Option.map (fun action -> ec,action)))

| ResponseMessage.OffsetCommitResponse r ->
Expand All @@ -424,44 +427,44 @@ type private RetryAction =
| ErrorCode.UnknownMemberIdCode | ErrorCode.IllegalGenerationCode | ErrorCode.RebalanceInProgressCode ->
Some (ec,RetryAction.PassThru)
| _ ->
RetryAction.errorRetryAction ec
RetryAction.errorRetryAction ec [|_tn|]
|> Option.map (fun action -> ec,action)))

| ResponseMessage.JoinGroupResponse r ->
match r.errorCode with
| ErrorCode.UnknownMemberIdCode ->
Some (r.errorCode,RetryAction.PassThru)
| _ ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun action -> r.errorCode,action)

| ResponseMessage.SyncGroupResponse r ->
match r.errorCode with
| ErrorCode.UnknownMemberIdCode | ErrorCode.IllegalGenerationCode | ErrorCode.RebalanceInProgressCode ->
Some (r.errorCode,RetryAction.PassThru)
| _ ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun action -> r.errorCode,action)

| ResponseMessage.LeaveGroupResponse r ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun action -> r.errorCode,action)

| ResponseMessage.DescribeGroupsResponse r ->
r.groups
|> Seq.tryPick (fun (ec,_,_,_,_,_) ->
RetryAction.errorRetryAction ec
RetryAction.errorRetryAction ec [||]
|> Option.map (fun action -> ec,action))

| ResponseMessage.ListGroupsResponse r ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun action -> r.errorCode,action)

| ResponseMessage.ProduceResponse _ ->
None

| ResponseMessage.ApiVersionsResponse r ->
RetryAction.errorRetryAction r.errorCode
RetryAction.errorRetryAction r.errorCode [||]
|> Option.map (fun a -> r.errorCode,a)


Expand Down