-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-jose2go
- Loading branch information
Showing
24 changed files
with
986 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package peerflow | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/PeerDB-io/peer-flow/generated/protos" | ||
"github.com/PeerDB-io/peer-flow/model" | ||
"go.temporal.io/sdk/log" | ||
"go.temporal.io/sdk/workflow" | ||
) | ||
|
||
type NormalizeFlowState struct { | ||
CDCFlowName string | ||
Progress []string | ||
} | ||
|
||
type NormalizeFlowExecution struct { | ||
NormalizeFlowState | ||
executionID string | ||
logger log.Logger | ||
} | ||
|
||
func NewNormalizeFlowExecution(ctx workflow.Context, state *NormalizeFlowState) *NormalizeFlowExecution { | ||
return &NormalizeFlowExecution{ | ||
NormalizeFlowState: *state, | ||
executionID: workflow.GetInfo(ctx).WorkflowExecution.ID, | ||
logger: workflow.GetLogger(ctx), | ||
} | ||
} | ||
|
||
func NormalizeFlowWorkflow(ctx workflow.Context, | ||
config *protos.FlowConnectionConfigs, | ||
) (*model.NormalizeResponse, error) { | ||
s := NewNormalizeFlowExecution(ctx, &NormalizeFlowState{ | ||
CDCFlowName: config.FlowJobName, | ||
Progress: []string{}, | ||
}) | ||
|
||
return s.executeNormalizeFlow(ctx, config) | ||
} | ||
|
||
func (s *NormalizeFlowExecution) executeNormalizeFlow( | ||
ctx workflow.Context, | ||
config *protos.FlowConnectionConfigs, | ||
) (*model.NormalizeResponse, error) { | ||
s.logger.Info("executing normalize flow - ", s.CDCFlowName) | ||
|
||
normalizeFlowCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ | ||
StartToCloseTimeout: 7 * 24 * time.Hour, | ||
HeartbeatTimeout: 5 * time.Minute, | ||
}) | ||
|
||
// execute StartFlow on the peers to start the flow | ||
startNormalizeInput := &protos.StartNormalizeInput{ | ||
FlowConnectionConfigs: config, | ||
} | ||
fStartNormalize := workflow.ExecuteActivity(normalizeFlowCtx, flowable.StartNormalize, startNormalizeInput) | ||
|
||
var normalizeResponse *model.NormalizeResponse | ||
if err := fStartNormalize.Get(normalizeFlowCtx, &normalizeResponse); err != nil { | ||
return nil, fmt.Errorf("failed to flow: %w", err) | ||
} | ||
|
||
return normalizeResponse, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import prisma from '@/app/utils/prisma'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export async function POST(request: Request) { | ||
const { flowName } = await request.json(); | ||
const errCount = await prisma.flow_errors.count({ | ||
where: { | ||
flow_name: flowName, | ||
error_type: 'error', | ||
ack: false, | ||
}, | ||
}); | ||
let mirrorStatus: 'healthy' | 'failed'; | ||
if (errCount > 0) { | ||
mirrorStatus = 'failed'; | ||
} else { | ||
mirrorStatus = 'healthy'; | ||
} | ||
return new Response(JSON.stringify(mirrorStatus)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.