Skip to content

Prepare for multiple data-sources - #437

Merged
DZakh merged 6 commits into
mainfrom
dz/multiple-sources
Mar 4, 2025
Merged

Prepare for multiple data-sources#437
DZakh merged 6 commits into
mainfrom
dz/multiple-sources

Conversation

@DZakh

@DZakh DZakh commented Jan 24, 2025

Copy link
Copy Markdown
Member

Initial data-structures clean up to allow multiple data sources.

@DZakh
DZakh force-pushed the dz/multiple-sources branch from 53950f1 to e3061b5 Compare January 27, 2025 08:45
@DZakh
DZakh force-pushed the dz/multiple-sources branch from 1ce96af to b23489b Compare February 28, 2025 12:28
// require("mocha-reporter").hook(); //Outputs filename in error logs with mocha-reporter

describe("Raw Events Integration", () => {
describe.skip("Raw Events Integration", () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I couldn't make the test work, because hardhat doesn't actually run an rpc server.

I think it's fine to disable it for now, since our integration tests do pretty much the same thing.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we have an rpc integration test? Agree this test is fragile and I'd like to remove hardhat from our tests

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think no. Need to make one of the integration tests to use RPC

@DZakh
DZakh requested a review from JonoPrest February 28, 2025 12:34
@DZakh DZakh changed the title Support multiple sources Prepare for multiple data-sources Feb 28, 2025
logger: Pino.t,
sources: array<Source.t>,
maxPartitionConcurrency: int,
mutable activeSource: Source.t,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps it makes sense to just track the index here and expose activeSource via public api function. That way it's easy to deal with incrementing/swapping out the source?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll think about it 🤔

let topics = switch topicSelection {
| {topic0, topic1: [], topic2: [], topic3: []} => [topic0]
| {topic0, topic1, topic2: [], topic3: []} => [topic0, topic1]
| {topic0, topic1: [], topic2, topic3: []} => [topic0, %raw(`null`), topic2]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like empty topic 0 is not handled with the null case

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Perhaps there should be one more case with all of them empty

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel like there's a heck of a lot of cases to manually check like this. I kind of think pipelining it would be better. Like, map the topics into js nullable type and then pop off the null values from the end.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We don't allow empty topic0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd agree with you if we had nullable topic0, but in my opinion, having 8 cases in pattern matching is more straightforward than mapping & popping off trailing null values.
But I see your point. If you don't mind, I'll keep it like this, but the next time I touch the code, I'll change it to the solution you suggest.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't allow empty topic0

Ah yes, I forgot you can't wildcard without topic0

envioVersion,
envioApiToken,
ecosystem: ecosystem.contents,
ecosystem: (config.ecosystem :> ecosystem),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm guessing the type system would shout if the @as field were different here? Any reason not to just use the same type here as the one in config?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep

Comment on lines +525 to +529
let sourceManager = SourceManager.make(
~sources=[source],
~maxPartitionConcurrency=3,
~logger=Logging.logger,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe worth adding a mock function and calling at each of these places rather than inliniing all of them

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Cool Dmitry! Excited for the next changes 😄

@DZakh
DZakh enabled auto-merge (squash) March 4, 2025 11:28
@DZakh
DZakh merged commit 62890c0 into main Mar 4, 2025
@DZakh
DZakh deleted the dz/multiple-sources branch March 4, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants