Coder Social home page Coder Social logo

nori-io / nori Goto Github PK

View Code? Open in Web Editor NEW
3.0 5.0 0.0 966 KB

Golang Plugin Engine

Home Page: https://nori.io

License: Apache License 2.0

Go 96.52% Makefile 2.13% Shell 0.06% Dockerfile 1.29%
golang plugin plugins plugin-engine plugin-manager plugin-architecture rapid-development rest-api web plugin-system

nori's Introduction

Nori Engine

Nori is plugin engine for Golang.

All you need:

  1. Implement Plugin interface and compile you project as golang plugin
  2. Put your file into plugin directory
  3. Start Nori

Run Nori

./nori server --config="/etc/nori/config.json"

--config - path to your config file, by default Nori looking for config in ~/.config/nori

Configuration

  • plugins.dir []string - paths to plugins dirs

Example config file:

{
  "nori": {
    "storage": {
      "type": "none"
    }
  },
  "plugins": {
    "dir": [
        "/home/nori/.config/nori/plugins"
    ]
  },
  "http": {
    "addr": "localhost:8089"
  }
}

Core Plugins

Semantic Versioning

This repo uses Semantic versioning (http://semver.org/), so

MAJOR version when you make incompatible API changes, MINOR version when you add functionality in a backwards-compatible manner, and PATCH version when you make backwards-compatible bug fixes.

Contributors

  • Sergei Che
  • Stan Shulga
  • Anita Nabieva

nori's People

Contributors

bruteforce1414 avatar cheebo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nori's Issues

Core Plugins implementation

Idea: core interfaces can be pluggable.
Nori can load implementation of core interfaces from plugin files.
Nori configuration has separate config options / keys to load these plugins.

{
 "nori": {
    "plugins": [
      "/opt/nori/plugins/storage.so",
      "/opt/nori/plugins/logger.so"
    ]
  }
}

Requirements to Core Plugins:

  1. Implement core interface (for example Storage)
  2. Export Plugin variable with interface implementation

Pluggable core interfaces: Hook, Storage.

Package dependency. Not enough information about ring.

There is no information about plugins with ring in line 527
=== RUN TestDependencyGraph_Sort10
--- PASS: TestDependencyGraph_Sort10 (0.00s)
graph_test.go:508: Plugins' order until sorting:
graph_test.go:514: Plugin n. 1 in list until sotring: plugin2:1.0 Dependencies:
graph_test.go:518: Dependence n. 1 for plugin2 is [plugin3:>=1.0, <2.0][interface: Custom]
graph_test.go:514: Plugin n. 2 in list until sotring: plugin3:1.0 Dependencies:
graph_test.go:518: Dependence n. 1 for plugin3 is [plugin2:>=1.0, <2.0][interface: Custom]
graph_test.go:524:
graph_test.go:527: dependency cycle found

Package dependency. Wrong information about self-ring.

Wrong information in line 498. Must be information about ring
=== RUN TestDependencyGraph_Sort9
--- PASS: TestDependencyGraph_Sort9 (0.00s)
graph_test.go:479: Plugins' order until sorting:
graph_test.go:485: Plugin n. 1 in list until sotring: plugin1:1.0 Dependencies:
graph_test.go:489: Dependence n. 1 for plugin1 is [plugin1:>=1.0, <2.0][interface: Custom]
graph_test.go:495:
graph_test.go:498: plugin1:1.0
Dependency [plugin1][>=1.0, <2.0] not found

Nori Documentation: Intro / Get started

Create documentation: Intro / Get started:

Intro / Get started

There are two main ways to get started with Nori

  • Tutorial: Step-by-step instructions on how to install Nori, use and develop plugins.
  • Quick start: One page summary of how to install Nori and use plugins.

nori-io/nori/core/plugins/dependency/manager_test.go fail

=== RUN TestManager_Resolve
--- FAIL: TestManager_Resolve (0.00s)
panic:
assert: mock: I don't know what to return because the method call was unexpected.
Either do Mock.On("GetInterface").Return(...) first, or remove the GetInterface() call.
This method was unexpected:
GetInterface()

at: [Meta.go:73 manager.go:138 manager.go:83 manager_test.go:89] [recovered]
panic: 

assert: mock: I don't know what to return because the method call was unexpected.
Either do Mock.On("GetInterface").Return(...) first, or remove the GetInterface() call.
This method was unexpected:
GetInterface()

at: [Meta.go:73 manager.go:138 manager.go:83 manager_test.go:89]

Implement Storage interface

Implement Storage interface from nori-common to get opportunity to store nori internal state in memory or in permanent storage system.

Implementations:

  • in memory
  • bolt db

Core refactoring

Nori Engine Refactoring

  • Registry
  • Plugin Manager
  • Dependency Manager
  • ConfigManager

graph_test.go

Add information about absent interface.
In last string interface is absent. Add additi:nal information in Sort() function?
Result of test n.5:
graph_test.go:307: Plugins' order until sorting:
graph_test.go:313: Plugin n. 1 in list until sotring: plugin1:1.0 Dependencies:
graph_test.go:317: Dependence n. 1 for plugin1 is [:>1.0][interface: HTTP]
graph_test.go:323:
graph_test.go:326: plugin1:1.0
Dependency [][
>1.0] not found

Compilation in docker

Compile plugin in docker:

  • create bash script to compile plugin from specific directory, for example go build -buildmode=plugin -o /app/plugin/plugins.so /app/plugin/plugin.go
  • create docker image to call script from #1 and compile plugins from mounted volume and put result back into this mounted directory:
    go build -buildmode=plugin -o /{mounted_volume_path}/plugins.so /{mounted_volume_path}/plugin.go

DifOfDone: run docker image with -v flagto mount directory with plugin sources, it executes, it finishs, we can see compiled plugin inside mounted directory

Problem with DB Endine

When ENGINE=MyISAM;
error occured

ERRO[0000] Error 1071: Specified key was too long; max key length is 1000 bytes

It worked when INNODB

Plugin was built with a different version of package internal/cpu"

Error occured, when plugins tried to start by engine Nori. Engine built in docker container.
Docker built Nori by golang 1.13.4
Plugins was built by golang 1.13.4 too with Makefile.
Error is "Plugin was built with a different version of package internal/cpu" for all plugins

Plugin dependency configuration

Plugin can request interfaces from the Registry.

Nori must support:

  1. Registry can load multiple plugins with the same interface with no error.

For example, 2 plugins implement nori/Cache interface. One plugin implements this interface for reads, another plugin implements this interfaces for memcached.

It would be great to have opportunity to configure which plugin Registry must return on interface request by specific plugin.

For example, templates plugin requests nori/Cache interface and receives memcached but sessions plugin receives redis on the same interface request .

Config example:

plugins: 
  - nori/templates: # plugin id
    - nori/Cache: "nori/redis:2.1.3" # interface: id:version
  - nori/sessions: # plugin id
    - nori/Cache: "nori/memcached:1.0.2" # interface: id:version

Nori Documentation: Plugin development

Tutorial how to develop plugin

  • Plugin interface
  • Plugin dependencies
  • How to compile
  • How to configure and deploy

Tutorial must provides information of plugin design and shows how to develop and deploy your own plugin.

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.