Skip to content
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

✨ Source MongoDB Internal POC: Use global state for CDC #29678

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected Map<String, MongodbStreamState> convertState(final JsonNode state) {

// TODO add namespace support?
return states.stream()
.filter(s -> s.getType() == AirbyteStateType.STREAM)
.filter(s -> s.getType() == AirbyteStateType.GLOBAL)
.map(s -> new CollectionNameState(
Optional.ofNullable(s.getStream().getStreamDescriptor()).map(StreamDescriptor::getName),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the comment below -> we should probably be using getGlobal

Jsons.tryObject(s.getStream().getStreamState(), MongodbStreamState.class)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public AirbyteMessage next() {
}

final var stateMessage = new AirbyteStateMessage()
.withType(AirbyteStateType.STREAM)
.withType(AirbyteStateType.GLOBAL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this all we need to do? I would expect to have to do a little more than that. Based on my understanding of stream vs global, I would expect for us to be setting the state of all streams in one same message when using the GLOBAL type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to need to change what we put in there, but we are not there yet. This should still work for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to create an object of the AirbyteGlobalState and then set the parameters in that object. Something like

 final AirbyteGlobalState globalState = new AirbyteGlobalState();
      globalState.setSharedState(debezium_state);
      globalState.setStreamStates(array_containing_all_the_streams);
      
 final var stateMessage = new AirbyteStateMessage()
          .withType(AirbyteStateType.GLOBAL)
          .withGlobal(globalState);      

.withStream(streamState);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the above comment, I would guess that we need to change this to withGlobal


return new AirbyteMessage().withType(Type.STATE).withState(stateMessage);
Expand Down