-
Notifications
You must be signed in to change notification settings - Fork 193
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(store-sync,store-indexer): consolidate sync logic, add syncToSqlite #1240
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2e5ebfa
add syncToSqlite
holic 85951bb
move indexer to syncToSqlite
holic f296ff2
wip start moving out shared logic
holic dc2f5fa
wip refactor
holic 3997dc1
Merge remote-tracking branch 'origin/main' into holic/sync-to-sqlite
holic 0f71589
it works
holic 9c62396
Merge remote-tracking branch 'origin/main' into holic/sync-to-sqlite
holic a1340d0
move TableWithRecords
holic 96cc55e
finish recs progress, make log optional, add id for react keys
holic d4cfc7a
move SyncStep import
holic fb5e481
update snapshot
holic cdc5a6f
add message to assert
holic 03eb28a
fixes after making log optional
holic 30709db
missed a spot
holic 2962c4c
some fixes
holic 92d823d
fix indexer live check
holic 7c32095
rework log handling, move 'all caught up' message
holic 94625b4
Create smooth-elephants-wave.md
holic 2cda399
remove ID
holic 992a3d4
Merge remote-tracking branch 'origin/main' into holic/sync-to-sqlite
holic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 @@ | ||
--- | ||
"@latticexyz/dev-tools": patch | ||
"@latticexyz/store-indexer": minor | ||
"@latticexyz/store-sync": minor | ||
--- | ||
|
||
Store sync logic is now consolidated into a `createStoreSync` function exported from `@latticexyz/store-sync`. This simplifies each storage sync strategy to just a simple wrapper around the storage adapter. You can now sync to RECS with `syncToRecs` or SQLite with `syncToSqlite` and PostgreSQL support coming soon. | ||
|
||
There are no breaking changes if you were just using `syncToRecs` from `@latticexyz/store-sync` or running the `sqlite-indexer` binary from `@latticexyz/store-indexer`. |
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
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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { assertExhaustive } from "@latticexyz/common/utils"; | ||
import { StoreEventsAbiItem } from "@latticexyz/store"; | ||
import { StoreConfig } from "@latticexyz/store"; | ||
import { StorageOperation } from "@latticexyz/store-sync"; | ||
|
||
type Props = { | ||
eventName: StoreEventsAbiItem["name"]; | ||
type: StorageOperation<StoreConfig>["type"]; | ||
}; | ||
|
||
export function EventIcon({ eventName }: Props) { | ||
switch (eventName) { | ||
case "StoreSetRecord": | ||
export function EventIcon({ type }: Props) { | ||
switch (type) { | ||
case "SetRecord": | ||
return <span className="text-green-500 font-bold">=</span>; | ||
case "StoreSetField": | ||
case "SetField": | ||
return <span className="text-cyan-500 font-bold">+</span>; | ||
case "StoreDeleteRecord": | ||
case "DeleteRecord": | ||
return <span className="text-red-500 font-bold">-</span>; | ||
case "StoreEphemeralRecord": | ||
return <span className="text-violet-400 font-bold">~</span>; | ||
// case "EphemeralRecord": | ||
// return <span className="text-violet-400 font-bold">~</span>; | ||
default: | ||
return assertExhaustive(eventName, `Unexpected event name: ${eventName}`); | ||
return assertExhaustive(type, `Unexpected storage operation type: ${type}`); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,6 @@ | ||
export enum SyncStep { | ||
INITIALIZE = "initialize", | ||
SNAPSHOT = "snapshot", | ||
RPC = "rpc", | ||
LIVE = "live", | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 the plan to add
EphemeralRecord
as a separateStorageOperation
or abstract it one level higher?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.
I haven't decided 🙈 any opinions?
Right now ephemeral records get collapsed/treated as
SetRecord
storage operations, but I can see the argument for exposing both and maybe our own adapters just treat them the same before inserting into RECS/SQLite.We don't distinguish them from each other when hydrating from the indexer, so it makes it a little weird/tricky to know what the current state ought to be.