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

Connection/event plugin type #6827

Closed
Stebalien opened this issue Jan 15, 2020 · 5 comments
Closed

Connection/event plugin type #6827

Stebalien opened this issue Jan 15, 2020 · 5 comments
Labels
kind/feature A new feature

Comments

@Stebalien
Copy link
Member

We need a plugin type that can respond to (libp2p) events (disconnect, connect, etc.).

@Stebalien Stebalien added the kind/feature A new feature label Jan 15, 2020
@Stebalien
Copy link
Member Author

We can use this to create a plugin that collects network stats.

@Stebalien Stebalien mentioned this issue Jan 15, 2020
21 tasks
@hsanjuan
Copy link
Contributor

Worth documenting a bit more where someone would start with something like this (in case the person is a bit new to the plugin/stat-collecting system). Pointers to modules, other plugins and stat-collectors would be nice.

@Stebalien
Copy link
Member Author

Good point.

  • The plugin types are defined in plugin/.
  • Existing plugins can be found in plugin/plugins/.
  • The plugin loader lives in plugin/loader/loader.go. You'll probably need to modify the Start function to hook into the appropriate libp2p events. For now, that'll just be the connect/disconnect events.

Technically, we don't even need a new plugin type: we can just use the internal plugin type. However, a new event plugin type would still be a nice addition.

The plugin itself will likely implement two interfaces:

  1. A new "EventPlugin" interface for accepting events. There are several possible designs here ranging from the "notifiee" design originally used by libp2p to the more recently introduced event bus design. Anyone implementing this feature should familiarize themselves with both designs.
  2. The standard Plugin interface. The plugin will be passed an environment on "Init" containing a Config. This config is loaded from "Plugins.Plugins.plugin-name in the ipfs config and can be used to, e.g., configure where the events are written (e.g., to a socket, http endpoint, etc.).

@dokterbob
Copy link
Contributor

This would be of great help for us at ipfs-search.com - we'd love to be able to index IPNS - but it seems there is currently no infrastructure to get that data out. Hence, it would be great if that (perhaps) could be included as events.

@Stebalien
Copy link
Member Author

@dokterbob there's now an "internal" plugin (disabled by default) in master that logs peer IDs using zap. You can build with it enabled by running make build IPFS_PLUGINS=peerlog.

Once we completely switch over to zap, it should be possible to turn on specific logging sub-systems and, e.g., log dht queries (which should get you content & ipns requests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A new feature
Projects
None yet
Development

No branches or pull requests

3 participants