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

Allow clients to specify one-directional sync #29

Open
ediphy-azorab opened this issue Jan 4, 2019 · 5 comments
Open

Allow clients to specify one-directional sync #29

ediphy-azorab opened this issue Jan 4, 2019 · 5 comments

Comments

@ediphy-azorab
Copy link
Contributor

I have a slightly unusual usecase where I want to sync from my development box to a cloud-side server, and then from that server to a number of docker containers cloud-side. The hub-and-spoke pattern will work fine for me, but in this particular case, if I've deleted a file on my laptop while I was disconnected, I don't want the server to send it back to me if it (likewise if any of the containers happen to have it).

If I could specify sync directions then I could set laptop -> server -> other clients and be sure I never get unexpected files appearing on my box after I've deleted them.

I suppose the main sticking point here might be that during the sync, if the laptop doesn't have the file the server should delete it, which is different/more complex logic than the current 'last write wins' strategy.

@stephenh
Copy link
Owner

stephenh commented Jan 6, 2019

Interesting. That doesn't seem particularly hard to implement, as you're right, passing around a flag to the diff code that says "this side always wins" seems easy enough.

I don't have time/itch to personally hack on this within the next ~weeks, but might get to it the next time I do a round of work on mirror.

Happy to review a PR if you take a crack at it. I can give some off-the-top-of-my-head ideas of what files/etc. to change if you're interested.

@ediphy-azorab
Copy link
Contributor Author

yeah, point me at it and I'll take a look

@stephenh
Copy link
Owner

Here is where the core "local wins / remote wins" logic is at:

https://github.com/stephenh/mirror/blob/master/src/main/java/mirror/UpdateTreeDiff.java#L68

Maybe having some sort of enum like LatestOverride.NONE, LOCAL, REMOTE, that then is then passed into the UpdateTreeDiff somehow.

It'd have to be a command line around here:

https://github.com/stephenh/mirror/blob/master/src/main/java/mirror/Mirror.java#L144

E.g. call ./mirror client ... --latest-override=local, and then passed to the server in the proto file:

https://github.com/stephenh/mirror/blob/master/src/main/proto/mirror.proto#L28

With an inversion, e.g. if the client is in LatestOverride.LOCAL mode, then the server should be told to use LatestOverride.REMOTE, so that it knows that it "looses" all newer decisions.

"LatestOverride" seems like an okay-ish name; could be something like "NewerOverride". Dunno, open to better names.

@ediphy-azorab
Copy link
Contributor Author

okay, looks straightforward enough. I'll try to get around to it this week 🙏

@ediphy-azorab
Copy link
Contributor Author

see #36

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

No branches or pull requests

2 participants