Coder Social home page Coder Social logo

Comments (3)

sh00s avatar sh00s commented on August 17, 2024 2

For the first part, I propose to transform the PluginPack into something with the following interface:

// All plugins will have to derive from this class. The implementation has to
// ensure that calls to all methods are thread-safe
class Plugin {
 public:
  enum class Type {
    PLUGIN_COLLECTION = 0,
    CONFIG_SOURCE = 1,
    STATS_PUBLISHER = 2,
    TRACE_LOGGER = 3,
    ...
  };
  // Specifies the type this plugin belongs to.
  virtual Type type() const = 0;

  // Returns the identifier for this plugin. This can be used to:
  // 1) load multiple plugins of the same type and pick which one to use
  //    via configuration / settings, and
  // 2) have per-plugin configuration.
  // Identifiers should be unique for all plugins loaded.
  virtual std::string identifier() const = 0;

  // A string that we can log somewhere when using this plugin.
  virtual std::string displayName() const = 0;

  // Versioning information
  virtual std::string version() const = 0;

  // If per-plugin configuration is present in the config, it would be fed to the
  // plugin immediately after initialization and on every config update.
  void onConfigUpdated(folly::dynamic plugin_configuration) = 0;
};

// A helper that would be returned by a `load_plugin()` function to ease loading several
// plugins at once from a single library
class PluginCollection : public Plugin {
 public:
  Type type() override {
    return Type::PLUGIN_COLLECTION;
  }
  virtual std::vector<std::unique_ptr<Plugin>> getPlugins() = 0;
};

Then we'd have classes that derive from the Plugin class to implement each of the plugin types - e.g. TraceLoggerPlugin, ConfigSourcePlugin, etc. Each implementation would then have to derive from these.

This is off the top of my head, so suggestions for improvement are welcome.

from logdevice.

sh00s avatar sh00s commented on August 17, 2024

Separated #56 and #57 out of this

from logdevice.

sh00s avatar sh00s commented on August 17, 2024

This is mostly done. I added documentation in 84fbb0a to explain how to write new plugins, and filed the follow-ups mentioned above for the remaining parts.

from logdevice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.