-
-
Save oklahomer/04d44b1e5436d9727d5ee283247b223f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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