-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from piyushdatazip/main
feat: CDC Postgres and CDK Changes
- Loading branch information
Showing
97 changed files
with
4,220 additions
and
1,912 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.git |
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 @@ | ||
FROM golang:1.22-alpine as base | ||
|
||
ADD . /home/app/ | ||
# ADD . /home/app/ | ||
WORKDIR /home/app/drivers/postgres/ | ||
|
||
RUN gofmt -l -s -w . | ||
RUN go build -o dsynk main.go | ||
RUN mv dsynk / | ||
RUN mv generated.json / | ||
|
||
FROM golang:1.21-alpine | ||
COPY --from=base /dsynk /home/ | ||
COPY --from=base /generated.json /home/generated.json | ||
ADD . /home | ||
|
||
LABEL io.eggwhite.version=2.0.24 | ||
LABEL io.eggwhite.name=airbyte/source-mysql | ||
|
||
WORKDIR /home | ||
ENTRYPOINT [ "./dsynk" ] |
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,24 @@ | ||
package base | ||
|
||
import ( | ||
"github.com/piyushsingariya/shift/protocol" | ||
"github.com/piyushsingariya/shift/types" | ||
"github.com/piyushsingariya/shift/utils" | ||
) | ||
|
||
// Pass dest with all fields initialized to handle nil state case | ||
func ManageGlobalState[T any](state *types.State, dest *T, driver protocol.BulkDriver) error { | ||
state.Type = driver.StateType() | ||
|
||
if state.Global != nil { | ||
err := utils.Unmarshal(state.Global, dest) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// set Global State reference | ||
state.Global = dest | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package base | ||
|
||
import ( | ||
"github.com/piyushsingariya/shift/protocol" | ||
"github.com/piyushsingariya/shift/types" | ||
"github.com/piyushsingariya/shift/typeutils" | ||
) | ||
|
||
type Driver struct { | ||
SourceStreams map[string]*types.Stream // locally cached streams; It contains all streams | ||
GroupRead bool // Used in CDC mode | ||
} | ||
|
||
func NewBase() *Driver { | ||
return &Driver{ | ||
SourceStreams: make(map[string]*types.Stream), | ||
} | ||
} | ||
|
||
func (d *Driver) BulkRead() bool { | ||
return d.GroupRead | ||
} | ||
|
||
func (d *Driver) UpdateState(stream protocol.Stream, data types.RecordData) error { | ||
datatype, err := stream.Schema().GetType(stream.Cursor()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if cursorVal, found := data[stream.Cursor()]; found && cursorVal != nil { | ||
// compare with current state | ||
if stream.GetState() != nil { | ||
state, err := typeutils.MaximumOnDataType(datatype, stream.GetState(), cursorVal) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
stream.SetState(state) | ||
} else { | ||
// directly update | ||
stream.SetState(cursorVal) | ||
} | ||
} | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package base | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/piyushsingariya/shift/logger" | ||
"github.com/piyushsingariya/shift/types" | ||
) | ||
|
||
type basestream interface { | ||
Name() string | ||
Namespace() string | ||
} | ||
|
||
func RetryOnFailure(attempts int, sleep *time.Duration, f func() error) (err error) { | ||
for i := 0; i < attempts; i++ { | ||
if err = f(); err == nil { | ||
return nil | ||
} | ||
|
||
logger.Infof("Retrying after %v...", sleep) | ||
time.Sleep(*sleep) | ||
} | ||
|
||
return err | ||
} | ||
|
||
func ReformatRecord(stream basestream, record map[string]any) types.Record { | ||
return types.Record{ | ||
Stream: stream.Name(), | ||
Namespace: stream.Namespace(), | ||
Data: record, | ||
} | ||
} |
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
File renamed without changes.
Oops, something went wrong.