Skip to content

Commit

Permalink
more improvements with colours and moves peer inputs to top
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Nov 6, 2023
1 parent fa09ed7 commit 53043d1
Show file tree
Hide file tree
Showing 14 changed files with 254 additions and 237 deletions.
79 changes: 3 additions & 76 deletions ui/app/mirrors/create/cdc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,8 @@ export default function CDCConfigForm(props: MirrorConfigProps) {
);
};
const handleChange = (val: string | boolean, setting: MirrorSetting) => {
let stateVal: string | boolean | Peer | QRepSyncMode = val;
if (setting.label.includes('Peer')) {
stateVal = props.peers.find((peer) => peer.name === val)!;
if (setting.label === 'Destination Peer') {
if (stateVal.type === DBType.POSTGRES) {
props.setter((curr) => {
return {
...curr,
cdcSyncMode: QRepSyncMode.QREP_SYNC_MODE_MULTI_INSERT,
snapshotSyncMode: QRepSyncMode.QREP_SYNC_MODE_MULTI_INSERT,
};
});
} else if (stateVal.type === DBType.SNOWFLAKE) {
props.setter((curr) => {
return {
...curr,
cdcSyncMode: QRepSyncMode.QREP_SYNC_MODE_STORAGE_AVRO,
snapshotSyncMode: QRepSyncMode.QREP_SYNC_MODE_STORAGE_AVRO,
};
});
}
}
} else if (setting.label.includes('Sync Mode')) {
let stateVal: string | boolean | QRepSyncMode = val;
if (setting.label.includes('Sync Mode')) {
stateVal =
val === 'AVRO'
? QRepSyncMode.QREP_SYNC_MODE_STORAGE_AVRO
Expand All @@ -92,55 +71,6 @@ export default function CDCConfigForm(props: MirrorConfigProps) {

return (
<>
<RowWithSelect
label={
<Label>
Source Peer
{RequiredIndicator(true)}
</Label>
}
action={
<div
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
}}
>
<Select
placeholder='Select the source peer'
onValueChange={(val) =>
handleChange(val, {
label: 'Source Peer',
stateHandler: (value, setter) =>
setter((curr: CDCConfig) => ({
...curr,
source: value as Peer,
})),
})
}
>
{(props.peers ?? [])
.map((peer) => peer.name)
.map((peerName, id) => {
return (
<SelectItem key={id} value={peerName}>
{peerName}
</SelectItem>
);
})}
</Select>
<InfoPopover
tips={
'The peer from which we will be replicating data. Ensure the prerequisites for this peer are met.'
}
link={
'https://docs.peerdb.io/usecases/Real-time%20CDC/postgres-to-snowflake#prerequisites'
}
/>
</div>
}
/>
{props.mirrorConfig.source && (
<TableMapping
sourcePeerName={props.mirrorConfig.source.name}
Expand Down Expand Up @@ -210,10 +140,7 @@ export default function CDCConfigForm(props: MirrorConfigProps) {
: undefined
}
>
{(setting.label.includes('Peer')
? (props.peers ?? []).map((peer) => peer.name)
: ['AVRO', 'Copy with Binary']
).map((item, id) => {
{['AVRO', 'Copy with Binary'].map((item, id) => {
return (
<SelectItem key={id} value={item.toString()}>
{item.toString()}
Expand Down
13 changes: 2 additions & 11 deletions ui/app/mirrors/create/helpers/cdc.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import { QRepSyncMode } from '@/grpc_generated/flow';
import { Peer } from '@/grpc_generated/peers';
import { CDCConfig } from '../../../dto/MirrorsDTO';
import { MirrorSetting } from './common';
export const cdcSettings: MirrorSetting[] = [
{
label: 'Destination Peer',
stateHandler: (value, setter) =>
setter((curr: CDCConfig) => ({ ...curr, destination: value as Peer })),
tips: 'The peer to which data will be replicated.',
type: 'select',
required: true,
},
{
label: 'Initial Copy',
stateHandler: (value, setter) =>
Expand Down Expand Up @@ -55,10 +46,10 @@ export const cdcSettings: MirrorSetting[] = [
stateHandler: (value, setter) =>
setter((curr: CDCConfig) => ({
...curr,
snapshotMaxParallelWorkers: parseInt(value as string, 10) || 8,
snapshotMaxParallelWorkers: parseInt(value as string, 10) || 1,
})),
tips: 'PeerDB spins up parallel threads for each partition. This setting controls the number of partitions to sync in parallel. The default value is 8.',
default: '8',
default: '1',
type: 'number',
},
{
Expand Down
4 changes: 2 additions & 2 deletions ui/app/mirrors/create/helpers/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const blankCDCSetting: FlowConnectionConfigs = {
doInitialCopy: false,
publicationName: '',
snapshotNumRowsPerPartition: 500000,
snapshotMaxParallelWorkers: 8,
snapshotMaxParallelWorkers: 1,
snapshotNumTablesInParallel: 1,
snapshotSyncMode: 0,
cdcSyncMode: 0,
Expand All @@ -57,7 +57,7 @@ export const blankQRepSetting: QRepConfig = {
syncMode: 0,
batchSizeInt: 0,
batchDurationSeconds: 0,
maxParallelWorkers: 8,
maxParallelWorkers: 1,
waitBetweenBatchesSeconds: 30,
writeMode: undefined,
stagingPath: '',
Expand Down
26 changes: 2 additions & 24 deletions ui/app/mirrors/create/helpers/qrep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,8 @@ import {
QRepWriteMode,
QRepWriteType,
} from '@/grpc_generated/flow';
import { Peer } from '@/grpc_generated/peers';
import { MirrorSetting } from './common';
export const qrepSettings: MirrorSetting[] = [
{
label: 'Source Peer',
stateHandler: (value, setter) =>
setter((curr: QRepConfig) => ({ ...curr, sourcePeer: value as Peer })),
tips: 'The peer from which we will be replicating data. Ensure the prerequisites for this peer are met.',
helpfulLink:
'https://docs.peerdb.io/usecases/Real-time%20CDC/postgres-to-snowflake#prerequisites',
type: 'select',
required: true,
},
{
label: 'Destination Peer',
stateHandler: (value, setter) =>
setter((curr: QRepConfig) => ({
...curr,
destinationPeer: value as Peer,
})),
tips: 'The peer to which data will be replicated.',
type: 'select',
required: true,
},
{
label: 'Table',
stateHandler: (value, setter) =>
Expand Down Expand Up @@ -84,10 +62,10 @@ export const qrepSettings: MirrorSetting[] = [
stateHandler: (value, setter) =>
setter((curr: QRepConfig) => ({
...curr,
maxParallelWorkers: parseInt(value as string, 10) || 8,
maxParallelWorkers: parseInt(value as string, 10) || 1,
})),
tips: 'PeerDB spins up parallel threads for each partition. This setting controls the number of partitions to sync in parallel. The default value is 8.',
default: '8',
default: '1',
type: 'number',
},
{
Expand Down
Loading

0 comments on commit 53043d1

Please sign in to comment.