https://github.com/xaxys/oasis
A simple go plugin server
https://github.com/xaxys/oasis
Last synced: 3 months ago
JSON representation
A simple go plugin server
- Host: GitHub
- URL: https://github.com/xaxys/oasis
- Owner: xaxys
- License: mit
- Created: 2020-03-07T10:10:14.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-09T06:35:31.000Z (about 5 years ago)
- Last Synced: 2025-01-02T07:23:15.484Z (5 months ago)
- Language: Go
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Oasis
Oasis is a go plugin server which provides basic plugin operation. You can easily create a plugin with its API and register it to the server to avoid write config operation or timely task operation etc.
# Plugins
You can find some useful plugin in this repository https://github.com/xaxys/Oasis_Plugins
# Update
* 2020/03/07 Initialized the repositories and released v 0.1.0
# Start
To build a oasis plugin, you need import `github.com/xaxys/oasis/api`. Recommand use `import . "github.com/xaxys/oasis/api"`. And create a struct containing `PluginBase` or rather `OasisAPI.PluginBase` for your plugin. And you shoud claim a variable named `PLUGIN` containing your struct which implements `UserPlugin`for server to load.
Here is a examle:
```go
package mainimport (
"fmt". "github.com/xaxys/oasis/api"
)var PLUGIN UserPlugin = &WhateverPlugin{
PluginBase: PluginBase{
PluginDescription: PluginDescription{
Name: "whatever",
Author: "xaxys",
Version: "0.1.2",
DefaultConfigFields: map[string]interface{}{
"name": "whatever",
},
Dependencies: []PluginDependency{
PluginDependency{
Name: "whatever3",
Version: "anyversion",
Comparator: ANY,
},
},
},
},
}type WhateverPlugin struct {
PluginBase
}func (p *WhateverPlugin) OnLoad() bool {
p.GetLogger().Infof("Exercuting OnLoad %s", p.Name)
plist := p.GetServer().GetPlugins()
for _, p := range plist {
fmt.Println(p)
}
return true
}// Custom your OnEnable
func (p *WhateverPlugin) OnEnable() bool {
return true
}// If you don't implement your OnDisable
// it Will use default Ondisable() in PluginBase
// and return true directly.
func (p *WhateverPlugin) OnDisable() bool {
return true
}
```