mirror of
https://github.com/mudler/luet.git
synced 2025-09-16 23:31:08 +00:00
Update go-pluggable
- Update vendor and run go mod tidy
This commit is contained in:
27
vendor/github.com/mudler/go-pluggable/README.md
generated
vendored
27
vendor/github.com/mudler/go-pluggable/README.md
generated
vendored
@@ -1,6 +1,7 @@
|
||||
# go-pluggable
|
||||
# :bento: go-pluggable
|
||||
[](https://pkg.go.dev/github.com/mudler/go-pluggable) [](https://goreportcard.com/report/github.com/mudler/go-pluggable) [](https://github.com/mudler/go-pluggable/actions?query=workflow%3ATest)
|
||||
|
||||
light Bus-event driven plugin library for Golang.
|
||||
:bento: *go-pluggable* is a light Bus-event driven plugin library for Golang.
|
||||
|
||||
`go-pluggable` implements the event/sub pattern to extend your Golang project with external binary plugins that can be written in any language.
|
||||
|
||||
@@ -24,8 +25,24 @@ func main() {
|
||||
m.Autoload("test", temp)
|
||||
m.Register()
|
||||
|
||||
// ...
|
||||
m.Publish(myEv, map[string]string{"foo": "bar"}) // test-foo, will receive our data as json payload
|
||||
// Optionally process plugin results response
|
||||
// The plugins has to return as output a json in stdout in the format { 'state': "somestate", data: "some data", error: "some error" }
|
||||
// e.g. with jq:
|
||||
// jq --arg key0 'state' \
|
||||
// --arg value0 '' \
|
||||
// --arg key1 'data' \
|
||||
// --arg value1 "" \
|
||||
// --arg key2 'error' \
|
||||
// --arg value2 '' \
|
||||
// '. | .[$key0]=$value0 | .[$key1]=$value1 | .[$key2]=$value2' \
|
||||
// <<<'{}'
|
||||
m.Response(myEv, func(p *pluggable.Plugin, r *pluggable.EventResponse) { ... })
|
||||
|
||||
// Emit events, they are encoded and passed as JSON payloads to the plugins.
|
||||
// In our case, test-foo will receive the map as JSON
|
||||
m.Publish(myEv, map[string]string{"foo": "bar"})
|
||||
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
```
|
||||
|
Reference in New Issue
Block a user