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

feat: DDS (Data Distribution Service) #826

Merged
merged 3 commits into from
Mar 29, 2024
Merged

feat: DDS (Data Distribution Service) #826

merged 3 commits into from
Mar 29, 2024

Conversation

sxyazi
Copy link
Owner

@sxyazi sxyazi commented Mar 18, 2024

This PR aims to address:

By introducing a new DDS (Data Distribution Service), allows communication and data synchronization between multiple Yazi instances through the plugin system.

It also provides a new mechanism to report Yazi events in real-time to external programs (such as Neovim) via stdout.

It's somewhat akin to a client-server architecture for lf but doesn't require running an additional server process and it's a Lua-based publish-subscribe pattern.

TODO

  • Windows support
  • Plugin system API
  • State persistence
  • Multi-tab and tabs event - will be implemented in subsequent PRs

I will add plugin API documentation to https://yazi-rs.github.io in the next few days.

@mikavilpas
Copy link
Contributor

mikavilpas commented Mar 18, 2024

I like the idea! 👍🏻

I wonder if I understand the architecture correctly - here's what I think is happening:

  • a global pubsub system is setup and communication between all running yazi instances (or other applications who want to listen in, perhaps) will happen via /tmp/yazi.sock, a unix socket (possibly something else for windows)
  • when yazi instances perform actions, such as copying files, these are broadcast to the global socket
  • actions of interest to editor integrations will, in addition, be written to stdout

Seems like stdout is added as a means of filtering events originating from a specific yazi instance only, as a sort of convenience feature. Or is the motivation performance?

As an example, Neovim's RPC has one socket per editor:

# this is executed in a terminal running embedded in neovim
❯ file $NVIM
/var/folders/23/y7gf7hz129l56_83w_g49jl80000gn/T/nvim.mikavilpas/Ngixlj/nvim.74060.0: socket
# neovim's remote documentation says this is a named pipe (which would indicate same system communication, not over the network), but I'm not sure if this is a mistake

But then again, neovim supports access over the network IIRC (I think some use it to talk to docker devcontainers from neovim), but I have not tried this out.

@sxyazi
Copy link
Owner Author

sxyazi commented Mar 19, 2024

Thank you for summarizing, that's roughly how it works. But stdout is only used for communication with external processes and is read-only.

This is the current idea and I'm still exploring if there's a better way and need to do some experimentation at the code level.

@sxyazi sxyazi changed the title [WIP] feat: DDS (Data Distribution Service) feat: DDS (Data Distribution Service) Mar 29, 2024
@sxyazi sxyazi merged commit 903f3da into main Mar 29, 2024
5 checks passed
@sxyazi sxyazi deleted the pr-208666f8 branch March 29, 2024 15:30
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide information about renamed files for editor integrations [Feature request] server/client architecture
2 participants