This file contains hidden or 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
parentActor := gosiris.Actor{} | |
defer parentActor.Close() | |
gosiris.ActorSystem().RegisterActor("parentActor", &parentActor, nil) |
This file contains hidden or 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
childActor := gosiris.Actor{} | |
defer childActor.Close() | |
childActor.React("message", func(context gosiris.Context) { | |
context.Self.LogInfo(context, "Received %v\n", context.Data) | |
}) | |
gosiris.ActorSystem().SpawnActor(&parentActor, "childActor", &childActor, nil) |
This file contains hidden or 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
parentActorRef, _ := gosiris.ActorSystem().ActorOf("parentActor") | |
childActorRef, _ := gosiris.ActorSystem().ActorOf("childActor") | |
childActorRef.Tell(gosiris.EmptyContext, "message", "Hi! How are you?", parentActorRef) |
This file contains hidden or 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 ( | |
"gosiris/gosiris" | |
) | |
func main() { | |
gosiris.InitActorSystem(gosiris.SystemOptions{ | |
ActorSystemName: "ActorSystem", | |
}) |
This file contains hidden or 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
type StatefulActor struct { | |
gosiris.Actor | |
someState interface{} | |
} | |
statefulActor := new(StatefulActor).React("someEvent", func(context gosiris.Context) { | |
//Some behavior | |
}) |
This file contains hidden or 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
actor.React(gosiris.GosirisMsgChildClosed, func(context gosiris.Context) { | |
context.Self.LogInfo(context, "My child is closed") | |
}) |
This file contains hidden or 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
context.Self.AskForClose(context.Self) |
This file contains hidden or 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
angry := func(context gosiris.Context) { | |
if context.Data == "happy" { | |
context.Self.LogInfo(context, "Unbecome\n") | |
context.Self.Unbecome(context.MessageType) | |
} else { | |
context.Self.LogInfo(context, "Angrily receiving %v\n", context.Data) | |
} | |
} | |
happy := func(context gosiris.Context) { |
This file contains hidden or 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
gosiris.InitActorSystem(gosiris.SystemOptions{ | |
ActorSystemName: "ActorSystem", | |
RegistryUrl: "http://etcd:2379", | |
ZipkinOptions: gosiris.ZipkinOptions{ | |
Url: "http://zipkin:9411/api/v1/spans", | |
Debug: true, | |
HostPort: "0.0.0.0", | |
SameSpan: true, | |
}, | |
}) |
This file contains hidden or 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
actor1 := new(gosiris.Actor).React("reply", func(context gosiris.Context) { | |
context.Self.LogInfo(context, "Received: %v", context.Data) | |
}) | |
defer actor1.Close() | |
gosiris.ActorSystem().RegisterActor("actor1", actor1, new(gosiris.ActorOptions) | |
.SetRemote(true) | |
.SetRemoteType(gosiris.Amqp) | |
.SetUrl("amqp://guest:guest@amqp:5672/") | |
.SetDestination("actor1")) |