-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: db event registry repository #42
Changes from all commits
33def58
35e45cb
0f4214f
c996d08
66abdca
6051700
024a75f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { | ||
CoreDependencies, | ||
DatabaseStrategyRegistry, | ||
IEventsRegistry, | ||
InMemoryCachedStrategyRegistry, | ||
InMemoryEventsRegistry, | ||
IStrategyRegistry, | ||
} from "@grants-stack-indexer/data-flow"; | ||
import { CoreDependencies } from "@grants-stack-indexer/data-flow"; | ||
import { EnvioIndexerClient } from "@grants-stack-indexer/indexer-client"; | ||
import { IpfsProvider } from "@grants-stack-indexer/metadata"; | ||
import { PricingProviderFactory } from "@grants-stack-indexer/pricing"; | ||
import { | ||
createKyselyDatabase, | ||
IEventRegistryRepository, | ||
IStrategyRegistryRepository, | ||
KyselyApplicationPayoutRepository, | ||
KyselyApplicationRepository, | ||
KyselyDonationRepository, | ||
KyselyEventRegistryRepository, | ||
KyselyProjectRepository, | ||
KyselyRoundRepository, | ||
KyselyStrategyRegistryRepository, | ||
|
@@ -24,9 +20,9 @@ import { Environment } from "../config/index.js"; | |
|
||
export type SharedDependencies = { | ||
core: Omit<CoreDependencies, "evmProvider">; | ||
registries: { | ||
eventsRegistry: IEventsRegistry; | ||
strategyRegistry: IStrategyRegistry; | ||
registriesRepositories: { | ||
eventRegistryRepository: IEventRegistryRepository; | ||
strategyRegistryRepository: IStrategyRegistryRepository; | ||
}; | ||
Comment on lines
+23
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the previous way was ok. I...Registry should be de dependency not I...RegistryRepository. Lmk if iam missing something There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i've changed the way it works by creating an instance per chain but using the same repository, since it's not really necessary to load into memory the if this makes sense, the same change applies for strategies (we create an instance per chain) but didn't want to mix and make the change for StrategyRegistry too. if we go for this approach, i'll make the change in another PR if smth it's not clear, we can discuss it offline 😄 |
||
indexerClient: EnvioIndexerClient; | ||
kyselyDatabase: ReturnType<typeof createKyselyDatabase>; | ||
|
@@ -35,7 +31,7 @@ export type SharedDependencies = { | |
/** | ||
* Shared dependencies service | ||
* - Initializes core dependencies (repositories, providers) | ||
* - Initializes registries | ||
* - Initializes registries repositories | ||
* - Initializes indexer client | ||
*/ | ||
export class SharedDependenciesService { | ||
|
@@ -68,20 +64,13 @@ export class SharedDependenciesService { | |
new Logger({ className: "IpfsProvider" }), | ||
); | ||
|
||
// Initialize registries | ||
const eventsRegistry = new InMemoryEventsRegistry( | ||
new Logger({ className: "InMemoryEventsRegistry" }), | ||
); | ||
const strategyRepository = new KyselyStrategyRegistryRepository( | ||
const eventRegistryRepository = new KyselyEventRegistryRepository( | ||
kyselyDatabase, | ||
env.DATABASE_SCHEMA, | ||
); | ||
const strategyRegistry = await InMemoryCachedStrategyRegistry.initialize( | ||
new Logger({ className: "InMemoryCachedStrategyRegistry" }), | ||
new DatabaseStrategyRegistry( | ||
new Logger({ className: "DatabaseStrategyRegistry" }), | ||
strategyRepository, | ||
), | ||
const strategyRegistryRepository = new KyselyStrategyRegistryRepository( | ||
kyselyDatabase, | ||
env.DATABASE_SCHEMA, | ||
); | ||
|
||
// Initialize indexer client | ||
|
@@ -100,9 +89,9 @@ export class SharedDependenciesService { | |
metadataProvider, | ||
applicationPayoutRepository, | ||
}, | ||
registries: { | ||
eventsRegistry, | ||
strategyRegistry, | ||
registriesRepositories: { | ||
eventRegistryRepository, | ||
strategyRegistryRepository, | ||
}, | ||
indexerClient, | ||
kyselyDatabase, | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason why you are doing this outside the
SharedDependenciesService
?