Skip to content

Commit

Permalink
Merge 78de65b into a793745
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing authored May 1, 2021
2 parents a793745 + 78de65b commit a30403b
Show file tree
Hide file tree
Showing 39 changed files with 8,115 additions and 2,751 deletions.
3 changes: 2 additions & 1 deletion _examples/remote-activate/node1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ func main() {
timeout := 5 * time.Second

system := actor.NewActorSystem()
r := remote.NewRemote(system, remote.Configure("127.0.0.1", 8081))
remoteConfig := remote.Configure("127.0.0.1", 8081)
r := remote.NewRemote(system, remoteConfig)
r.Start()

rootContext := system.Root
Expand Down
11 changes: 6 additions & 5 deletions _examples/remote-activate/node2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ func newHelloActor() actor.Actor {
return &helloActor{}
}

func init() {
remote.Register("hello", actor.PropsFromProducer(newHelloActor))
}

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())

remote.Start("127.0.0.1:8080")
system := actor.NewActorSystem()
remoteConfig := remote.Configure("127.0.0.1", 8080,
remote.WithKind("hello", actor.PropsFromProducer(newHelloActor)))

remoter := remote.NewRemote(system, remoteConfig)
remoter.Start()

console.ReadLine()
}
2 changes: 1 addition & 1 deletion actor/actor_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (as *ActorSystem) GetHostPort() (host string, port int, err error) {
}

func NewActorSystem() *ActorSystem {
return NewActorSystemWithConfig(defaultActorSystemConfig())
return NewActorSystemWithConfig(defaultConfig())
}

func NewActorSystemWithConfig(config Config) *ActorSystem {
Expand Down
52 changes: 34 additions & 18 deletions actor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Config struct {
DiagnosticsSerializer func(Actor) string //extract diagnostics from actor and return as string
}

func defaultActorSystemConfig() Config {
func defaultConfig() Config {
return Config{
DeadLetterThrottleInterval: time.Duration(0),
DeadLetterThrottleCount: 0,
Expand All @@ -22,31 +22,47 @@ func defaultActorSystemConfig() Config {
}
}

func NewConfig() Config {
return defaultActorSystemConfig()
type ConfigOption func(config Config) Config

func Configure(options ...ConfigOption) Config {
config := defaultConfig()
for _, option := range options {
config = option(config)
}
return config
}

func (asc Config) WithDeadLetterThrottleInterval(duration time.Duration) Config {
asc.DeadLetterThrottleInterval = duration
return asc
func WithDeadLetterThrottleInterval(duration time.Duration) ConfigOption {
return func(config Config) Config {
config.DeadLetterThrottleInterval = duration
return config
}
}

func (asc Config) WithDeadLetterThrottleCount(count int32) Config {
asc.DeadLetterThrottleCount = count
return asc
func WithDeadLetterThrottleCount(count int32) ConfigOption {
return func(config Config) Config {
config.DeadLetterThrottleCount = count
return config
}
}

func (asc Config) WithDeadLetterRequestLogging(enabled bool) Config {
asc.DeadLetterRequestLogging = enabled
return asc
func WithDeadLetterRequestLogging(enabled bool) ConfigOption {
return func(config Config) Config {
config.DeadLetterRequestLogging = enabled
return config
}
}

func (asc Config) WithDeveloperSupervisionLogging(enabled bool) Config {
asc.DeveloperSupervisionLogging = enabled
return asc
func WithDeveloperSupervisionLogging(enabled bool) ConfigOption {
return func(config Config) Config {
config.DeveloperSupervisionLogging = enabled
return config
}
}

func (asc Config) WithDiagnosticsSerializer(serializer func(Actor) string) Config {
asc.DiagnosticsSerializer = serializer
return asc
func WithDiagnosticsSerializer(serializer func(Actor) string) ConfigOption {
return func(config Config) Config {
config.DiagnosticsSerializer = serializer
return config
}
}
Loading

0 comments on commit a30403b

Please sign in to comment.