Skip to content

Commit

Permalink
Merge pull request #457 from cupen/revert-456-fix-endpoint-crashloop
Browse files Browse the repository at this point in the history
Revert "Endpoint actor now doesn't crashloop"
  • Loading branch information
rogeralsing committed Feb 25, 2021
2 parents bab29b9 + 692aad2 commit 0de6c44
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions remote/endpoint_writer.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package remote

import (
io "io"
"time"

"github.com/AsynkronIT/protoactor-go/actor"
"github.com/AsynkronIT/protoactor-go/log"
"golang.org/x/net/context"
"google.golang.org/grpc"
"io"
)

func endpointWriterProducer(remote *Remote, address string, config *Config) actor.Producer {
Expand All @@ -27,13 +29,15 @@ type endpointWriter struct {
remote *Remote
}

func (state *endpointWriter) initialize() error {
func (state *endpointWriter) initialize() {
err := state.initializeInternal()
if err != nil {
plog.Error("EndpointWriter failed to connect", log.String("address", state.address), log.Error(err))
return err
// Wait 2 seconds to restart and retry
// Replace with Exponential Backoff
time.Sleep(2 * time.Second)
panic(err)
}
return nil
}

func (state *endpointWriter) initializeInternal() error {
Expand Down Expand Up @@ -170,14 +174,7 @@ func addToLookup(m map[string]int32, name string, a []string) (int32, []string)
func (state *endpointWriter) Receive(ctx actor.Context) {
switch msg := ctx.Message().(type) {
case *actor.Started:
err := state.initialize()
if err != nil {
plog.Error("Endpoint could not reach endpoint address - killing endpoint actor",
log.Error(err),
log.String("actorId", ctx.Self().GetId()),
log.String("actorAddress", ctx.Self().GetAddress()))
ctx.Stop(ctx.Self())
}
state.initialize()
case *actor.Stopped:
if state.stream != nil {
err := state.stream.CloseSend()
Expand Down

0 comments on commit 0de6c44

Please sign in to comment.