Skip to content

Instantly share code, notes, and snippets.

@oklahomer
Created December 6, 2018 05:52
Show Gist options
  • Save oklahomer/04d44b1e5436d9727d5ee283247b223f to your computer and use it in GitHub Desktop.
Save oklahomer/04d44b1e5436d9727d5ee283247b223f to your computer and use it in GitHub Desktop.
package main
import (
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/AsynkronIT/protoactor-go/plugin"
)
type myPlugin struct {
}
func (_ *myPlugin) OnStart(actor.Context) {
// Do nothing
}
func (_ *myPlugin) OnOtherMessage(actor.Context, interface{}) {
// Do nothing
}
func main() {
// Construct plugin implementation
myPlugin := &myPlugin{}
// Wrap plugin implementation in a form of InboundMiddleware
middleware := plugin.Use(myPlugin)
props := actor.
FromFunc(func(ctx actor.Context) {
// Some logic comes here
}).
WithMiddleware(middleware) // Set as a middleware
pid := actor.Spawn(props)
pid.Tell("dummy message")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment